Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove resources page summary #195

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/App/redirects/AlertDetailsRedirect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {
generatePath,
useNavigate,
useParams,
} from 'react-router-dom';

import routes from '#routes';

interface AlertDetailsParams {
alertId: string | undefined;
[key: string]: string | undefined;
barshathakuri marked this conversation as resolved.
Show resolved Hide resolved
}

// eslint-disable-next-line import/prefer-default-export
export function Component() {
const { alertId } = useParams<AlertDetailsParams>();
const navigate = useNavigate();

const alertDetailsLink = (alertId) ? ({
pathname: (generatePath(
routes.alertDetails.absolutePath,
{ alertId },
)),
})
: routes.pageNotFound.path;

if (alertDetailsLink) {
navigate(alertDetailsLink);
}

return null;
}

Component.displayName = 'AlertDetailsRedirect';
32 changes: 32 additions & 0 deletions src/App/redirects/UnsubscribeRedirect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {
generatePath,
useNavigate,
useParams,
} from 'react-router-dom';

import routes from '#routes';

interface UnsubscribeParams {
subscriptionId: string | undefined;
token: string | undefined;
[key: string]: string | undefined;
barshathakuri marked this conversation as resolved.
Show resolved Hide resolved
}

// eslint-disable-next-line import/prefer-default-export
export function Component() {
const { subscriptionId, token } = useParams<UnsubscribeParams>();
const navigate = useNavigate();

const UnsubscribeLink = (subscriptionId && token) ? ({
pathname: (generatePath(routes.unsubscribe.absolutePath, { subscriptionId, token })),
})
: routes.pageNotFound.path;

if (UnsubscribeLink) {
navigate(UnsubscribeLink);
}

return null;
}

Component.displayName = 'UnsubscribeRedirect';
46 changes: 46 additions & 0 deletions src/App/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,20 @@ const alertDetails = customWrapRoute({
},
});

const alertDetailRedirect = customWrapRoute({
parent: rootLayout,
path: 'permalink/alert-detail/:alertId',
component: {
render: () => import('../redirects/AlertDetailsRedirect.tsx'),
props: {},
},
wrapperComponent: Auth,
context: {
title: 'Alert Details',
visibility: 'anything',
},
});

