Skip to content

Commit

Permalink
Add my subscription page
Browse files Browse the repository at this point in the history
  • Loading branch information
barshathakuri committed Oct 24, 2024
1 parent d27010d commit 29313f0
Show file tree
Hide file tree
Showing 29 changed files with 805 additions and 43 deletions.
49 changes: 49 additions & 0 deletions src/App/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ const homeLayout = customWrapRoute({
},
});

const mySubscription = customWrapRoute({
parent: rootLayout,
path: 'subscription',
component: {
render: () => import('#views/MySubscription'),
props: {},
},
context: {
title: 'My Subscription',
// TODO: Change visibility after login feature
visibility: 'anything',
},
});

const homeIndex = customWrapRoute({
parent: homeLayout,
index: true,
Expand All @@ -74,6 +88,38 @@ const homeIndex = customWrapRoute({
},
});

const historicalAlerts = customWrapRoute({
parent: homeLayout,
path: 'map' satisfies DefaultHomeChild,
component: {
render: () => import('#views/Home'),
props: {},
},
context: {
title: 'Historical Alerts',
// TODO: Change visibility after login feature
visibility: 'anything',
},
});

const myPastAlerts = customWrapRoute({
parent: homeLayout,
index: true,
component: {
eagerLoad: true,
render: Navigate,
props: {
to: 'MySubscription',
replace: true,
},
},
context: {
title: 'My Past Alerts',
// TODO: Change visibility after login feature
visibility: 'anything',
},
});

const homeMap = customWrapRoute({
parent: homeLayout,
path: 'map' satisfies DefaultHomeChild,
Expand Down Expand Up @@ -190,6 +236,9 @@ const wrappedRoutes = {
allSourcesFeeds,
about,
pageNotFound,
historicalAlerts,
mySubscription,
myPastAlerts,
};

export const unwrappedRoutes = unwrapRoute(Object.values(wrappedRoutes));
Expand Down
4 changes: 3 additions & 1 deletion src/components/Navbar/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"appAbout": "About",
"appResources": "Resources",
"headerMenuHome": "Home",
"headerMenuMySubscription": "My Subscription"
"headerMenuMySubscription": "My Subscription",
"headerMenuHistoricalAlerts": "Historical Alerts",
"headerMenuMyPastAlerts": "My Past Alerts"
}
}
6 changes: 6 additions & 0 deletions src/components/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,15 @@ function Navbar(props: Props) {
>
{strings.headerMenuHome}
</NavigationTab>
<NavigationTab
to="mySubscription"
>
{strings.headerMenuMySubscription}
</NavigationTab>
</NavigationTabList>
</PageContainer>
</nav>
);
}

export default Navbar;
1 change: 0 additions & 1 deletion src/components/Navbar/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
}

.menu-item:hover {
text-decoration: underline;
color: var(--go-ui-color-primary-red);
}

Expand Down
3 changes: 2 additions & 1 deletion src/views/Home/AlertsMap/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"ongoingAlertCountries": "Ongoing Alert Countries",
"backToAlertsLabel": "Back to Alerts",
"alertViewDetails": "View Details",
"alertInfo": "The IFRC AlertHub shows current warnings from official alerting agencies. These warnings have a start time (when the event might happen) and an end time (when it's expected to be over). The IFRC Alert Hub shows warnings that are happening right now (their start time has already passed) but aren't finished yet (their end time hasn't come yet)."
"alertInfo": "The IFRC AlertHub shows current warnings from official alerting agencies. These warnings have a start time (when the event might happen) and an end time (when it's expected to be over). The IFRC Alert Hub shows warnings that are happening right now (their start time has already passed) but aren't finished yet (their end time hasn't come yet).",
"alertNewSubscription": "New Subscription"
}
}
51 changes: 41 additions & 10 deletions src/views/Home/AlertsMap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ import {
useContext,
useEffect,
useMemo,
useState,
} from 'react';
import {
gql,
useQuery,
} from '@apollo/client';
import { ChevronRightLineIcon } from '@ifrc-go/icons';
import {
AddLineIcon,
ChevronRightLineIcon,
} from '@ifrc-go/icons';
import {
Button,
Container,
InfoPopup,
} from '@ifrc-go/ui';
Expand All @@ -29,6 +34,7 @@ import {
} from '#generated/types/graphql';
import useFilterState from '#hooks/useFilterState';

