From 975b2e7bfc18cdf0e5e1c83440f9daaa439c699f Mon Sep 17 00:00:00 2001 From: Oliver Schulz <64468276+olschulz@users.noreply.github.com> Date: Thu, 15 Jun 2023 13:14:31 +0200 Subject: [PATCH] 530 look into amazon simple email service (#547) * add basic amazon ses configuration * cherry-pick some changes from permissions branch and slightly adjust them to work with current permissions system * adjust contact page design by using mui components * add email field to archives * use archive email attribute instead of address config; change email text * add email field to archive form and standardize colons * fix styling * move aws ses region into env file * improve typings and error handling a bit * update context type and use it for growthbook middleware * implement review feedback --- .../src/components/common/PrimaryButton.tsx | 9 +- .../views/archives/ArchiveEditView.scss | 3 +- .../views/archives/ArchiveEditView.tsx | 29 +- .../views/archives/ArchiveInputField.tsx | 2 +- .../views/archives/ArchiveLinkForm.tsx | 2 +- .../views/archives/ArchiveLogoInput.tsx | 2 +- .../views/contact/ContactFormView.tsx | 165 ++++++--- .../bp-gallery/src/graphql/APIConnector.tsx | 89 ++++- .../bp-gallery/src/graphql/operation.graphql | 3 +- .../bp-gallery/src/graphql/schema/schema.json | 32 ++ .../src/hooks/onchange-setter.hook.ts | 10 + .../bp-gallery/src/shared/locales/de.json | 18 +- .../bp-graphql/src/operations/getArchive.ts | 1 + .../src/operations/getArchiveNames.ts | 19 + projects/bp-strapi/config/plugins.js | 23 +- projects/bp-strapi/package.json | 3 + .../content-types/archive-tag/schema.json | 3 + .../src/api/contact/config/adresses.json | 4 - .../src/api/contact/controllers/contact.js | 25 -- .../src/api/contact/controllers/contact.ts | 7 + .../src/api/contact/services/contact.js | 7 - .../src/api/contact/services/contact.ts | 73 ++++ .../src/api/contact/services/mailText.ts | 31 ++ .../src/middlewares/growthbook-client.ts | 27 +- projects/bp-strapi/src/types.ts | 33 +- projects/bp-strapi/yarn.lock | 328 +++++++++++++++++- 26 files changed, 803 insertions(+), 145 deletions(-) create mode 100644 projects/bp-gallery/src/hooks/onchange-setter.hook.ts create mode 100644 projects/bp-graphql/src/operations/getArchiveNames.ts delete mode 100644 projects/bp-strapi/src/api/contact/config/adresses.json delete mode 100644 projects/bp-strapi/src/api/contact/controllers/contact.js create mode 100644 projects/bp-strapi/src/api/contact/controllers/contact.ts delete mode 100644 projects/bp-strapi/src/api/contact/services/contact.js create mode 100644 projects/bp-strapi/src/api/contact/services/contact.ts create mode 100644 projects/bp-strapi/src/api/contact/services/mailText.ts diff --git a/projects/bp-gallery/src/components/common/PrimaryButton.tsx b/projects/bp-gallery/src/components/common/PrimaryButton.tsx index 54cf2b934..0daec8332 100644 --- a/projects/bp-gallery/src/components/common/PrimaryButton.tsx +++ b/projects/bp-gallery/src/components/common/PrimaryButton.tsx @@ -7,16 +7,21 @@ const PrimaryButton = ({ children, onClickFn, isShowMore, + type, + className, }: PropsWithChildren<{ - onClickFn: MouseEventHandler; + onClickFn?: MouseEventHandler; isShowMore?: boolean; + type?: 'button' | 'submit' | 'reset'; + className?: string; }>) => { return ( diff --git a/projects/bp-gallery/src/components/views/archives/ArchiveEditView.scss b/projects/bp-gallery/src/components/views/archives/ArchiveEditView.scss index c5895d9d8..2ebfe5f33 100644 --- a/projects/bp-gallery/src/components/views/archives/ArchiveEditView.scss +++ b/projects/bp-gallery/src/components/views/archives/ArchiveEditView.scss @@ -53,8 +53,6 @@ display: flex; flex-direction: row; margin: 2rem 0; - flex-wrap: wrap; - @media (max-width: 1250px) { flex-direction: column; margin: 1rem 0; @@ -62,6 +60,7 @@ .archive-form-label { margin-top: 1rem; + flex-shrink: 0; width: 20%; display: flex; align-items: flex-start; diff --git a/projects/bp-gallery/src/components/views/archives/ArchiveEditView.tsx b/projects/bp-gallery/src/components/views/archives/ArchiveEditView.tsx index f45c89b90..e6f96e7d3 100644 --- a/projects/bp-gallery/src/components/views/archives/ArchiveEditView.tsx +++ b/projects/bp-gallery/src/components/views/archives/ArchiveEditView.tsx @@ -2,7 +2,7 @@ import { Check, Close, Save } from '@mui/icons-material'; import { Button } from '@mui/material'; import { Jodit } from 'jodit-react'; import { pick } from 'lodash'; -import { useCallback, useEffect, useState } from 'react'; +import { FormEvent, useCallback, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useGetArchiveQuery, useUpdateArchiveMutation } from '../../../graphql/APIConnector'; import { useSimplifiedQueryResponseData } from '../../../graphql/queryUtils'; @@ -26,6 +26,7 @@ interface ArchiveForm { name: string; shortDescription: string; longDescription: string; + email: string | null; paypalClient: string; paypalDonationText: string; paypalPurpose: string; @@ -58,7 +59,7 @@ const ArchiveEditView = ({ archiveId }: ArchiveEditViewProps) => { const archive: FlatArchiveTag | undefined = useSimplifiedQueryResponseData(data)?.archiveTag; const [updateArchive, updateMutationResponse] = useUpdateArchiveMutation({ - refetchQueries: ['getArchive'], + refetchQueries: ['getArchive', 'getArchiveNames'], awaitRefetchQueries: true, }); const { createLink, updateLink, deleteLink } = useLinks(archiveId); @@ -67,6 +68,7 @@ const ArchiveEditView = ({ archiveId }: ArchiveEditViewProps) => { name: '', shortDescription: '', longDescription: '', + email: null, paypalClient: '', paypalDonationText: '', paypalPurpose: '', @@ -80,6 +82,7 @@ const ArchiveEditView = ({ archiveId }: ArchiveEditViewProps) => { name: archive?.name ?? '', shortDescription: archive?.shortDescription ?? '', longDescription: archive?.longDescription ?? '', + email: archive?.email ?? null, paypalClient: archive?.paypalClient ?? '', paypalDonationText: archive?.paypalDonationText ?? '', paypalPurpose: archive?.paypalPurpose ?? '', @@ -139,7 +142,8 @@ const ArchiveEditView = ({ archiveId }: ArchiveEditViewProps) => { }); }; - const handleSubmit = () => { + const handleSubmit = (event: FormEvent) => { + event.preventDefault(); if (form.invalid) return; handleLinks(); if (form.logo) { @@ -152,6 +156,7 @@ const ArchiveEditView = ({ archiveId }: ArchiveEditViewProps) => { 'name', 'shortDescription', 'longDescription', + 'email', 'paypalClient', 'paypalDonationText', 'paypalPurpose', @@ -170,6 +175,7 @@ const ArchiveEditView = ({ archiveId }: ArchiveEditViewProps) => { 'name', 'shortDescription', 'longDescription', + 'email', 'paypalClient', 'paypalDonationText', 'paypalPurpose', @@ -204,8 +210,9 @@ const ArchiveEditView = ({ archiveId }: ArchiveEditViewProps) => {