diff --git a/README.md b/README.md index e43815c..422d95d 100644 --- a/README.md +++ b/README.md @@ -71,5 +71,8 @@ docker-compose up └── index.tsx (Defines root layout and requests fetched for DomainContext) ``` +## IFRC Alert Hub backend +The backend that serves the frontend application is maintained in a separate [repository](https://github.com/IFRCGo/alert-hub-backend). + ## External facing API Here is the documentation for [Alert Hub GraphQL Client Usage Guide](./APIDOCS.md) diff --git a/src/views/MySubscriptions/index.tsx b/src/views/MySubscriptions/index.tsx index 65ed4ea..9f0fcaa 100644 --- a/src/views/MySubscriptions/index.tsx +++ b/src/views/MySubscriptions/index.tsx @@ -209,7 +209,7 @@ export function Component() { return; } if (response.ok) { - if (response.result) { + if (response.result?.isActive === true) { alert.show( strings.subscriptionUnarchived, { variant: 'success' }, diff --git a/src/views/NewSubscriptionModal/index.tsx b/src/views/NewSubscriptionModal/index.tsx index 4203dce..4b13e7d 100644 --- a/src/views/NewSubscriptionModal/index.tsx +++ b/src/views/NewSubscriptionModal/index.tsx @@ -40,6 +40,7 @@ import { FilteredAdminListQueryVariables, UpdateSubscriptionMutation, UpdateSubscriptionMutationVariables, + UserAlertSubscriptionEmailFrequencyEnum, UserAlertSubscriptionInput, } from '#generated/types/graphql'; import useAlert from '#hooks/useAlert'; @@ -111,6 +112,7 @@ mutation CreateUserAlertSubscription( data: $data, ) { ok + errors result { id name @@ -240,6 +242,7 @@ const formSchema: FormSchema = { }, notifyByEmail: { required: true, + defaultValue: false, }, emailFrequency: { required: !!value?.notifyByEmail, @@ -277,8 +280,9 @@ function NewSubscriptionModal(props: Props) { filterAlertCountry: subscription?.filterAlertCountry, filterAlertAdmin1s: subscription?.filterAlertAdmin1s ?? [], - notifyByEmail: subscription?.notifyByEmail ?? false, - emailFrequency: subscription?.emailFrequency ?? undefined, + notifyByEmail: subscription?.notifyByEmail, + emailFrequency: subscription?.emailFrequency + ?? UserAlertSubscriptionEmailFrequencyEnum.Monthly, }), [subscription]); const { @@ -318,10 +322,11 @@ function NewSubscriptionModal(props: Props) { onSuccess(); } } else { - alert.show( - strings.newSubscriptionLimitExceeded, - { variant: 'danger' }, - ); + const errorMessages = response?.errors + ?.map((error: { messages: string; }) => error.messages) + .filter((message: string) => message) + .join(', '); + alert.show(errorMessages, { variant: 'danger' }); } }, onError: () => { @@ -353,10 +358,11 @@ function NewSubscriptionModal(props: Props) { onSuccess(); } } else { - alert.show( - strings.newSubscriptionLimitExceeded, - { variant: 'danger' }, - ); + const errorMessages = response?.errors + ?.map((error: { messages: string; }) => error.messages) + .filter((message: string) => message) + .join(', '); + alert.show(errorMessages, { variant: 'danger' }); } }, onError: () => {