Skip to content

Commit

Permalink
Error message fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
barshathakuri committed Dec 6, 2024
1 parent 6f08d0e commit 914634c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion src/views/MySubscriptions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand Down
26 changes: 16 additions & 10 deletions src/views/NewSubscriptionModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
FilteredAdminListQueryVariables,
UpdateSubscriptionMutation,
UpdateSubscriptionMutationVariables,
UserAlertSubscriptionEmailFrequencyEnum,
UserAlertSubscriptionInput,
} from '#generated/types/graphql';
import useAlert from '#hooks/useAlert';
Expand Down Expand Up @@ -111,6 +112,7 @@ mutation CreateUserAlertSubscription(
data: $data,
) {
ok
errors
result {
id
name
Expand Down Expand Up @@ -240,6 +242,7 @@ const formSchema: FormSchema = {
},
notifyByEmail: {
required: true,
defaultValue: false,
},
emailFrequency: {
required: !!value?.notifyByEmail,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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: () => {
Expand Down Expand Up @@ -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: () => {
Expand Down

0 comments on commit 914634c

Please sign in to comment.