-
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.
Merge pull request #18 from dataesr/init-finance-dashboard
feat(finance): init finances folder
- Loading branch information
Showing
8 changed files
with
1,202 additions
and
0 deletions.
There are no files selected for viewing
1,014 changes: 1,014 additions & 0 deletions
1,014
client/src/pages/finance-university/components/filters/filters-config.json
Large diffs are not rendered by default.
Oops, something went wrong.
78 changes: 78 additions & 0 deletions
78
client/src/pages/finance-university/components/filters/index.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,78 @@ | ||
import { Button, Modal, ModalContent, ModalTitle } from '@dataesr/dsfr-plus'; | ||
import { useState } from 'react'; | ||
import { useSearchParams } from 'react-router-dom'; | ||
|
||
import filtersConfig from './filters-config.json'; | ||
|
||
type ItemProps = { | ||
uai: string, | ||
idPaysage: string, | ||
libelle: string, | ||
}[] | ||
|
||
export default function Filters() { | ||
const [filterId, setFilterId] = useState(''); | ||
const [isOpen, setIsOpen] = useState(false); | ||
const [searchParams, setSearchParams] = useSearchParams(); | ||
const [title, setTitle] = useState(); | ||
const [values, setValues] = useState<ItemProps>([]); | ||
|
||
const openModal = (key: string) => { | ||
setTitle(filtersConfig[key].title); | ||
setValues(filtersConfig[key].values); | ||
setFilterId(key); | ||
setIsOpen(true); | ||
} | ||
|
||
const selectItem = (item: { id: string }) => { | ||
setSearchParams({ [filterId]: item.id }); | ||
setIsOpen(false); | ||
}; | ||
|
||
return ( | ||
<> | ||
{ | ||
[...searchParams].map((param) => { | ||
const [key, value] = param; | ||
const filter = filtersConfig[key]; | ||
if (!filter) return null; | ||
return ( | ||
<Button | ||
className="fr-mr-1w" | ||
color='purple-glycine' | ||
icon={filter.icon} | ||
key={key} | ||
onClick={() => openModal(key)} | ||
size='sm' | ||
> | ||
{`${filter.label} : ${filter.values.find((item) => item.uai === value)?.libelle ?? 'inconnu'}`} | ||
</Button> | ||
); | ||
}) | ||
} | ||
|
||
<Modal isOpen={isOpen} hide={() => setIsOpen(false)} size="lg"> | ||
<ModalTitle>{title}</ModalTitle> | ||
<ModalContent> | ||
<select | ||
className="fr-select" | ||
id="select" | ||
name="select" | ||
onChange={(e) => selectItem({ id: e.target.value })} | ||
> | ||
{ | ||
values.map((value) => ( | ||
<option | ||
key={value.uai} | ||
value={value.uai} | ||
> | ||
{value.libelle} | ||
</option> | ||
)) | ||
} | ||
</select> | ||
</ModalContent> | ||
</Modal> | ||
</> | ||
); | ||
} |
48 changes: 48 additions & 0 deletions
48
client/src/pages/finance-university/components/side-menu.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,48 @@ | ||
import { SideMenu, Link, Container, Row, Col } from '@dataesr/dsfr-plus'; | ||
import { Outlet, useLocation } from 'react-router-dom'; | ||
import './styles.scss'; | ||
|
||
export default function CustomSideMenu() { | ||
const { pathname } = useLocation(); | ||
|
||
if (!pathname) return null; | ||
|
||
const is = (str: string): boolean => pathname?.startsWith(str) | ||
return ( | ||
<Container as="nav"> | ||
<Row> | ||
<Col xs={12} md={3} className="fr-pl-2w"> | ||
<SideMenu title="" sticky fullHeight className="padded-sidemenu"> | ||
<Link | ||
current={is('/finance-universite/grands-indicateurs')} | ||
href={'/finance-universite/grands-indicateurs'} | ||
> | ||
Grands indicateurs | ||
</Link> | ||
<Link | ||
current={is('/finance-universite/recettes-propres')} | ||
href={'/finance-universite/recettes-propres'} | ||
> | ||
Recettes Propres | ||
</Link> | ||
<Link | ||
current={is('/finance-universite/masse-salariale')} | ||
href={'/finance-universite/masse-salariale'} | ||
> | ||
Masse salariale | ||
</Link> | ||
<Link | ||
current={is('/finance-universite/consommation')} | ||
href={'/finance-universite/consommation'} | ||
> | ||
Consommation | ||
</Link> | ||
</SideMenu> | ||
</Col> | ||
<Col xs={12} md={8} className="fr-pt-6w"> | ||
<Outlet /> | ||
</Col> | ||
</Row> | ||
</Container> | ||
) | ||
} |
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,9 @@ | ||
.padded-sidemenu { | ||
.fr-sidemenu__inner { | ||
padding-top: 3rem; | ||
} | ||
} | ||
|
||
.text-right { | ||
text-align: right; | ||
} |
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,28 @@ | ||
import { Container, Row, Col } from "@dataesr/dsfr-plus"; | ||
import { useSearchParams } from "react-router-dom"; | ||
import { useEffect } from "react"; | ||
import CustomSideMenu from "./components/side-menu"; | ||
import Filters from "./components/filters"; | ||
|
||
export default function Main() { | ||
const [searchParams, setSearchParams] = useSearchParams(); | ||
|
||
useEffect(() => { | ||
if (!searchParams.get('structure_code')) { | ||
setSearchParams({ structure_code: '0752744A' }); | ||
} | ||
}, [searchParams, setSearchParams]); | ||
|
||
return ( | ||
<main> | ||
<Container> | ||
<Row> | ||
<Col className="fr-ml-1w"> | ||
<Filters /> | ||
</Col> | ||
</Row> | ||
</Container> | ||
<CustomSideMenu /> | ||
</main> | ||
); | ||
} |
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,16 @@ | ||
import { Routes, Route } from 'react-router-dom'; | ||
|
||
import Main from './index.tsx'; | ||
|
||
export default function FinanceUniversityRoutes() { | ||
return ( | ||
<Routes> | ||
<Route path="/" element={<Main />}> | ||
<Route path="/grands-indicateurs" element={<div>Les grands indicateurs</div>} /> | ||
<Route path="/recettes-propres" element={<div>Les recettes propres</div>} /> | ||
<Route path="/masse-salariale" element={<div>La masse salariale</div>} /> | ||
<Route path="/consommation" element={<div>La consommation</div>} /> | ||
</Route> | ||
</Routes> | ||
); | ||
} |
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