const allSourcesFeeds = customWrapRoute({
parent: rootLayout,
path: 'feeds',
Expand Down Expand Up @@ -311,6 +325,7 @@ const resetPasswordRedirect = customWrapRoute({
visibility: 'is-not-authenticated',
},
});

const activation = customWrapRoute({
parent: rootLayout,
path: 'activation/:userId/:token',
Expand Down Expand Up @@ -339,6 +354,34 @@ const activationRedirect = customWrapRoute({
},
});

const unsubscribe = customWrapRoute({
parent: rootLayout,
path: 'unsubscribe/:subscriptionId/:token',
component: {
render: () => import('#views/Unsubscribe/index.tsx'),
props: {},
},
wrapperComponent: Auth,
context: {
title: 'Unsubscribe',
visibility: 'is-authenticated',
},
});

const unsubscribeRedirect = customWrapRoute({
parent: rootLayout,
path: 'permalink/unsubscribe-user-alert-subscription/:subscriptionId/:token',
component: {
render: () => import('../redirects/UnsubscribeRedirect.tsx'),
props: {},
},
wrapperComponent: Auth,
context: {
title: 'Unsubscribe Redirect',
visibility: 'anything',
},
});

const wrappedRoutes = {
rootLayout,
homeLayout,
Expand All @@ -363,6 +406,9 @@ const wrappedRoutes = {
resetPasswordRedirect,
activationRedirect,
activation,
alertDetailRedirect,
unsubscribeRedirect,
unsubscribe,
};

export const unwrappedRoutes = unwrapRoute(Object.values(wrappedRoutes));
Expand Down
9 changes: 4 additions & 5 deletions src/views/Activation/i18n.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"namespace": "activation",
"strings": {
"activationSuccessMessage":"Your account has been successfully activated!",
"goToLogin":"Go to Login",
"activationFailMessage":"An error occurred during activation. Please try again."
"activationSuccessMessage": "Your account has been successfully activated!",
"goToLogin": "Go to Login",
"activationFailMessage": "This account has already been activated."
}
}

}
5 changes: 3 additions & 2 deletions src/views/Home/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"addSubscriptionDescription": "With real-time monitoring of potential risks and emergency events, receive timely and accurate alerts.",
"useApi": "Use API to rebroadcast CAP alerts",
"useApiDescription": "With simple yet powerful API endpoints, you can tailor the alerts to suit your users' needs.",
"alertNewSubscription": "Subscribe Alerts ",
"alertApiReference": "API Reference"
"alertNewSubscription": "Subscribe to Alerts",
"alertApiReference": "API Reference",
"redirectToLogin": "Please log in to subscribe."
}
}
25 changes: 23 additions & 2 deletions src/views/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import {
useMemo,
useState,
} from 'react';
import { Outlet } from 'react-router-dom';
import {
Outlet,
useNavigate,
} from 'react-router-dom';
import {
Button,
Container,
Expand All @@ -27,6 +30,8 @@ import {
AlertFilter,
CountryDetailQuery,
} from '#generated/types/graphql';
import useAuth from '#hooks/domain/useAuth';
import useAlert from '#hooks/useAlert';
import useUrlSearchState from '#hooks/useUrlSearchState';
import NewSubscriptionModal from '#views/NewSubscriptionModal';

Expand Down Expand Up @@ -86,6 +91,9 @@ const filterKeys: CombinedAlertFilterKey[] = ['country', 'admin1', 'region', 'ur
// eslint-disable-next-line import/prefer-default-export
export function Component() {
const strings = useTranslation(i18n);
const { isAuthenticated } = useAuth();
const alert = useAlert();
const navigate = useNavigate();

const [
filters,
Expand Down Expand Up @@ -240,6 +248,11 @@ export function Component() {
setFalse: setShowSubscriptionModalFalse,
}] = useBooleanState(false);

const handleLoginRedirect = () => {
alert.show(strings.redirectToLogin);
navigate('/login');
};

return (
<AlertDataContext.Provider value={alertContextValue}>
<Page
Expand All @@ -266,10 +279,18 @@ export function Component() {
heading={strings.addSubscription}
headerDescription={strings.addSubscriptionDescription}
withInternalPadding
footerContent={(
footerContent={isAuthenticated ? (
<Button
name={undefined}
onClick={setShowSubscriptionModalTrue}
variant="primary"
>
{strings.alertNewSubscription}
</Button>
) : (
<Button
name={undefined}
onClick={handleLoginRedirect}
variant="primary"
>
{strings.alertNewSubscription}
Expand Down
2 changes: 1 addition & 1 deletion src/views/RecoverAccount/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ export function Component() {
title={strings.successfulMessage}
/>
</Page>

);
}

Expand Down Expand Up @@ -183,6 +182,7 @@ export function Component() {
name="captcha"
onChange={setFieldValue}
onError={onCaptchaError}
error={fieldError?.captcha}
/>
<Button
name={undefined}
Expand Down
1 change: 1 addition & 0 deletions src/views/RecoverAccountConfirm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ export function Component() {
name="captcha"
onChange={setFieldValue}
onError={onCaptchaError}
error={fieldError?.captcha}
/>
<Button
name={undefined}
Expand Down
11 changes: 10 additions & 1 deletion src/views/Register/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import {
} from '@ifrc-go/ui';
import { useTranslation } from '@ifrc-go/ui/hooks';
import { resolveToComponent } from '@ifrc-go/ui/utils';
import { isTruthyString } from '@togglecorp/fujs';
import {
isDefined,
isTruthyString,
} from '@togglecorp/fujs';
import {
addCondition,
createSubmitHandler,
Expand Down Expand Up @@ -151,6 +154,11 @@ export function Component() {
errors,
));
setError(formError);
const errorMessages = errors
?.map((message: { messages: string }) => message.messages)
.filter(isDefined)
.join(', ');
alert.show(errorMessages, { variant: 'danger' });
} else if (ok) {
navigate('/login');
alert.show(
Expand Down Expand Up @@ -267,6 +275,7 @@ export function Component() {
name="captcha"
onChange={setFieldValue}
onError={onCaptchaError}
error={error?.captcha}
/>
<Button
name={undefined}
Expand Down
3 changes: 1 addition & 2 deletions src/views/Resources/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function Component() {
{
id: 2,
title: strings.ifrcRelatedExternalLinksCapImplementation,
url: 'https://cap-workshop.alert-hub.org/2023/index.html',
url: 'https://cap-workshop.alert-hub.org/2024/index.html',
},
{
id: 3,
Expand All @@ -102,7 +102,6 @@ export function Component() {
mainSectionClassName={styles.resources}
title={strings.resourceAlerthubTitle}
heading={strings.resourceHeadingTitle}
description={strings.resourceHeadingDescription}
>
<Container
heading={strings.earlyWarningResourcesTitle}
Expand Down
10 changes: 10 additions & 0 deletions src/views/Unsubscribe/i18n.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"namespace": "unsubscribe",
"strings": {
"unsubscriptionFailed": "Failed to unsubscribe. Please try again later.",
"unsubscribeSuccessfully": "Subscription successfully deactivated! Redirecting to the homepage...",
"unsubscribeConfirmHeading": "Unsubscribe",
"unsubscribeConfirmMessage": "Are you sure you want to unsubscribe?",
"subscribeNotAvailable": "The subscription is unavailable! Redirecting to the homepage..."
}
}
Loading
Loading