|
1 | 1 | import { Grid } from '@mui/material'; |
2 | | -import { GuestDefinition } from 'shared'; |
| 2 | +import { GuestDefinition, GuestDefinitionType } from 'shared'; |
3 | 3 | import PageLayout from '../../components/PageLayout'; |
4 | 4 | import ProjectManagementCard from './ProjectManagementCard'; |
| 5 | +import { useAllGuestDefinitions } from '../../hooks/recruitment.hooks'; |
| 6 | +import LoadingIndicator from '../../components/LoadingIndicator'; |
| 7 | +import ErrorPage from '../ErrorPage'; |
5 | 8 |
|
6 | 9 | const ProjectManagementPage: React.FC = () => { |
7 | 10 | // replace when hook is ready |
8 | | - const definitions: GuestDefinition[] = [ |
9 | | - { |
10 | | - definitionId: '1', |
11 | | - term: 'NER', |
12 | | - description: 'A really awesome organization!', |
13 | | - order: 1, |
14 | | - buttonText: 'learn more!', |
15 | | - buttonLink: '/home' |
16 | | - }, |
17 | | - { |
18 | | - definitionId: '2', |
19 | | - term: 'NER2', |
20 | | - description: 'A really awesome organization2!', |
21 | | - order: 0, |
22 | | - buttonText: 'learn more2!', |
23 | | - buttonLink: '/home' |
24 | | - } |
25 | | - ]; |
| 11 | + const { data: definitions, isLoading, isError, error } = useAllGuestDefinitions(); |
| 12 | + |
| 13 | + if (isError) { |
| 14 | + return <ErrorPage message={error.message} />; |
| 15 | + } |
| 16 | + if (isLoading || !definitions) return <LoadingIndicator />; |
| 17 | + |
| 18 | + const filteredDefinitions = definitions.filter((definition) => definition.type === GuestDefinitionType.PROJECT_MANAGEMENT); |
26 | 19 |
|
27 | 20 | return ( |
28 | 21 | <PageLayout title="Project Management"> |
29 | 22 | <Grid container spacing={2} sx={{ mt: 1 }}> |
30 | | - {definitions |
| 23 | + {filteredDefinitions |
31 | 24 | .sort((a, b) => a.order - b.order) |
32 | 25 | .map((definition) => ( |
33 | 26 | <Grid item xs={12} sm={6} md={4} key={definition.definitionId} sx={{ display: 'flex' }}> |
|
0 commit comments