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 23, 2024
1 parent d27010d commit a71b50f
Show file tree
Hide file tree
Showing 23 changed files with 698 additions and 33 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;
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"
}
}
34 changes: 24 additions & 10 deletions src/views/Home/AlertsMap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import {
gql,
useQuery,
} from '@apollo/client';
import { ChevronRightLineIcon } from '@ifrc-go/icons';
import {
AddLineIcon,
ChevronRightLineIcon,
} from '@ifrc-go/icons';
import {
Container,
InfoPopup,
Expand Down Expand Up @@ -185,15 +188,26 @@ 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}>
<Link
className={styles.sources}
to="mySubscription"
actions={(
<AddLineIcon className={styles.icon} />
)}
>
{strings.alertNewSubscription}
</Link>
<Link
className={styles.sources}
to="allSourcesFeeds"
actions={(
<ChevronRightLineIcon className={styles.icon} />
)}
>
{strings.mapViewAllSources}
</Link>
</div>
)}
overlayPending
pending={countryListLoading}
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"
}
}
34 changes: 24 additions & 10 deletions src/views/Home/AlertsTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import {
gql,
useQuery,
} from '@apollo/client';
import { ChevronRightLineIcon } from '@ifrc-go/icons';
import {
AddLineIcon,
ChevronRightLineIcon,
} from '@ifrc-go/icons';
import {
Container,
DateOutput,
Expand Down Expand Up @@ -286,15 +289,26 @@ export function Component() {
withHeaderBorder
withGridViewInFilter
actions={(
<Link
className={styles.sources}
to="allSourcesFeeds"
actions={(
<ChevronRightLineIcon className={styles.icon} />
)}
>
{strings.tableViewAllSources}
</Link>
<div className={styles.links}>
<Link
className={styles.sources}
to="mySubscription"
actions={(
<AddLineIcon className={styles.icon} />
)}
>
{strings.alertNewSubscription}
</Link>
<Link
className={styles.sources}
to="allSourcesFeeds"
actions={(
<ChevronRightLineIcon className={styles.icon} />
)}
>
{strings.tableViewAllSources}
</Link>
</div>
)}
overlayPending
pending={alertInfoLoading}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"namespace": "SubscriptionActions",
"strings": {
"archiveSubscriptionActions": "Archive",
"deleteSubscriptionActions": "Delete",
"editSubscriptionActions": "Edit"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { MoreOptionsIcon } from '@ifrc-go/icons';
import { DropdownMenu } from '@ifrc-go/ui';
import { useTranslation } from '@ifrc-go/ui/hooks';

import DropdownMenuItem from '#components/DropdownMenuItem';

interface Props {
onSubscriptionDelete: () => void;
onSubscriptionArchive: () => void;
}

function SubscriptionActions(props: Props) {
const {
onSubscriptionDelete,
onSubscriptionArchive,
} = props;

const strings = useTranslation(i18n);

return (
<DropdownMenu
icons={<MoreOptionsIcon />}
variant="tertiary"
withoutDropdownIcon
>
<DropdownMenuItem
type="button"
name="archive"
onClick={onSubscriptionArchive}
>
{strings.archiveSubscriptionActions}
</DropdownMenuItem>
<DropdownMenuItem
type="button"
name="edit"
>
{strings.editSubscriptionActions}
</DropdownMenuItem>
<DropdownMenuItem
type="button"
name="delete"
onClick={onSubscriptionDelete}
>
{strings.deleteSubscriptionActions}
</DropdownMenuItem>
</DropdownMenu>
);
}

export default SubscriptionActions;
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Container } from '@ifrc-go/ui';

import SubscriptionActions from './SubscriptionActions';

import styles from './styles.module.css';

interface Props {
data: any;
onDelete: () => void;
onArchive: () => void;
}

function SubscriptionDetail(props: Props) {
const {
data,
onDelete,
onArchive,
} = props;

return (
<Container
className={styles.subscriptionDetail}
>
<div className={styles.subscriptionFilters}>
<div className={styles.alertName}>
{data.alertName}
</div>
<div>
(
{data.totalAlertCount}
)
<SubscriptionActions
onSubscriptionDelete={onDelete}
onSubscriptionArchive={onArchive}
/>
</div>
</div>
<div className={styles.filterApplied}>
{data.filtersApplied}
</div>
</Container>
);
}

export default SubscriptionDetail;
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.subscription-detail {
padding: var(--go-ui-spacing-lg);
background-color: var(--go-ui-color-gray-20);

.subscription-filters {
display: flex;
gap: var(--go-ui-spacing-lg);
justify-content: space-between;

.alert-name {
font-weight: bold;
}
}

.filter-applied {
display: flex;
gap: var(--go-ui-spacing-lg);
}
}
Loading

0 comments on commit a71b50f

Please sign in to comment.