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 Nov 12, 2024
1 parent ab4bb88 commit 8285519
Show file tree
Hide file tree
Showing 25 changed files with 987 additions and 98 deletions.
15 changes: 15 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: 'subscriptions',
component: {
render: () => import('#views/MySubscription'),
props: {},
},
context: {
title: 'My Subscriptions',
// TODO: Change visibility after login feature
visibility: 'anything',
},
});

const homeIndex = customWrapRoute({
parent: homeLayout,
index: true,
Expand Down Expand Up @@ -218,6 +232,7 @@ const wrappedRoutes = {
pageNotFound,
login,
recoverAccount,
mySubscription,
};

export const unwrappedRoutes = unwrapRoute(Object.values(wrappedRoutes));
Expand Down
2 changes: 1 addition & 1 deletion src/components/Navbar/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"appAbout": "About",
"appResources": "Resources",
"headerMenuHome": "Home",
"headerMenuMySubscription": "My Subscription"
"headerMenuMySubscription": "My Subscriptions"
}
}
6 changes: 6 additions & 0 deletions src/components/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,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
76 changes: 38 additions & 38 deletions src/views/Home/AlertFilters/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,65 +55,65 @@ const categoryLabelSelector = (category: Category) => category.label;
const ALERT_ENUMS = gql`
query AlertEnums {
enums {
AlertInfoCertainty {
key
label
}
AlertInfoUrgency {
label
key
}
AlertInfoSeverity {
key
label
}
AlertInfoCategory {
key
label
}
AlertInfoCertainty {
key
label
}
AlertInfoUrgency {
label
key
}
AlertInfoSeverity {
key
label
}
AlertInfoCategory {
key
label
}
}
}`;

const ADMIN_LIST = gql`
query FilteredAdminList($filters:Admin1Filter, $pagination: OffsetPaginationInput) {
public {
id
admin1s(filters: $filters, pagination: $pagination) {
items {
id
name
countryId
alertCount
id
admin1s(filters: $filters, pagination: $pagination) {
items {
id
name
countryId
alertCount
}
}
}
}
}
}
`;

const REGION_LIST = gql`
query RegionList {
public {
id
regions {
items {
id
name
ifrcGoId
regions {
items {
id
name
ifrcGoId
}
}
}
}
}
}
`;

const ALL_COUNTRY_LIST = gql`
query AllCountryList {
public {
id
allCountries {
name
id
public {
id
allCountries {
name
id
}
}
}
}
`;

Expand Down
30 changes: 15 additions & 15 deletions src/views/Home/AlertsMap/Sidebar/CountryDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,23 @@ import styles from './styles.module.css';

const COUNTRY_DETAIL = gql`
query CountryDetail($countryId: ID!) {
public {
id
country(pk: $countryId) {
id
bbox
name
iso3
ifrcGoId
alertCount
admin1s {
public {
id
countryId
filteredAlertCount
name
}
country(pk: $countryId) {
id
bbox
name
iso3
ifrcGoId
alertCount
admin1s {
id
countryId
filteredAlertCount
name
}
}
}
}
}
`;

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"
}
}
76 changes: 65 additions & 11 deletions src/views/Home/AlertsMap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@ 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';
import { useTranslation } from '@ifrc-go/ui/hooks';
import {
useBooleanState,
useTranslation,
} from '@ifrc-go/ui/hooks';
import { resolveToString } from '@ifrc-go/ui/utils';
import {
isDefined,
Expand All @@ -28,6 +35,7 @@ import {
FilteredCountryListQueryVariables,
} from '#generated/types/graphql';
import useFilterState from '#hooks/useFilterState';
import NewSubscriptionModal from '#views/NewSubscriptionModal';

import AlertDataContext from '../AlertDataContext';
import AlertFilters from '../AlertFilters';
Expand Down Expand Up @@ -77,12 +85,21 @@ type AlertPointProperties = {
export function Component() {
const strings = useTranslation(i18n);
const alertFilters = useAlertFilters();

const [showSubscriptionModal, {
setTrue: setShowSubscriptionModalTrue,
setFalse: setShowSubscriptionModalFalse,
}] = useBooleanState(false);

const {
activeAdmin1Id,
activeCountryId,
activeAlertId,
activeCountryDetails,
activeAdmin1Details,
selectedUrgencyTypes,
selectedCertaintyTypes,
selectedSeverityTypes,
} = useContext(AlertDataContext);

// FIXME: We should remove useFilterState as we are not using any feature
Expand Down Expand Up @@ -170,6 +187,22 @@ export function Component() {
[totalAlertCount, activeCountryDetails, activeAdmin1Details, strings],
);

const defaultSubscription = useMemo(() => ({
id: '',
title: '',
urgency: selectedUrgencyTypes,
severity: selectedSeverityTypes,
certainty: selectedCertaintyTypes,
country: activeCountryId,
admin1: activeAdmin1Id,
}), [
selectedUrgencyTypes,
selectedSeverityTypes,
selectedCertaintyTypes,
activeCountryId,
activeAdmin1Id,
]);

return (
<Container
className={styles.alertsMap}
Expand All @@ -185,15 +218,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={setShowSubscriptionModalTrue}
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 +252,12 @@ export function Component() {
filters={<AlertFilters variant="map" />}
withGridViewInFilter
>
{showSubscriptionModal && (
<NewSubscriptionModal
subscription={defaultSubscription}
onCloseModal={setShowSubscriptionModalFalse}
/>
)}
<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"
}
}
Loading

0 comments on commit 8285519

Please sign in to comment.