import NewSubscriptionModal from '../../NewSubscriptionModal';
import AlertDataContext from '../AlertDataContext';
import AlertFilters from '../AlertFilters';
import useAlertFilters from '../useAlertFilters';
Expand Down Expand Up @@ -77,6 +83,11 @@ type AlertPointProperties = {
export function Component() {
const strings = useTranslation(i18n);
const alertFilters = useAlertFilters();
const [isModalOpen, setModalOpen] = useState(false);

const openModal = () => setModalOpen(true);
const closeModal = () => setModalOpen(false);

const {
activeAdmin1Id,
activeCountryId,
Expand Down Expand Up @@ -185,15 +196,30 @@ export function Component() {
withHeaderBorder
childrenContainerClassName={styles.mainContent}
actions={(
<Link
className={styles.sources}
to="allSourcesFeeds"
actions={(
<ChevronRightLineIcon className={styles.icon} />
)}
>
{strings.mapViewAllSources}
</Link>
<div className={styles.links}>
<Button
className={styles.sources}
onClick={openModal}
name={undefined}
variant="tertiary"
actions={(
<AddLineIcon
className={styles.icon}
/>
)}
>
{strings.alertNewSubscription}
</Button>
<Link
className={styles.sources}
to="allSourcesFeeds"
actions={(
<ChevronRightLineIcon className={styles.icon} />
)}
>
{strings.mapViewAllSources}
</Link>
</div>
)}
overlayPending
pending={countryListLoading}
Expand All @@ -204,6 +230,11 @@ export function Component() {
filters={<AlertFilters variant="map" />}
withGridViewInFilter
>
{isModalOpen && (
<NewSubscriptionModal
onCloseModal={closeModal}
/>
)}
<Map
className={styles.alertsMap}
countriesWithAlert={countriesWithAlert}
Expand Down
25 changes: 15 additions & 10 deletions src/views/Home/AlertsMap/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,21 @@
}
}

.sources {
.links {
display: flex;
align-items: center;
text-decoration: none;
color: var(--go-ui-color-text);
font-weight: var(--go-ui-font-weight-medium);
}

.sources:hover {
text-decoration: underline;
color: var(--go-ui-color-primary-red);
gap: var(--go-ui-spacing-lg);

.sources {
display: flex;
align-items: center;
text-decoration: none;
color: var(--go-ui-color-text);
font-weight: var(--go-ui-font-weight-medium);
}

.sources:hover {
text-decoration: underline;
color: var(--go-ui-color-primary-red);
}
}
}
3 changes: 2 additions & 1 deletion src/views/Home/AlertsTable/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"alertTableAdminsTitle":"Admin1s",
"alertTableSentLabel":"Sent",
"tableViewAllSources": "View All Sources",
"alertInfo": "The IFRC AlertHub shows current warnings from official alerting agencies. These warnings have a start time (when the event might happen) and an end time (when it's expected to be over). The IFRC Alert Hub shows warnings that are happening right now (their start time has already passed) but aren't finished yet (their end time hasn't come yet)."
"alertInfo": "The IFRC AlertHub shows current warnings from official alerting agencies. These warnings have a start time (when the event might happen) and an end time (when it's expected to be over). The IFRC Alert Hub shows warnings that are happening right now (their start time has already passed) but aren't finished yet (their end time hasn't come yet).",
"alertNewSubscription": "New Subscription"
}
}
51 changes: 41 additions & 10 deletions src/views/Home/AlertsTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ import {
useContext,
useEffect,
useMemo,
useState,
} from 'react';
import {
gql,
useQuery,
} from '@apollo/client';
import { ChevronRightLineIcon } from '@ifrc-go/icons';
import {
AddLineIcon,
ChevronRightLineIcon,
} from '@ifrc-go/icons';
import {
Button,
Container,
DateOutput,
DateOutputProps,
Expand Down Expand Up @@ -40,6 +45,7 @@ import {
} from '#generated/types/graphql';
import useFilterState from '#hooks/useFilterState';
import { DATE_FORMAT } from '#utils/constants';
import NewSubscriptionModal from '#views/NewSubscriptionModal';

import AlertDataContext from '../AlertDataContext';
import AlertFilters from '../AlertFilters';
Expand Down Expand Up @@ -104,6 +110,11 @@ const DESC = 'DESC';
export function Component() {
const strings = useTranslation(i18n);

const [isModalOpen, setModalOpen] = useState(false);

const openModal = () => setModalOpen(true);
const closeModal = () => setModalOpen(false);

const alertFilters = useAlertFilters();
const {
activeCountryId,
Expand Down Expand Up @@ -286,15 +297,30 @@ export function Component() {
withHeaderBorder
withGridViewInFilter
actions={(
<Link
className={styles.sources}
to="allSourcesFeeds"
actions={(
<ChevronRightLineIcon className={styles.icon} />
)}
>
{strings.tableViewAllSources}
</Link>
<div className={styles.links}>
<Button
className={styles.sources}
onClick={openModal}
name={undefined}
variant="tertiary"
actions={(
<AddLineIcon
className={styles.icon}
/>
)}
>
{strings.alertNewSubscription}
</Button>
<Link
className={styles.sources}
to="allSourcesFeeds"
actions={(
<ChevronRightLineIcon className={styles.icon} />
)}
>
{strings.tableViewAllSources}
</Link>
</div>
)}
overlayPending
pending={alertInfoLoading}
Expand All @@ -310,6 +336,11 @@ export function Component() {
)}
filters={<AlertFilters variant="table" />}
>
{isModalOpen && (
<NewSubscriptionModal
onCloseModal={closeModal}
/>
)}
<SortContext.Provider value={sortState}>
<Table
pending={alertInfoLoading}
Expand Down
23 changes: 14 additions & 9 deletions src/views/Home/AlertsTable/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,21 @@
font-weight: var(--go-ui-font-weight-medium);
}

.sources {
.links {
display: flex;
align-items: center;
text-decoration: none;
color: var(--go-ui-color-text);
font-weight: var(--go-ui-font-weight-medium);
}
gap: var(--go-ui-spacing-lg);

.sources:hover {
text-decoration: underline;
color: var(--go-ui-color-primary-red);
.sources {
display: flex;
align-items: center;
text-decoration: none;
color: var(--go-ui-color-text);
font-weight: var(--go-ui-font-weight-medium);
}

.sources:hover {
text-decoration: underline;
color: var(--go-ui-color-primary-red);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"namespace": "SubscriptionActions",
"strings": {
"archiveSubscriptionActions": "Archive",
"deleteSubscriptionActions": "Delete",
"editSubscriptionActions": "Edit"
}
}
Loading

0 comments on commit 29313f0

Please sign in to comment.