Skip to content

Commit

Permalink
changement de l'année courante => 2023-24
Browse files Browse the repository at this point in the history
  • Loading branch information
jerem1508 committed Dec 13, 2024
1 parent b5fe5d2 commit 4936016
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 19 deletions.
3 changes: 2 additions & 1 deletion client/src/components/filieres-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import { Badge, Container, Row, Col, Text, Title } from "@dataesr/dsfr-plus";

import ListSkeleton from "../../pages/atlas/charts/skeletons/list.tsx";
import { getNumberOfStudents } from "../../api/atlas.ts";
import { DEFAULT_CURRENT_YEAR } from "../../constants.tsx";

export default function FilieresList() {
const [searchParams] = useSearchParams();
const params = [...searchParams]
.map(([key, value]) => `${key}=${value}`)
.join("&");
const currentYear = searchParams.get("annee_universitaire") || "2022-23";
const currentYear = searchParams.get("annee_universitaire") || DEFAULT_CURRENT_YEAR;

const { data, isLoading } = useQuery({
queryKey: ["atlas/number-of-students", params],
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/atlas/charts/arrondissements-map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Template from "../../../../components/template";
import MapWithPolygonAndBubbles from "../map-with-polygon-and-bubbles";
import data from "./georef-france-commune-arrondissement-municipal@public.json";
import { MapBubbleDataProps } from "../../../../types/atlas";
import { DEFAULT_CURRENT_YEAR } from "../../../../constants";

const config = {
paris: {
Expand Down Expand Up @@ -54,7 +55,7 @@ const config = {

export default function ArrondissementsMap({ location }) {
const [searchParams] = useSearchParams();
const currentYear = searchParams.get("annee_universitaire") || "2022-23";
const currentYear = searchParams.get("annee_universitaire") || DEFAULT_CURRENT_YEAR;

const { data: dataHistoric, isLoading: isLoadingHistoric } = useQuery({
queryKey: [
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/atlas/components/atlas-map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ import FilieresList from "../../../../components/filieres-list/index.tsx";
import SubList from "../main/tabs/sub-list.tsx";

import "./styles.scss";
import { DEFAULT_CURRENT_YEAR } from "../../../../constants.tsx";

export default function AtlasMap() {
const location = useLocation();
const path = location.pathname.split("/");
const selectedTab = path[path.length - 1];
const [searchParams] = useSearchParams();
const geoId = searchParams.get("geo_id") || "";
const currentYear = searchParams.get("annee_universitaire") || "2022-23";
const currentYear = searchParams.get("annee_universitaire") || DEFAULT_CURRENT_YEAR;

const { data: dataHistoric, isLoading: isLoadingHistoric } = useQuery({
queryKey: [
Expand Down
5 changes: 3 additions & 2 deletions client/src/pages/atlas/components/home-map-cards/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type TerritoiresListProps = {
};

import { GetLevelBadgeFromId } from "../../utils/badges.tsx";
import { DEFAULT_CURRENT_YEAR } from "../../../../constants.tsx";

function getRandomElementsFromArray(
territoiresList: TerritoiresListProps[],
Expand Down Expand Up @@ -74,7 +75,7 @@ export default function HomeMapCards({
<li
className="fr-py-1w"
>
<Link href="/atlas/general?geo_id=PAYS_100&annee_universitaire=2022-23">
<Link href={`/atlas/general?geo_id=PAYS_100&annee_universitaire=${DEFAULT_CURRENT_YEAR}`}>
France
</Link>
{GetLevelBadgeFromId({ id: "PAYS_100" })}
Expand All @@ -87,7 +88,7 @@ export default function HomeMapCards({
style={{ borderBottom: "solid 1px #ddd" }}
>
<Link
href={`/atlas/general?geo_id=${territoire.id}&annee_universitaire=2022-23`}
href={`/atlas/general?geo_id=${territoire.id}&annee_universitaire=${DEFAULT_CURRENT_YEAR}`}
>
{territoire.label}
</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { useQuery } from '@tanstack/react-query';

import { Alert, Button, Modal, ModalContent, ModalTitle } from '@dataesr/dsfr-plus';
import { getFiltersValues } from '../../../../../api/atlas.ts';
import { DEFAULT_CURRENT_YEAR } from '../../../../../constants.tsx';

export default function YearsModalButton() {
const [isOpen, setIsOpen] = useState(false);
const [searchParams] = useSearchParams();
const currentYear = searchParams.get('annee_universitaire') || '2022-23';
const currentYear = searchParams.get('annee_universitaire') || DEFAULT_CURRENT_YEAR;
const geoId = searchParams.get('geo_id') || '';
const [showAlertMessage, setShowAlertMessage] = useState(false);

Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/atlas/components/main/tabs/fields/all.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import {

import FilieresGendersChart from "../../../../charts/filieres-genders.tsx";
import FilieresList from "../../../../../../components/filieres-list/index.tsx";
import { DEFAULT_CURRENT_YEAR } from "../../../../../../constants.tsx";

export default function AllFields() {
const [searchParams] = useSearchParams();
const currentYear = searchParams.get("annee_universitaire") || "2022-23";
const currentYear = searchParams.get("annee_universitaire") || DEFAULT_CURRENT_YEAR;
const params = [...searchParams]
.map(([key, value]) => `${key}=${value}`)
.join("&");
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/atlas/components/main/tabs/genders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ import {
import GenderHistoChart from "../../../charts/genders-histo.tsx";
import { DataByYear, SimilarData } from "../../../../../types/atlas.ts";
import StudentsCardWithTrend from "../../../../../components/cards/students-card-with-trend/index.tsx";
import { DEFAULT_CURRENT_YEAR } from "../../../../../constants.tsx";

export function Genders() {
const [chartView, setChartView] = useState<"basic" | "percentage">("basic");
const [chartType, setChartType] = useState<"column" | "line">("column");
const [searchParams] = useSearchParams();
const currentYear = searchParams.get("annee_universitaire") || "2022-23";
const currentYear = searchParams.get("annee_universitaire") || DEFAULT_CURRENT_YEAR;
const geoId = searchParams.get("geo_id") || "";
const params = [...searchParams]
.map(([key, value]) => `${key}=${value}`)
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/atlas/components/main/tabs/general.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ import MapSkeleton from "../../../charts/skeletons/map.tsx";
import ArrondissementsMap from "../../../charts/arrondissements-map/index.tsx";

import "./styles.scss";
import { DEFAULT_CURRENT_YEAR } from "../../../../../constants.tsx";

export function General() {
const [searchParams] = useSearchParams();
const params = [...searchParams]
.map(([key, value]) => `${key}=${value}`)
.join("&");
const currentYear = searchParams.get("annee_universitaire") || "2022-23";
const currentYear = searchParams.get("annee_universitaire") || DEFAULT_CURRENT_YEAR;
const geoId = searchParams.get("geo_id") || "";

const { data, isLoading } = useQuery({
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/atlas/components/main/tabs/search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import HomeMapCards from "../../../home-map-cards/index.js";
import { GetLevelBadgeFromItem } from "../../../../utils/badges.js";

import "./styles.scss";
import { DEFAULT_CURRENT_YEAR } from "../../../../../../constants.js";

type SearchTypes = {
geo_id: string;
Expand Down Expand Up @@ -195,7 +196,7 @@ export function Search() {
key={result.geo_id}
onClick={() => {
navigate(
`/atlas/general?geo_id=${result.geo_id}&annee_universitaire=2022-23`
`/atlas/general?geo_id=${result.geo_id}&annee_universitaire=${DEFAULT_CURRENT_YEAR}`
);
}}
>
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/atlas/components/main/tabs/sectors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ import {
} from "../../../../../api/atlas.ts";
import { DataByYear, SimilarData } from "../../../../../types/atlas.ts";
import StudentsCardWithTrend from "../../../../../components/cards/students-card-with-trend/index.tsx";
import { DEFAULT_CURRENT_YEAR } from "../../../../../constants.tsx";

export function Sectors() {
const [chartView, setChartView] = useState<"basic" | "percentage">("basic");
const [chartType, setChartType] = useState<"column" | "line">("column");
const [searchParams] = useSearchParams();
const currentYear = searchParams.get("annee_universitaire") || "2022-23";
const currentYear = searchParams.get("annee_universitaire") || DEFAULT_CURRENT_YEAR;
const geoId = searchParams.get("geo_id") || "";
const params = [...searchParams]
.map(([key, value]) => `${key}=${value}`)
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/atlas/components/main/tabs/sub-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { useQuery } from "@tanstack/react-query";

import Template from "../../../../../components/template/index.tsx";
import { getNumberOfStudentsHistoricByLevel } from "../../../../../api/index.ts";
import { DEFAULT_CURRENT_YEAR } from "../../../../../constants.tsx";

export default function SubList() {
const [searchParams] = useSearchParams();
const navigate = useNavigate();
const geoId = searchParams.get("geo_id") || "";
const currentYear = searchParams.get("annee_universitaire") || "2022-23";
const currentYear = searchParams.get("annee_universitaire") || DEFAULT_CURRENT_YEAR;

const { data: dataHistoric, isLoading: isLoadingHistoric } = useQuery({
queryKey: [
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/atlas/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ import { AtlasSideMenu } from "./side-menu-layout/index.tsx";
import { GetLevelBadgeFromId } from "./utils/badges.tsx";

import "./styles.scss";
import { DEFAULT_CURRENT_YEAR } from "../../constants.tsx";

export default function AtlasHeader() {
const [searchParams] = useSearchParams();
const geoId = searchParams.get("geo_id") || "";
const currentYear = searchParams.get("annee_universitaire") || "2022-23";
const currentYear = searchParams.get("annee_universitaire") || DEFAULT_CURRENT_YEAR;
const navigate = useNavigate();

useTitle("dataSupR - Atlas des effectifs étudiant-e-s");
Expand Down
2 changes: 1 addition & 1 deletion server/src/routes/tableaux/atlas/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"label": "Atlas des effectifs étudiants",
"description": "Description de l'atlas des effectifs étudiants",
"constants": [{ "current_year": "2022-23" }],
"constants": [{ "current_year": "2023-24" }],
"data": [
{
"key": "atlas",
Expand Down
12 changes: 7 additions & 5 deletions server/src/routes/tableaux/atlas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ const filieresOrder = [
"TOTAL",
];

const DEFAULT_CURRENT_YEAR = "2023-24";

router.route("/atlas/get-geo-ids-from-search").get((req, res) => {
if (
(!req.query.q || req.query?.q.length === 0) &&
Expand Down Expand Up @@ -413,7 +415,7 @@ router.route("/atlas/number-of-students-historic-by-level").get(async (req, res)
router.route("/atlas/number-of-students-by-gender-and-level").get(async (req, res) => {
const filters = { ...req.query };
if (!req.query.annee_universitaire) {
filters.annee_universitaire = "2022-23";
filters.annee_universitaire = DEFAULT_CURRENT_YEAR;
}
const data = await db
.collection("atlas2024")
Expand Down Expand Up @@ -480,7 +482,7 @@ router.route("/atlas/number-of-students-by-gender-and-level").get(async (req, re
router.route("/atlas/number-of-students-by-sector-and-sublevel").get(async (req, res) => {
const filters = { ...req.query };
if (!req.query.annee_universitaire) {
filters.annee_universitaire = "2022-23";
filters.annee_universitaire = DEFAULT_CURRENT_YEAR;
}
filters.regroupement = "TOTAL";

Expand Down Expand Up @@ -538,7 +540,7 @@ router.route("/atlas/number-of-students-by-sector-and-sublevel").get(async (req,
router.route("/atlas/number-of-students-by-gender-and-sublevel").get(async (req, res) => {
const filters = { ...req.query };
if (!req.query.annee_universitaire) {
filters.annee_universitaire = "2022-23";
filters.annee_universitaire = DEFAULT_CURRENT_YEAR;
}

const data = await db
Expand Down Expand Up @@ -595,7 +597,7 @@ router.route("/atlas/number-of-students-by-gender-and-sublevel").get(async (req,
router.route("/atlas/number-of-students-by-field-and-sublevel").get(async (req, res) => {
const filters = { ...req.query };
if (!req.query.annee_universitaire) {
filters.annee_universitaire = "2022-23";
filters.annee_universitaire = DEFAULT_CURRENT_YEAR;
}

const data = await db
Expand Down Expand Up @@ -642,7 +644,7 @@ router.route("/atlas/number-of-students-by-field-and-sublevel").get(async (req,
router.route("/atlas/number-of-students").get((req, res) => {
const filters = { ...req.query };
if (!req.query.annee_universitaire) {
filters.annee_universitaire = "2022-23";
filters.annee_universitaire = DEFAULT_CURRENT_YEAR;
}

if (!req.query.geo_id) {
Expand Down

0 comments on commit 4936016

Please sign in to comment.