From dba417df9344fd276f8c8f833afad3dabb038e43 Mon Sep 17 00:00:00 2001 From: barshathakuri Date: Wed, 11 Dec 2024 14:04:59 +0545 Subject: [PATCH] Remove resources page summary --- src/App/redirects/AlertDetailsRedirect.tsx | 34 ++++ src/App/redirects/UnsubscribeRedirect.tsx | 32 ++++ src/App/routes/index.tsx | 46 ++++++ src/views/Activation/i18n.json | 9 +- src/views/Home/i18n.json | 5 +- src/views/Home/index.tsx | 25 ++- src/views/RecoverAccount/index.tsx | 2 +- src/views/RecoverAccountConfirm/index.tsx | 1 + src/views/Register/index.tsx | 11 +- src/views/Resources/index.tsx | 3 +- src/views/Unsubscribe/i18n.json | 9 ++ src/views/Unsubscribe/index.tsx | 177 +++++++++++++++++++++ src/views/Unsubscribe/styles.module.css | 7 + 13 files changed, 348 insertions(+), 13 deletions(-) create mode 100644 src/App/redirects/AlertDetailsRedirect.tsx create mode 100644 src/App/redirects/UnsubscribeRedirect.tsx create mode 100644 src/views/Unsubscribe/i18n.json create mode 100644 src/views/Unsubscribe/index.tsx create mode 100644 src/views/Unsubscribe/styles.module.css diff --git a/src/App/redirects/AlertDetailsRedirect.tsx b/src/App/redirects/AlertDetailsRedirect.tsx new file mode 100644 index 00000000..898dcb7b --- /dev/null +++ b/src/App/redirects/AlertDetailsRedirect.tsx @@ -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; +} + +// eslint-disable-next-line import/prefer-default-export +export function Component() { + const { alertId } = useParams(); + const navigate = useNavigate(); + + const alertDetailsLink = (alertId) ? ({ + pathname: (generatePath( + routes.alertDetails.absolutePath, + { alertId }, + )), + }) + : routes.pageNotFound.path; + + if (alertDetailsLink) { + navigate(alertDetailsLink); + } + + return null; +} + +Component.displayName = 'AlertDetailsRedirect'; diff --git a/src/App/redirects/UnsubscribeRedirect.tsx b/src/App/redirects/UnsubscribeRedirect.tsx new file mode 100644 index 00000000..174ea9fb --- /dev/null +++ b/src/App/redirects/UnsubscribeRedirect.tsx @@ -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; +} + +// eslint-disable-next-line import/prefer-default-export +export function Component() { + const { subscriptionId, token } = useParams(); + 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'; diff --git a/src/App/routes/index.tsx b/src/App/routes/index.tsx index e1f22676..80b19b08 100644 --- a/src/App/routes/index.tsx +++ b/src/App/routes/index.tsx @@ -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', @@ -311,6 +325,7 @@ const resetPasswordRedirect = customWrapRoute({ visibility: 'is-not-authenticated', }, }); + const activation = customWrapRoute({ parent: rootLayout, path: 'activation/:userId/:token', @@ -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, @@ -363,6 +406,9 @@ const wrappedRoutes = { resetPasswordRedirect, activationRedirect, activation, + alertDetailRedirect, + unsubscribeRedirect, + unsubscribe, }; export const unwrappedRoutes = unwrapRoute(Object.values(wrappedRoutes)); diff --git a/src/views/Activation/i18n.json b/src/views/Activation/i18n.json index c09a861b..688ed505 100644 --- a/src/views/Activation/i18n.json +++ b/src/views/Activation/i18n.json @@ -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." } -} - +} \ No newline at end of file diff --git a/src/views/Home/i18n.json b/src/views/Home/i18n.json index 8eea42b3..88a2ec43 100644 --- a/src/views/Home/i18n.json +++ b/src/views/Home/i18n.json @@ -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." } } diff --git a/src/views/Home/index.tsx b/src/views/Home/index.tsx index 9ae2e002..202db9b3 100644 --- a/src/views/Home/index.tsx +++ b/src/views/Home/index.tsx @@ -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, @@ -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'; @@ -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, @@ -240,6 +248,11 @@ export function Component() { setFalse: setShowSubscriptionModalFalse, }] = useBooleanState(false); + const handleLoginRedirect = () => { + alert.show(strings.RedirectToLogin); + navigate('/login'); + }; + return ( + {strings.alertNewSubscription} + + ) : ( +