Skip to content

Commit

Permalink
fix ts
Browse files Browse the repository at this point in the history
  • Loading branch information
jerem1508 committed Feb 6, 2024
1 parent 4a698c4 commit f0c2f5a
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 50 deletions.
2 changes: 1 addition & 1 deletion client/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './atlas'
export * from './atlas.ts'
2 changes: 1 addition & 1 deletion client/src/components/cards/students-card/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Container, Row, Col, TagGroup, Tag, Badge } from '@dataesr/dsfr-plus';
import { Row, Col, Badge } from '@dataesr/dsfr-plus';

import './style.scss';

Expand Down
2 changes: 1 addition & 1 deletion client/src/components/filieres-cards/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useSearchParams } from "react-router-dom";
import { Container, Row, Col, TagGroup, Tag, Badge } from '@dataesr/dsfr-plus';
import { Container, Row, Col, TagGroup, Tag } from '@dataesr/dsfr-plus';

import StudentsCard from "../cards/students-card/index.tsx";

Expand Down
2 changes: 1 addition & 1 deletion client/src/components/filters/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState, useEffect } from 'react';
import { Accordion, AccordionGroup, Button, Col, Container, Modal, ModalContent, ModalTitle, Row, Tag, TagGroup, Text, Title } from '../../../../musical-octo-waddle/dist/index.js';
import { Accordion, AccordionGroup, Button, Col, Container, Modal, ModalContent, ModalTitle, Row, Tag, TagGroup, Text, Title } from '@dataesr/dsfr-plus';
import { useSearchParams } from 'react-router-dom';
import { useQuery } from '@tanstack/react-query';
import { getFiltersValues } from '../../api';
Expand Down
9 changes: 5 additions & 4 deletions client/src/components/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ type PolygonCoordinatesProps = {
type: string,
coordinates: []
}
const zoomLevel = 8;

