-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Ajout du nom et du departement de l acheteur
- Loading branch information
1 parent
049f319
commit cf617d7
Showing
10 changed files
with
236 additions
and
81 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
17 changes: 17 additions & 0 deletions
17
src/client/src/components/DataSheets/NotFound/NotFound.jsx
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,17 @@ | ||
import "./notFound.scss"; | ||
|
||
import React from "react"; | ||
|
||
const NotFound = () => { | ||
return ( | ||
<section className="data-sheet container is-fluid"> | ||
<div className=""> | ||
<div className="notFound"> | ||
<div>0 entreprise correspond à votre requête</div> | ||
</div> | ||
</div> | ||
</section> | ||
); | ||
}; | ||
|
||
export default NotFound; |
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,7 @@ | ||
.notFound { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
font-size: 22px; | ||
font-weight: bold; | ||
} |
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
82 changes: 75 additions & 7 deletions
82
...lient/src/components/DataSheets/Sections/Establishment/MarchesPublic/marchesPublic.gql.js
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 |
---|---|---|
@@ -1,25 +1,93 @@ | ||
import { gql, useQuery } from "@apollo/client"; | ||
import { gql, useApolloClient, useQuery } from "@apollo/client"; | ||
import { useEffect, useState } from "react"; | ||
|
||
import { BCE_CLIENT } from "../../../../../services/GraphQL/GraphQL"; | ||
|
||
const marchesPublicQuery = gql` | ||
query getMarchesPublic($siret: String!) { | ||
marches: fce_marches_valides(where: { siret: { _eq: $siret } }) { | ||
marches: fce_marches_valides( | ||
where: { siret: { _eq: $siret } } | ||
order_by: { dateNotification: desc } | ||
) { | ||
acheteur_id | ||
codeCPV | ||
cpv_libelle | ||
dateNotification | ||
dureeMois | ||
montant | ||
objet | ||
procedure | ||
sousTraitanceDeclaree | ||
} | ||
} | ||
`; | ||
|
||
export const useMarchesPublic = (siret) => | ||
useQuery(marchesPublicQuery, { | ||
const etablissementQuery = gql` | ||
query getEtablissement($acheteurId: String!) { | ||
etablissement: fce_etablissements(where: { siret: { _eq: $acheteurId } }) { | ||
siret | ||
etb_raisonsociale | ||
codepostaletablissement | ||
numerovoieetablissement | ||
indicerepetitionetablissement | ||
typevoieetablissement | ||
complementadresseetablissement | ||
libellevoieetablissement | ||
libellecommuneetablissement | ||
codecommune2etablissement | ||
codecommuneetablissement | ||
libellepaysetrangeretablissement | ||
} | ||
} | ||
`; | ||
|
||
export const useMarchesPublicWithEtablissements = (siret) => { | ||
const client = useApolloClient(); // Accéder à l'instance du client Apollo | ||
const { | ||
data: marcheData, | ||
loading: marcheLoading, | ||
error: marcheError, | ||
} = useQuery(marchesPublicQuery, { | ||
context: { clientName: BCE_CLIENT }, | ||
variables: { siret }, | ||
}); | ||
|
||
const [enrichedMarches, setEnrichedMarches] = useState([]); | ||
const [loading, setLoading] = useState(true); | ||
const [error, setError] = useState(null); | ||
|
||
useEffect(() => { | ||
if (marcheData && marcheData.marches.length > 0) { | ||
const fetchEtablissements = async () => { | ||
try { | ||
setLoading(true); | ||
const results = await Promise.all( | ||
marcheData.marches.map(async (marche) => { | ||
const { data: etablissementData } = await client.query({ | ||
context: { clientName: BCE_CLIENT }, | ||
query: etablissementQuery, | ||
variables: { acheteurId: marche.acheteur_id }, | ||
}); | ||
return { | ||
...marche, | ||
etablissement: etablissementData.etablissement[0], | ||
}; | ||
}) | ||
); | ||
setEnrichedMarches(results); | ||
setLoading(false); | ||
} catch (e) { | ||
setError(e); | ||
setLoading(false); | ||
} | ||
}; | ||
|
||
fetchEtablissements(); | ||
} else { | ||
setLoading(false); | ||
} | ||
}, [marcheData, client]); // Ajoutez 'client' comme dépendance | ||
|
||
return { | ||
enrichedMarches, | ||
error: marcheError || error, | ||
loading: marcheLoading || loading, | ||
}; | ||
}; |
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
Oops, something went wrong.