Skip to content

Commit

Permalink
Subscription page integration
Browse files Browse the repository at this point in the history
  • Loading branch information
barshathakuri authored and AdityaKhatri committed Nov 26, 2024
1 parent 92e0c19 commit 7b4bf02
Show file tree
Hide file tree
Showing 19 changed files with 883 additions and 365 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@graphql-codegen/typescript-operations": "^4.2.0",
"@hcaptcha/react-hcaptcha": "^1.11.0",
"@ifrc-go/icons": "^1.3.3",
"@ifrc-go/ui": "^1.1.2",
"@ifrc-go/ui": "^1.2.1",
"@mapbox/mapbox-gl-draw": "^1.4.3",
"@placemarkio/geo-viewport": "^1.0.2",
"@sentry/react": "^7.81.1",
Expand Down
21 changes: 0 additions & 21 deletions src/components/Badge/index.tsx

This file was deleted.

6 changes: 0 additions & 6 deletions src/components/Badge/styles.module.css

This file was deleted.

1 change: 0 additions & 1 deletion src/views/AlertDetails/AlertInfo/AreaInfoDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ function AreaInfoDetail(props: Props) {
onChange={setSelectedFeature}
/>
)}
withGridViewInFilter
headingLevel={4}
>
<div className={styles.map}>
Expand Down
1 change: 0 additions & 1 deletion src/views/AllSourcesFeeds/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ export function Component() {
heading={strings.sourceFeedsTitle}
>
<Container
withGridViewInFilter
filters={(
<TextInput
placeholder={strings.searchSourcesPlaceholder}
Expand Down
30 changes: 7 additions & 23 deletions src/views/HistoricalAlerts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ import {
AlertEnumsAndAllCountryListQueryVariables,
AlertEnumsQuery,
AlertFilter,
AlertInformationsQuery,
AlertInformationsQueryVariables,
FilteredAdminListQuery,
FilteredAdminListQueryVariables,
HistoricalAlertInformationsQuery,
HistoricalAlertInformationsQueryVariables,
OffsetPaginationInput,
} from '#generated/types/graphql';
import useFilterState from '#hooks/useFilterState';
Expand All @@ -60,9 +60,8 @@ import styles from './styles.module.css';

// TODO: Add Historical alert query here

const ALERT_INFORMATIONS = gql`
query AlertInformations(
$order:AlertOrder,
const HISTORICAL_ALERT_INFORMATIONS = gql`
query HistoricalAlertInformations(
$pagination: OffsetPaginationInput,
$filters: AlertFilter,
) {
Expand All @@ -71,7 +70,6 @@ const ALERT_INFORMATIONS = gql`
alerts(
pagination: $pagination,
filters: $filters,
order:$order,
) {
limit
offset
Expand Down Expand Up @@ -156,7 +154,7 @@ type Severity = NonNullable<AlertEnumsQuery['enums']['AlertInfoSeverity']>[numbe
type Certainty = NonNullable<AlertEnumsQuery['enums']['AlertInfoCertainty']>[number];
type Category = NonNullable<AlertEnumsQuery['enums']['AlertInfoCategory']>[number];

type AlertType = NonNullable<NonNullable<NonNullable<AlertInformationsQuery['public']>['alerts']>['items']>[number];
type AlertType = NonNullable<NonNullable<NonNullable<HistoricalAlertInformationsQuery['public']>['alerts']>['items']>[number];
type Admin1 = AlertType['admin1s'][number];

const adminKeySelector = (admin1: AdminOption) => admin1.id;
Expand All @@ -168,8 +166,6 @@ const categoryKeySelector = (category: Category) => category.key;

const alertKeySelector = (item: AlertType) => item.id;
const PAGE_SIZE = 20;
const ASC = 'ASC';
const DESC = 'DESC';

// eslint-disable-next-line import/prefer-default-export
export function Component() {
Expand All @@ -190,21 +186,11 @@ export function Component() {
filter: {},
});

const order = useMemo(() => {
if (isNotDefined(sortState.sorting)) {
return undefined;
}
return {
[sortState.sorting.name]: sortState.sorting.direction === 'asc' ? ASC : DESC,
};
}, [sortState.sorting]);

const variables = useMemo<{ filters: AlertFilter, pagination: OffsetPaginationInput }>(() => ({
pagination: {
offset,
limit,
},
order,
filters: {
urgency: filter.urgency,
severity: filter.severity,
Expand All @@ -221,7 +207,6 @@ export function Component() {
} : undefined,
},
}), [
order,
limit,
offset,
filter,
Expand All @@ -232,8 +217,8 @@ export function Component() {
previousData,
data: alertInfosResponse = previousData,
error: alertInfoError,
} = useQuery<AlertInformationsQuery, AlertInformationsQueryVariables>(
ALERT_INFORMATIONS,
} = useQuery<HistoricalAlertInformationsQuery, HistoricalAlertInformationsQueryVariables>(
HISTORICAL_ALERT_INFORMATIONS,
{
skip: isNotDefined(variables),
variables,
Expand Down Expand Up @@ -374,7 +359,6 @@ export function Component() {
className={styles.alertsTable}
heading={heading}
withHeaderBorder
withGridViewInFilter
actions={(
<Link
className={styles.sources}
Expand Down
14 changes: 5 additions & 9 deletions src/views/Home/AlertsMap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,11 @@ export function Component() {
);

const defaultSubscription = useMemo(() => ({
name: '',
alertFilters: {
urgency: selectedUrgencyTypes,
severity: selectedSeverityTypes,
certainty: selectedCertaintyTypes,
country: activeCountryId ?? '',
admin1s: activeAdmin1Id ? [activeAdmin1Id] : [],
},
filterAlertUrgencies: selectedUrgencyTypes,
filterAlertCertainties: selectedCertaintyTypes,
filterAlertSeverities: selectedSeverityTypes,
filterAlertCountry: activeCountryId || '',
filterAlertAdmin1s: activeAdmin1Id ? [activeAdmin1Id] : [],
}), [
selectedUrgencyTypes,
selectedSeverityTypes,
Expand Down Expand Up @@ -251,7 +248,6 @@ export function Component() {
contentViewType="grid"
numPreferredGridContentColumns={3}
filters={<AlertFilters variant="map" />}
withGridViewInFilter
>
{showSubscriptionModal && (
<NewSubscriptionModal
Expand Down
16 changes: 8 additions & 8 deletions src/views/Home/AlertsTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,20 +288,21 @@ export function Component() {
);

const defaultSubscription = useMemo(() => ({
id: '',
name: '',
alertFilters: {
urgency: selectedUrgencyTypes,
severity: selectedSeverityTypes,
certainty: selectedCertaintyTypes,
country: activeCountryId ?? '',
admin1s: activeAdmin1Id ? [activeAdmin1Id] : [],
},
filterAlertUrgencies: selectedUrgencyTypes,
filterAlertCertainties: selectedCertaintyTypes,
filterAlertSeverities: selectedSeverityTypes,
filterAlertCategories: selectedCategoryTypes,
filterAlertCountry: activeCountryId || '',
filterAlertAdmin1s: activeAdmin1Id ? [activeAdmin1Id] : [],
}), [
selectedUrgencyTypes,
selectedSeverityTypes,
selectedCertaintyTypes,
activeCountryId,
activeAdmin1Id,
selectedCategoryTypes,
]);

return (
Expand All @@ -317,7 +318,6 @@ export function Component() {
</div>
)}
withHeaderBorder
withGridViewInFilter
actions={(
<div className={styles.links}>
<Button
Expand Down
19 changes: 16 additions & 3 deletions src/views/MySubscription/ActiveTableActions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@ import DropdownMenuItem from '#components/DropdownMenuItem';

import i18n from './i18n.json';

function ActiveTableActions() {
interface Props {
onSubscriptionRemove?: () => void;
onArchiveClick?: () => void;
onEditClick: () => void;
}

function ActiveTableActions(props: Props) {
const {
onSubscriptionRemove,
onArchiveClick,
onEditClick,
} = props;

const strings = useTranslation(i18n);

return (
Expand All @@ -23,22 +35,23 @@ function ActiveTableActions() {
<DropdownMenuItem
type="button"
name="archive"
onClick={undefined}
onClick={onArchiveClick}
icons={<LayoutBottomLineIcon />}
>
{strings.archiveSubscriptionActions}
</DropdownMenuItem>
<DropdownMenuItem
type="button"
name="edit"
onClick={onEditClick}
icons={<EditTwoLineIcon />}
>
{strings.editSubscriptionActions}
</DropdownMenuItem>
<DropdownMenuItem
type="button"
name="delete"
onClick={undefined}
onClick={onSubscriptionRemove}
icons={<DeleteBinSixLineIcon />}
>
{strings.deleteSubscriptionActions}
Expand Down
15 changes: 13 additions & 2 deletions src/views/MySubscription/ArchiveTableActions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ import DropdownMenuItem from '#components/DropdownMenuItem';

import i18n from './i18n.json';

function ArchiveTableActions() {
interface Props {
onSubscriptionRemove?: () => void;
onUnArchive?: () => void;
}

function ArchiveTableActions(props: Props) {
const {
onSubscriptionRemove,
onUnArchive,
} = props;

const strings = useTranslation(i18n);

return (
Expand All @@ -22,14 +32,15 @@ function ArchiveTableActions() {
<DropdownMenuItem
type="button"
name="unArchive"
onClick={onUnArchive}
icons={<LayoutBottomLineIcon />}
>
{strings.unarchiveSubscriptionActions}
</DropdownMenuItem>
<DropdownMenuItem
type="button"
name="delete"
onClick={undefined}
onClick={onSubscriptionRemove}
icons={<DeleteBinSixLineIcon />}
>
{strings.deleteSubscriptionActions}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import styles from './styles.module.css';

interface Props {
alertId: string;
alertTitle: string;
alertTitle: string | undefined;
alertDescription?: string;
}

Expand Down
Loading

0 comments on commit 7b4bf02

Please sign in to comment.