Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Root/config/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const preparedness: RouteConfig = {
},
{
path: 'pmer',
load: () => import('#views/Preparedness/DisasterResponse'),
load: () => import('#views/Preparedness/Pmer'),
visibility: 'is-anything',
},
{
Expand Down
37 changes: 37 additions & 0 deletions app/Root/hooks/useRouting.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {
generatePath,
useNavigate,
} from 'react-router';

import routes from '#root/config/routes';

export type RoutesMap = typeof routes;

type ExtractPath<T> = T extends { path: infer P }
? (P extends string ? P : '')
: '';

type PathParams<P extends string> = P extends `${string}:${string}`
? [params: Record<string, string | number>]
: [params?: Record<string, string> | undefined];

function useRouting() {
const navigate = useNavigate();

return <K extends keyof RoutesMap>(
route: K,
...args: PathParams<ExtractPath<RoutesMap[K]>>
) => {
const routeConfig = routes[route] as { path?: string };
const pathTemplate = routeConfig.path ?? '';

const normalizedTemplate = pathTemplate.startsWith('/')
? pathTemplate
: `/${pathTemplate}`;

const absolutePath = generatePath(normalizedTemplate, args[0] ?? {});
navigate(absolutePath);
};
}

export default useRouting;
4 changes: 3 additions & 1 deletion app/views/CapacityAndResources/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ function CapacityAndResourcesList() {
filters: {
regions: regionId ? [regionId] : null,
isActive: true,
search: filter.searchText,
title: {
iContains: filter.searchText,
},
},
pagination: {
limit,
Expand Down
16 changes: 8 additions & 8 deletions app/views/DataAndReport/AIsummary/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { StarLineIcon } from '@ifrc-go/icons';
import {
BlockLoading,
Container,
Description,
Heading,
InlineView,
Expand Down Expand Up @@ -30,16 +30,16 @@ function AIsummary(props: AISummaryProps) {
>
<Heading level={2}>AI Summary</Heading>
</InlineView>
{loading ? (
<BlockLoading
withoutBorder
message="Generating...."
/>
) : (
<Container
className={styles.summaryContainer}
pending={loading}
pendingMessage="Generating...."
withContentOverflow
>
<Description textSize="lg">
{summary}
</Description>
) }
</Container>
</ListView>
);
}
Expand Down
4 changes: 4 additions & 0 deletions app/views/DataAndReport/AIsummary/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@
white-space: pre-line;
color: var(--go-ui-color-white);

.summary-container {
flex-grow: 1;
min-height: 0;
}
}
8 changes: 5 additions & 3 deletions app/views/DataAndReport/ReportDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ function ReportDetail() {
const aiSummary = summaryData?.reportSummaries.results
.map((summary) => summary.text)
.join('\n \n');

const publishedDate = new Date(reportData?.publishedAt);
const encodedPublishedDate = encodeDate(publishedDate);
const encodedPublishedDate = reportData?.publishedAt ? encodeDate(publishedDate) : '-';

return (
<PageContainer
Expand All @@ -109,8 +110,9 @@ function ReportDetail() {
pending={fetching}
>
<ListView
// FIXME: isDefined is not working as expected, need to check why
// eslint-disable-next-line react/jsx-props-no-spreading
{...(isDefined(aiSummary)
{...(aiSummary
? { layout: 'grid', withSidebar: true }
: { layout: 'block' })}
>
Expand Down Expand Up @@ -172,7 +174,7 @@ function ReportDetail() {
/>
) }
</ListView>
{isDefined(aiSummary) && (
{aiSummary && (
<div className={styles.details}>
<div className={styles.stickyDetails}>
<AIsummary
Expand Down
138 changes: 68 additions & 70 deletions app/views/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,46 @@ import {
import InfoCard from '#components/InfoCard';
import KeyCard from '#components/KeyCard';
import Page from '#components/Page';
import {
DashboardPage,
useExternalDashboardsQuery,
} from '#generated/types/graphql';
import type { RouteKeys } from '#root/config/routes';
import useRouting from '#root/hooks/useRouting';
import ActiveOperation from '#views/Home/ActiveOperation';

const DASHBOARD_PAGE_TO_ROUTE_KEY: Record<DashboardPage, RouteKeys> = {
[DashboardPage.CapacityResources]: 'capacityAndResources',
[DashboardPage.DisasterResponse]: 'disasterResponse',
[DashboardPage.EmergencyAlerts]: 'emergencyAlert',
[DashboardPage.EmergencyResponse]: 'emergencyResponse',
[DashboardPage.Home]: 'home',
[DashboardPage.Operations]: 'home',
[DashboardPage.ProjectMapping]: 'projectMapping',
};

function Home() {
// TODO: Fetch real data for key figures and operations
const routeTo = useRouting();

const [{ data, fetching }] = useExternalDashboardsQuery({
variables: {
filters: {
isActive: true,
showOnHome: true,
},
pagination: {
limit: 6,
},
},
});

const operationDashboards = data?.externalDashboards.results ?? [];

const handleViewClick = (page: DashboardPage) => {
const routeKey = DASHBOARD_PAGE_TO_ROUTE_KEY[page];
routeTo(routeKey);
};

const keyFigures = (
<ListView
layout="grid"
Expand Down Expand Up @@ -74,76 +110,38 @@ function Home() {
layout="block"
>
<ActiveOperation />
<InfoCard
icon={<DashboardFillIcon />}
title="Operational Dashboards"
description="Real-time emergency alerts and early warning system monitoring across regions"
/>
<ListView
layout="grid"
numPreferredGridColumns={3}
<Container
pending={fetching}
>
<KeyCard
value="Emergency Response Dashboard"
valueType="text"
info=" Real-time overview of all active emergency operations"
size="sm"
pillText="Operation"
withIconBackground
withShadow
viewButton
/>
<KeyCard
value="Emergency Response Dashboard"
valueType="text"
info=" Real-time overview of all active emergency operations"
size="sm"
pillText="Operation"
withIconBackground
withShadow
viewButton
/>
<KeyCard
value="Emergency Response Dashboard"
valueType="text"
info=" Real-time overview of all active emergency operations"
size="sm"
pillText="Operation"
withIconBackground
withShadow
viewButton
/>
<KeyCard
value="Emergency Response Dashboard"
valueType="text"
info=" Real-time overview of all active emergency operations"
size="sm"
pillText="Operation"
withIconBackground
withShadow
viewButton
/>
<KeyCard
value="Emergency Response Dashboard"
valueType="text"
info=" Real-time overview of all active emergency operations"
size="sm"
pillText="Operation"
withIconBackground
withShadow
viewButton
/>
<KeyCard
value="Emergency Response Dashboard"
valueType="text"
info=" Real-time overview of all active emergency operations"
size="sm"
pillText="Operation"
withIconBackground
withShadow
viewButton
/>
</ListView>
<ListView
layout="block"
>

<InfoCard
icon={<DashboardFillIcon />}
title="Operational Dashboards"
description="Real-time emergency alerts and early warning system monitoring across regions"
/>
<ListView
layout="grid"
numPreferredGridColumns={3}
>
{operationDashboards.map((res) => (
<KeyCard
key={res.id}
value={res.title}
valueType="text"
size="sm"
pillText={res.pageDisplay}
withIconBackground
withShadow
viewButton
onViewClick={() => handleViewClick(res.page)}
/>
))}
</ListView>
</ListView>
</Container>
</ListView>
</Page>
);
Expand Down
1 change: 1 addition & 0 deletions app/views/OurWork/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const EXTERNAL_DASHBOARDS_QUERY = gql`
page
regionId
showOnHome
pageDisplay
url
}
pageInfo {
Expand Down
23 changes: 23 additions & 0 deletions app/views/Preparedness/Pmer/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ToolsLineIcon } from '@ifrc-go/icons';
import {
Description,
Heading,
} from '@ifrc-go/ui';

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

function Pmer() {
return (
<div className={styles.pmer}>
<ToolsLineIcon className={styles.icon} />
<Heading level={3}>
Under Construction
</Heading>
<Description>
The PMER dashboard is currently being built. Please check back later.
</Description>
</div>
);
}

export default Pmer;
14 changes: 14 additions & 0 deletions app/views/Preparedness/Pmer/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.pmer {
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
gap: var(--go-ui-spacing-sm);
min-height: 60vh;
text-align: center;

.icon {
color: var(--go-ui-color-text-light);
font-size: 2.5rem;
}
}
3 changes: 2 additions & 1 deletion app/views/TeamList/Members/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ function Members() {

const [{ fetching, data }] = useTeamMembersQuery({
variables: {
teamId: id!,
teamId: id ?? '',
filters: {
search: filter.searchText,
teamId: id,
},
pagination: {
offset,
Expand Down
Loading