export default function Map({
autoCenter = false,
Expand All @@ -27,7 +26,8 @@ export default function Map({

if (polygonCoordinates) {
if (polygonCoordinates?.type === 'MultiPolygon') {
polygons = polygonCoordinates.coordinates[0];
// @ts-expect-error description
polygons = polygonCoordinates.coordinates[0] || [];
} else if (polygonCoordinates?.type === 'Polygon') {
polygons = polygonCoordinates.coordinates;
}
Expand All @@ -39,12 +39,12 @@ export default function Map({
let center = [46.71109, 1.719103];
if (autoCenter) {
zoomLevel = 8;
center = calculateCenter?.geometry?.coordinates?.reverse();
center = (calculateCenter as turf.Feature<turf.Point>)?.geometry?.coordinates?.reverse();
}

return (
<MapContainer
center={center}
center={[center[0], center[1]]}
scrollWheelZoom={false}
style={{ height, width }}
zoom={zoomLevel}
Expand All @@ -56,6 +56,7 @@ export default function Map({
/>
<GeoJSON
style={{ color: 'var(--brown-caramel-sun-425-moon-901-active)' }}
// @ts-expect-error description
data={polygonCoordinates}
/>
</MapContainer>
Expand Down
8 changes: 4 additions & 4 deletions client/src/components/queries-creator/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useState } from "react";
import { Button, TextInput } from "../../../../musical-octo-waddle/dist/index.js";
// import { useState } from "react";
import { Button } from "@dataesr/dsfr-plus";

export default function QueriesCreator({ }) {
const [queries, setQueries] = useState({});
export default function QueriesCreator() {
// const [queries, setQueries] = useState({});


const addQuery = () => {
Expand Down
7 changes: 4 additions & 3 deletions client/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { ReactNode, useLayoutEffect } from 'react'
import React from 'react';
import ReactDOM from 'react-dom/client'
import Routes from './router.js'
import { BrowserRouter, Link, useLocation } from 'react-router-dom';
import { BrowserRouter, Link } from 'react-router-dom';
import { DSFRConfig } from '@dataesr/dsfr-plus';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
Expand Down Expand Up @@ -40,7 +40,8 @@ ReactDOM.createRoot(document.getElementById('root')!).render(
<BrowserRouter>
<QueryClientProvider client={queryClient}>
{/* <ScrollToTop /> */}
<DSFRConfig routerComponent={RouterLink} theme='light'>
{/* <DSFRConfig routerComponent={RouterLink} theme='light'> */}
<DSFRConfig routerComponent={RouterLink}>
<Routes />
</DSFRConfig>
<ReactQueryDevtools initialIsOpen={false} />
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/atlas/charts/EffectifByType/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
Container, Row, Col,
Text,
} from '../../../../../../musical-octo-waddle/dist/index.js';
} from '@dataesr/dsfr-plus';
import ColumnsChart from '../columns';
import './style.css';

Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/atlas/charts/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Highcharts from "highcharts";
import HighchartsReact from "highcharts-react-official";
import type { DataByYear } from '../../../types/atlas';

export default function ColumnsChart({ data, label, currentYear, noTitle }: { data: DataByYear[], label: string, currentYear: string, noTitle: boolean }) {
export default function ColumnsChart({ data, label, currentYear }: { data: DataByYear[], label: string, currentYear: string }) {
const filieresOptions = {
chart: {
type: 'column',
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/atlas/charts/map-with-polygon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function MapWithPolygon({
width = '100%',
zoomControl = true,
}: {
autoCenter: boolean,
autoCenter?: boolean,
id: string,
height?: string,
width?: string,
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/atlas/charts/sectors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type SectorData = {
y: number;
}[];

export default function SectortsChart({ data = [], isLoading = false, currentYear }: { data: SectorData, isLoading: boolean, currentYear: string }) {
export default function SectortsChart({ data = [], isLoading = false }: { data: SectorData, isLoading: boolean }) {
if (isLoading || !data || !data.length) {
return (
<div>Loader</div>
Expand Down
8 changes: 6 additions & 2 deletions client/src/pages/atlas/components/main/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export function Search() {
queryFn: () => getFiltersValues()
})

if (isLoadingFiltersValues) {
return <div>Loading...</div>
}

// Create a list of all territories (regions, departments, academies - without urban unities and cities)
const territoiresList = Object.keys(filtersValues.geo_id).map((key) => {
if (key !== 'communes' && key !== 'unites_urbaines') {
Expand Down Expand Up @@ -92,8 +96,8 @@ export function Search() {
<hr className="fr-mt-3w" />

<HomeMapCards
data={filtersValues}
isLoading={isLoadingFiltersValues}
// data={filtersValues}
// isLoading={isLoadingFiltersValues}
territoiresList={territoiresList}
/>
</Container>
Expand Down
44 changes: 20 additions & 24 deletions client/src/pages/atlas/components/main/tabs/fields/one.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import {
Title, Text,
Button, Badge
} from '@dataesr/dsfr-plus';
import Callout from "../../../../../../components/callout.tsx";
import ColumnsChart from "../../../../charts/columns.tsx";
import SectortsChart from "../../../../charts/sectors.tsx";
import GenderChart from "../../../../charts/gender.tsx";
import { DEFAULT_CURRENT_YEAR } from "../../../../../../constants.tsx";
import { DataByYear } from "../../../../../../types/atlas.ts";
import StudentsCard from "../../../../../../components/cards/students-card/index.tsx";
Expand Down Expand Up @@ -40,27 +37,27 @@ export default function OneField() {
return <div>Loading...</div>
}

const dataSectors = [
{
name: 'Secteur public',
y: dataByYear?.find((el: DataByYear) => el.annee_universitaire === currentYear)?.effectif_pu || 0,
},
{
name: 'Secteur privé',
y: dataByYear?.find((el: DataByYear) => el.annee_universitaire === currentYear)?.effectif_pr || 0,
}
];
// const dataSectors = [
// {
// name: 'Secteur public',
// y: dataByYear?.find((el: DataByYear) => el.annee_universitaire === currentYear)?.effectif_pu || 0,
// },
// {
// name: 'Secteur privé',
// y: dataByYear?.find((el: DataByYear) => el.annee_universitaire === currentYear)?.effectif_pr || 0,
// }
// ];

const dataGender = [
{
name: 'Masculin',
y: dataByYear?.find((el: DataByYear) => el.annee_universitaire === currentYear)?.effectif_masculin || 0,
},
{
name: 'Féminin',
y: dataByYear?.find((el: DataByYear) => el.annee_universitaire === currentYear)?.effectif_feminin || 0,
}
];
// const dataGender = [
// {
// name: 'Masculin',
// y: dataByYear?.find((el: DataByYear) => el.annee_universitaire === currentYear)?.effectif_masculin || 0,
// },
// {
// name: 'Féminin',
// y: dataByYear?.find((el: DataByYear) => el.annee_universitaire === currentYear)?.effectif_feminin || 0,
// }
// ];

const effectifPU = dataByYear?.find((el: DataByYear) => el.annee_universitaire === currentYear)?.effectif_pu || 0;
const effectifPR = dataByYear?.find((el: DataByYear) => el.annee_universitaire === currentYear)?.effectif_pr || 0;
Expand Down Expand Up @@ -146,7 +143,6 @@ export default function OneField() {
<ColumnsChart
data={dataByYear || []} label="effectif_total"
currentYear={currentYear}
noTitle
/>
</Col>
</Row>
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/atlas/components/main/tabs/sectors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export function Sectors() {
</Row>
</Col>
<Col>
<SectortsChart data={dataSectors || []} isLoading={isLoading} currentYear={data?.annee_universitaire || ''} />
<SectortsChart data={dataSectors || []} isLoading={isLoading} />
</Col>
</Row>
<Row className="fr-mt-5w">
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/atlas/side-menu-layout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SideMenu, Link, Container, Row, Col, SideMenuItem } from '../../../../../musical-octo-waddle/dist/index.js';
import { SideMenu, Link, Container, Row, Col, SideMenuItem } from '@dataesr/dsfr-plus';
import { Outlet, useLocation, useSearchParams, useParams } from 'react-router-dom';
import './styles.scss';

Expand Down
7 changes: 4 additions & 3 deletions client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"DOM",
"DOM.Iterable"
],
"module": "NodeNext",
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "nodenext",
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
Expand All @@ -20,7 +20,8 @@
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
"noFallthroughCasesInSwitch": true,
"noImplicitAny": false,
},
"include": [
"src"
Expand Down

0 comments on commit f0c2f5a

Please sign in to comment.