diff --git a/app/Root/config/routes.ts b/app/Root/config/routes.ts index 3b22f61..26397d4 100644 --- a/app/Root/config/routes.ts +++ b/app/Root/config/routes.ts @@ -33,7 +33,7 @@ const preparedness: RouteConfig = { }, { path: 'pmer', - load: () => import('#views/Preparedness/DisasterResponse'), + load: () => import('#views/Preparedness/Pmer'), visibility: 'is-anything', }, { diff --git a/app/Root/hooks/useRouting.tsx b/app/Root/hooks/useRouting.tsx new file mode 100644 index 0000000..29b67d8 --- /dev/null +++ b/app/Root/hooks/useRouting.tsx @@ -0,0 +1,37 @@ +import { + generatePath, + useNavigate, +} from 'react-router'; + +import routes from '#root/config/routes'; + +export type RoutesMap = typeof routes; + +type ExtractPath = T extends { path: infer P } + ? (P extends string ? P : '') + : ''; + +type PathParams

= P extends `${string}:${string}` + ? [params: Record] + : [params?: Record | undefined]; + +function useRouting() { + const navigate = useNavigate(); + + return ( + route: K, + ...args: PathParams> + ) => { + 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; diff --git a/app/views/CapacityAndResources/index.tsx b/app/views/CapacityAndResources/index.tsx index 9a5eca0..64c5a78 100644 --- a/app/views/CapacityAndResources/index.tsx +++ b/app/views/CapacityAndResources/index.tsx @@ -78,7 +78,9 @@ function CapacityAndResourcesList() { filters: { regions: regionId ? [regionId] : null, isActive: true, - search: filter.searchText, + title: { + iContains: filter.searchText, + }, }, pagination: { limit, diff --git a/app/views/DataAndReport/AIsummary/index.tsx b/app/views/DataAndReport/AIsummary/index.tsx index e33ab89..0b3e3cc 100644 --- a/app/views/DataAndReport/AIsummary/index.tsx +++ b/app/views/DataAndReport/AIsummary/index.tsx @@ -1,6 +1,6 @@ import { StarLineIcon } from '@ifrc-go/icons'; import { - BlockLoading, + Container, Description, Heading, InlineView, @@ -30,16 +30,16 @@ function AIsummary(props: AISummaryProps) { > AI Summary - {loading ? ( - - ) : ( + {summary} - ) } + ); } diff --git a/app/views/DataAndReport/AIsummary/styles.module.css b/app/views/DataAndReport/AIsummary/styles.module.css index 634fa2a..9f13084 100644 --- a/app/views/DataAndReport/AIsummary/styles.module.css +++ b/app/views/DataAndReport/AIsummary/styles.module.css @@ -5,4 +5,8 @@ white-space: pre-line; color: var(--go-ui-color-white); + .summary-container { + flex-grow: 1; + min-height: 0; + } } \ No newline at end of file diff --git a/app/views/DataAndReport/ReportDetail/index.tsx b/app/views/DataAndReport/ReportDetail/index.tsx index e4fe497..4498e83 100644 --- a/app/views/DataAndReport/ReportDetail/index.tsx +++ b/app/views/DataAndReport/ReportDetail/index.tsx @@ -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 ( @@ -172,7 +174,7 @@ function ReportDetail() { /> ) } - {isDefined(aiSummary) && ( + {aiSummary && (

= { + [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 = ( - } - title="Operational Dashboards" - description="Real-time emergency alerts and early warning system monitoring across regions" - /> - - - - - - - - + + + } + title="Operational Dashboards" + description="Real-time emergency alerts and early warning system monitoring across regions" + /> + + {operationDashboards.map((res) => ( + handleViewClick(res.page)} + /> + ))} + + + ); diff --git a/app/views/OurWork/index.tsx b/app/views/OurWork/index.tsx index 7a2e301..8ff8ca0 100644 --- a/app/views/OurWork/index.tsx +++ b/app/views/OurWork/index.tsx @@ -41,6 +41,7 @@ const EXTERNAL_DASHBOARDS_QUERY = gql` page regionId showOnHome + pageDisplay url } pageInfo { diff --git a/app/views/Preparedness/Pmer/index.tsx b/app/views/Preparedness/Pmer/index.tsx new file mode 100644 index 0000000..3a9aca9 --- /dev/null +++ b/app/views/Preparedness/Pmer/index.tsx @@ -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 ( +
+ + + Under Construction + + + The PMER dashboard is currently being built. Please check back later. + +
+ ); +} + +export default Pmer; diff --git a/app/views/Preparedness/Pmer/styles.module.css b/app/views/Preparedness/Pmer/styles.module.css new file mode 100644 index 0000000..17144a0 --- /dev/null +++ b/app/views/Preparedness/Pmer/styles.module.css @@ -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; + } +} diff --git a/app/views/TeamList/Members/index.tsx b/app/views/TeamList/Members/index.tsx index 9433724..af736f7 100644 --- a/app/views/TeamList/Members/index.tsx +++ b/app/views/TeamList/Members/index.tsx @@ -133,9 +133,10 @@ function Members() { const [{ fetching, data }] = useTeamMembersQuery({ variables: { - teamId: id!, + teamId: id ?? '', filters: { search: filter.searchText, + teamId: id, }, pagination: { offset, diff --git a/backend b/backend index e85bd4e..62f92ee 160000 --- a/backend +++ b/backend @@ -1 +1 @@ -Subproject commit e85bd4e1e55c708aabce1dca3d0d8cf4dcfbd0f7 +Subproject commit 62f92ee515fb2ca80c0c3f661a092ba68c9a9f7d