|
| 1 | +import { useQuery } from '@apollo/client' |
| 2 | +import { Label, List, Loader } from '@navikt/ds-react' |
| 3 | +import moment from 'moment' |
| 4 | +import { EPVO, EPvkDokumentStatus, IPageResponse, TPvoTilbakemeldingQL } from '../../constants' |
| 5 | +import { TPvoVariables, getPvoTilbakemeldingListQuery } from '../../query/PvoTilbakemeldingQuery' |
| 6 | +import { ListLayout } from '../common/ListLayout' |
| 7 | +import PvoStatusView from './common/PvoStatusView' |
| 8 | + |
| 9 | +export const PvoSistRedigertView = () => { |
| 10 | + const { data, loading: isLoading } = useQuery< |
| 11 | + { pvoTilbakemeldinger: IPageResponse<TPvoTilbakemeldingQL> }, |
| 12 | + TPvoVariables |
| 13 | + >(getPvoTilbakemeldingListQuery, { |
| 14 | + variables: { sistRedigert: 20 }, |
| 15 | + }) |
| 16 | + |
| 17 | + return ( |
| 18 | + <div> |
| 19 | + {isLoading && ( |
| 20 | + <div className='flex w-full justify-center items-center mt-5'> |
| 21 | + <Loader size='3xlarge' className='flex justify-self-center' /> |
| 22 | + </div> |
| 23 | + )} |
| 24 | + |
| 25 | + {!isLoading && ( |
| 26 | + <div> |
| 27 | + <div className='w-full justify-center my-4'> |
| 28 | + <div className='flex justify-center content-center w-full'> |
| 29 | + <div className='flex justify-start align-middle w-full'> |
| 30 | + <Label size='medium'> |
| 31 | + {data?.pvoTilbakemeldinger.numberOfElements} PVK dokumenter |
| 32 | + </Label> |
| 33 | + </div> |
| 34 | + </div> |
| 35 | + </div> |
| 36 | + <List className='mb-2.5 flex flex-col gap-2'> |
| 37 | + {data && |
| 38 | + data.pvoTilbakemeldinger && |
| 39 | + data.pvoTilbakemeldinger.content.map((pvoTilbakemelding: TPvoTilbakemeldingQL) => ( |
| 40 | + <ListLayout |
| 41 | + key={pvoTilbakemelding.id} |
| 42 | + id={pvoTilbakemelding.id} |
| 43 | + url={`/pvkdokument/${pvoTilbakemelding.pvkDokumentId}${EPVO.tilbakemelding}/1`} |
| 44 | + documentNumber={`E${pvoTilbakemelding.etterlevelseDokumentasjonData.etterlevelseNummer}`} |
| 45 | + title={pvoTilbakemelding.etterlevelseDokumentasjonData.title} |
| 46 | + status={ |
| 47 | + <PvoStatusView |
| 48 | + status={pvoTilbakemelding.pvkDokumentStatus as EPvkDokumentStatus} |
| 49 | + /> |
| 50 | + } |
| 51 | + upperRightField='PVK dokument ble' |
| 52 | + changeStamp={`sist endret av meg: ${moment(pvoTilbakemelding.sistEndretAvMeg).format('ll')}`} |
| 53 | + /> |
| 54 | + ))} |
| 55 | + </List> |
| 56 | + </div> |
| 57 | + )} |
| 58 | + </div> |
| 59 | + ) |
| 60 | +} |
| 61 | +export default PvoSistRedigertView |
0 commit comments