Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add aides finance #358

Merged
merged 23 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f2411bd
chore: add pgadmin
gary-van-woerkens Apr 19, 2024
8a22da1
chore: fix key
matmut7 Apr 19, 2024
b9272ad
chore: missing keys
matmut7 Apr 19, 2024
80e3ed3
chore: typo
matmut7 Apr 19, 2024
ff34a4b
chore: numeric user
matmut7 Apr 19, 2024
9e94ba8
chore: secret
matmut7 Apr 19, 2024
3ca95c6
chore: containerPort
matmut7 Apr 19, 2024
21bd901
chore: auth
matmut7 Apr 19, 2024
bb7fe49
chore: probespath
matmut7 Apr 19, 2024
7171b68
Merge branch 'master' of github.com:SocialGouv/fce
ImenOuidou May 28, 2024
ec17d8d
Merge branch 'master' of github.com:SocialGouv/fce
ImenOuidou Jun 4, 2024
877833f
Merge branch 'master' of github.com:SocialGouv/fce
ImenOuidou Jun 10, 2024
941f867
Merge branch 'master' of github.com:SocialGouv/fce
ImenOuidou Aug 1, 2024
f2183d8
Merge branch 'master' of github.com:SocialGouv/fce
ImenOuidou Aug 8, 2024
dbca97f
Merge branch 'master' of github.com:SocialGouv/fce
ImenOuidou Aug 20, 2024
7bc6b0e
Merge branch 'master' of github.com:SocialGouv/fce
ImenOuidou Aug 20, 2024
e1504d2
Merge branch 'master' of github.com:SocialGouv/fce
ImenOuidou Sep 2, 2024
36318b0
Merge branch 'master' of github.com:SocialGouv/fce
ImenOuidou Sep 19, 2024
5cf269b
Merge branch 'master' of github.com:SocialGouv/fce
ImenOuidou Oct 6, 2024
2f02eac
Merge branch 'master' of github.com:SocialGouv/fce
ImenOuidou Nov 7, 2024
6aa4d44
Merge branch 'master' of github.com:SocialGouv/fce
ImenOuidou Nov 25, 2024
9112e36
feat: add aides financiers rebrique
ImenOuidou Dec 27, 2024
b6c777e
Merge branch 'master' of github.com:SocialGouv/fce into add-aides-fin…
ImenOuidou Jan 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import PropTypes from "prop-types";
import React, { useState } from "react";

import BlocTitle from "../../SharedComponents/BlocTitle/BlocTitle.jsx";
import AidesFinancieres from "./Subcategory/AidesFinancieres.jsx";
import Apprentissage from "./Subcategory/Apprentissage";
import ContratsAides from "./Subcategory/ContratsAides";

Expand All @@ -19,6 +20,7 @@ const EstablishmentHelps = ({ siret }) => {
<div className="section-datas">
<ContratsAides siret={siret} />
<Apprentissage siret={siret} />
<AidesFinancieres siret={siret} />
</div>
)}
</section>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { gql, useQuery } from "@apollo/client";
import { pipe, prop } from "lodash/fp";

import { BCE_CLIENT } from "../../../../../../services/GraphQL/GraphQL";
import { mapQueryResult } from "../../../../../../utils/graphql/graphql";

const AidesFinancieresQuery = gql`
query GetAidesFinancieresParSiret($siretValue: String!) {
fce_ademe_aide(
where: {
siret: {
# relationship field on fce_ademe_aide
siret: { _eq: $siretValue } # the actual scalar column in fce_etablissements
}
}
) {
dateConvention
objet
Nom_de_l_attribuant
montant
nomBeneficiaire
notificationUE
siret {
# must provide nested selection since it's an object
siret # the scalar field in the fce_etablissements table
}
}
}
`;

export const useAidesFinancieresData = pipe(
(siretValue) =>
useQuery(AidesFinancieresQuery, {
context: { clientName: BCE_CLIENT },
variables: { siretValue },
}),
mapQueryResult(prop("fce_ademe_aide"))
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import PropTypes from "prop-types";
import React from "react";

import { useRenderIfSiret } from "../../../../../../helpers/hoc/renderIfSiret";
import { formatChiffre } from "../../../../../../utils/donnees-ecofi/donnees-ecofi.js";
import LoadableContent from "../../../../../shared/LoadableContent/LoadableContent";
import Value from "../../../../../shared/Value";
import NonBorderedTable from "../../../SharedComponents/NonBorderedTable";
import { useSortableData } from "../../../SharedComponents/NonBorderedTable/hooks";
import SortableButton from "../../../SharedComponents/NonBorderedTable/SortableButton.jsx";
import SeeDetailsLink from "../../../SharedComponents/SeeDetailsLink";
import Subcategory from "../../../SharedComponents/Subcategory";
import { useAidesFinancieresData } from "./AidesFinancieres.gql";

const AidesFinancieres = ({ siret }) => {
const { loading, data, error } = useAidesFinancieresData(siret);
const { items, requestSort, sortConfig } = useSortableData(data, {
direction: "descending",
key: "dateConvention",
});
const shouldNotRender = useRenderIfSiret({ siret });

if (error || loading || shouldNotRender) {
return null;
}

return (
<Subcategory subtitle="Aides financières" sourceSi="DataGouv">
<LoadableContent loading={loading} error={error}>
{items?.length > 0 && (
<div className="data-sheet--table">
<NonBorderedTable>
<thead>
<tr>
<th>
<SortableButton
sortConfig={sortConfig}
columnKey="dateConvention"
requestSort={requestSort}
label="Date de convention"
/>
</th>
<th className="th">Beneficiaire</th>
<th className="th">Objet</th>
<th>
<SortableButton
sortConfig={sortConfig}
columnKey="montant"
requestSort={requestSort}
label="Montant"
/>
</th>
</tr>
</thead>
<tbody>
{items?.map((aide) => (
<tr key={aide?.nomBeneficiaire + aide?.dateConvention}>
<td>
<Value value={aide?.dateConvention} />
</td>
<td>
<SeeDetailsLink
text={aide?.nomBeneficiaire}
link={`/establishment/${aide?.siret?.siret}/`}
className={"list"}
/>
</td>
<td>{aide?.objet}</td>
<td>{<Value value={formatChiffre(aide?.montant)} />}</td>
</tr>
))}
</tbody>
</NonBorderedTable>
</div>
)}
{items?.length === 0 && (
<div className="data-value is-centred">
{"Aucune aide financières connue"}
</div>
)}
</LoadableContent>
</Subcategory>
);
};

AidesFinancieres.propTypes = {
siret: PropTypes.string.isRequired,
};

export default AidesFinancieres;
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export const useSortableData = (items, config = null) => {
const [sortConfig, setSortConfig] = useState(config);

const sortedItems = useMemo(() => {
const sortableItems = [...items];
if (sortConfig !== null) {
const sortableItems = [...(items || [])];
if (items && sortConfig !== null) {
sortableItems.sort((a, b) => {
let aValue, bValue;

Expand Down
Loading