-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: pouvoir accéder aux raisons de l'échec d'une validation #583
- Loading branch information
1 parent
57db739
commit ed328c4
Showing
10 changed files
with
219 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
assets/entrepot/pages/stored_data/StoredDataDetails/DeliveryDetails.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { fr } from "@codegouvfr/react-dsfr"; | ||
import Alert from "@codegouvfr/react-dsfr/Alert"; | ||
import Button from "@codegouvfr/react-dsfr/Button"; | ||
import Tabs from "@codegouvfr/react-dsfr/Tabs"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { FC, useMemo } from "react"; | ||
|
||
import { DeliveryReport } from "../../../../@types/app"; | ||
import DatastoreLayout from "../../../../components/Layout/DatastoreLayout"; | ||
import LoadingIcon from "../../../../components/Utils/LoadingIcon"; | ||
import RQKeys from "../../../../modules/entrepot/RQKeys"; | ||
import { CartesApiException } from "../../../../modules/jsonFetch"; | ||
import { routes } from "../../../../router/router"; | ||
import api from "../../../api"; | ||
import DeliveryPreviewTab from "./PreviewTab/DeliveryPreviewTab"; | ||
import ReportTab from "./ReportTab/ReportTab"; | ||
|
||
type DeliveryDetailsProps = { | ||
datastoreId: string; | ||
uploadDataId: string; | ||
}; | ||
|
||
const DeliveryDetails: FC<DeliveryDetailsProps> = ({ datastoreId, uploadDataId }) => { | ||
const datastoreQuery = useQuery({ | ||
queryKey: RQKeys.datastore(datastoreId), | ||
queryFn: ({ signal }) => api.datastore.get(datastoreId, { signal }), | ||
staleTime: 3600000, | ||
}); | ||
|
||
const reportQuery = useQuery<DeliveryReport, CartesApiException>({ | ||
queryKey: RQKeys.datastore_delivery_report(datastoreId, uploadDataId), | ||
queryFn: ({ signal }) => api.upload.getDeliveryReport(datastoreId, uploadDataId, { signal }), | ||
staleTime: 3600000, | ||
}); | ||
|
||
const datasheetName = useMemo(() => reportQuery?.data?.input_upload?.tags?.datasheet_name, [reportQuery?.data?.input_upload?.tags?.datasheet_name]); | ||
|
||
return ( | ||
<DatastoreLayout datastoreId={datastoreId} documentTitle={`Rapport de livraison ${reportQuery?.data?.input_upload?.name ?? ""}`}> | ||
<div className={fr.cx("fr-grid-row", "fr-grid-row--middle")}> | ||
{datasheetName ? ( | ||
<Button | ||
iconId="fr-icon-arrow-left-s-line" | ||
priority="tertiary no outline" | ||
linkProps={routes.datastore_datasheet_view({ datastoreId, datasheetName, activeTab: "dataset" }).link} | ||
title="Retour à la fiche de donnée" | ||
size="large" | ||
/> | ||
) : ( | ||
<Button | ||
iconId="fr-icon-arrow-left-s-line" | ||
priority="tertiary no outline" | ||
linkProps={routes.datasheet_list({ datastoreId }).link} | ||
title="Retour à mes données" | ||
size="large" | ||
/> | ||
)} | ||
<h1 className={fr.cx("fr-m-0")}> | ||
{"Rapport de livraison"} | ||
{reportQuery.isLoading && <LoadingIcon className={fr.cx("fr-ml-2v")} largeIcon={true} />} | ||
</h1> | ||
</div> | ||
|
||
<div className={fr.cx("fr-grid-row", "fr-grid-row--middle", "fr-mb-4w")}> | ||
{reportQuery.isError && <Alert severity="error" closable title={reportQuery.error.message} onClose={reportQuery.refetch} />} | ||
</div> | ||
{reportQuery?.data?.input_upload?.name && ( | ||
<div className={fr.cx("fr-grid-row", "fr-grid-row--middle", "fr-mb-4w")}> | ||
<h2>{reportQuery?.data?.input_upload?.name}</h2> | ||
</div> | ||
)} | ||
|
||
{reportQuery.data && ( | ||
<div className={fr.cx("fr-grid-row")}> | ||
<div className={fr.cx("fr-col")}> | ||
<Tabs | ||
tabs={[ | ||
{ | ||
label: "Aperçu de la donnée", | ||
content: <DeliveryPreviewTab reportData={reportQuery.data} />, | ||
}, | ||
{ | ||
label: "Rapport de génération", | ||
content: <ReportTab datastoreName={datastoreQuery.data?.name} reportQuery={reportQuery} />, | ||
}, | ||
]} | ||
/> | ||
</div> | ||
</div> | ||
)} | ||
</DatastoreLayout> | ||
); | ||
}; | ||
|
||
export default DeliveryDetails; |
42 changes: 42 additions & 0 deletions
42
assets/entrepot/pages/stored_data/StoredDataDetails/PreviewTab/DeliveryPreviewTab.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { fr } from "@codegouvfr/react-dsfr"; | ||
import Accordion from "@codegouvfr/react-dsfr/Accordion"; | ||
import { FC } from "react"; | ||
|
||
import { DeliveryReport } from "../../../../../@types/app"; | ||
import { niceBytes } from "../../../../../utils"; | ||
import ReportStatusBadge from "../ReportTab/ReportStatusBadge"; | ||
|
||
type DeliveryPreviewTabProps = { | ||
reportData: DeliveryReport; | ||
}; | ||
|
||
const DeliveryPreviewTab: FC<DeliveryPreviewTabProps> = ({ reportData }) => { | ||
const uploadData = reportData.input_upload; | ||
|
||
return ( | ||
<Accordion titleAs="h2" label="Informations générales" defaultExpanded={true}> | ||
<ul className={fr.cx("fr-raw-list")}> | ||
<li> | ||
<strong>Nom :</strong> {uploadData.name} | ||
</li> | ||
<li> | ||
<strong>Identifiant technique :</strong> {uploadData._id} | ||
</li> | ||
<li> | ||
<strong>Projection :</strong> {uploadData.srs} | ||
</li> | ||
<li> | ||
<strong>Statut :</strong> {<ReportStatusBadge status="FAILURE" />} | ||
</li> | ||
<li> | ||
<strong>Taille :</strong> {uploadData.size && niceBytes(uploadData.size.toString())} | ||
</li> | ||
<li> | ||
<strong>Type :</strong> {uploadData.type} | ||
</li> | ||
</ul> | ||
</Accordion> | ||
); | ||
}; | ||
|
||
export default DeliveryPreviewTab; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters