From 602f3e46cafb07d9ddfab234ff145fe2554b2aa7 Mon Sep 17 00:00:00 2001 From: RenauxLeaInsee <153934662+RenauxLeaInsee@users.noreply.github.com> Date: Wed, 27 Nov 2024 15:30:41 +0100 Subject: [PATCH] feat: add questioning page data (#97) --- package.json | 2 +- src/pages/QuestioningPage.tsx | 7 +- src/pages/SearchSurveyForm.tsx | 0 src/types/api.ts | 4 +- src/ui/CardtitleWithIcon.tsx | 2 +- src/ui/FilterSelect.tsx | 2 +- src/ui/Form/SelectWithOptions.tsx | 3 +- src/ui/Questioning/AddStatusDialog.tsx | 2 +- .../Questioning/QuestioningCommentsCard.tsx | 14 +- src/ui/Questioning/QuestioningInfos.tsx | 59 +- .../Questioning/SearchQuestioningTableRow.tsx | 8 +- src/ui/Search/FilterListBySelector.tsx | 3 +- src/ui/Search/SearchFilters.tsx | 2 +- src/ui/Search/SearchSurveySelect.tsx | 2 +- src/ui/SearchTextField.tsx | 18 +- src/ui/Survey/SurveyHeader.tsx | 3 +- src/ui/SurveyUnit/SurveyUnitCommentsCard.tsx | 8 + src/ui/TableComponents.tsx | 4 +- yarn.lock | 934 +++++++++++------- 19 files changed, 650 insertions(+), 427 deletions(-) delete mode 100644 src/pages/SearchSurveyForm.tsx diff --git a/package.json b/package.json index 45382f7..0dbe7a4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "platine-management", "private": true, - "version": "2.0.1", + "version": "2.1.0", "type": "module", "scripts": { "dev": "vite", diff --git a/src/pages/QuestioningPage.tsx b/src/pages/QuestioningPage.tsx index 6eaa700..e9e7e45 100644 --- a/src/pages/QuestioningPage.tsx +++ b/src/pages/QuestioningPage.tsx @@ -44,12 +44,7 @@ export const QuestioningPage = () => { ); } - const surveyUnitLabel = - questioning.surveyUnitIdentificationCode !== "" - ? questioning.surveyUnitIdentificationCode - : questioning.surveyUnitId; - - const label = `${questioning.campaignId ?? ""} ${surveyUnitLabel ?? ""}`; + const label = `Interrogation ${questioning.questioningId}`; const breadcrumbs = [ { href: "/", title: "Accueil" }, { href: "/questionings", title: "Interrogations" }, diff --git a/src/pages/SearchSurveyForm.tsx b/src/pages/SearchSurveyForm.tsx deleted file mode 100644 index e69de29..0000000 diff --git a/src/types/api.ts b/src/types/api.ts index 099cfb4..8ba5f69 100644 --- a/src/types/api.ts +++ b/src/types/api.ts @@ -832,6 +832,8 @@ export type APISchemas = { listContactIdentifiers?: Array surveyUnitId?: string surveyUnitIdentificationCode?: string + surveyUnitIdentificationName?: string + surveyUnitLabel?: string listEvents?: Array lastEvent?: string /* Format: date-time */ @@ -1586,7 +1588,7 @@ export type APIEndpoints = { } } "/api/questionings/{id}/questioning-communications": { - responses: { get: {} } + responses: { get: Array } requests: { method?: "get" urlParams: { diff --git a/src/ui/CardtitleWithIcon.tsx b/src/ui/CardtitleWithIcon.tsx index 02e80d2..01b7b1e 100644 --- a/src/ui/CardtitleWithIcon.tsx +++ b/src/ui/CardtitleWithIcon.tsx @@ -10,7 +10,7 @@ type Props = { export const CardtitleWithIcon = ({ IconComponent, title }: Props) => { return ( - + {title} diff --git a/src/ui/FilterSelect.tsx b/src/ui/FilterSelect.tsx index c2ffc2b..f99b07b 100644 --- a/src/ui/FilterSelect.tsx +++ b/src/ui/FilterSelect.tsx @@ -1,7 +1,7 @@ import FormControl from "@mui/material/FormControl"; import InputLabel from "@mui/material/InputLabel"; import MenuItem from "@mui/material/MenuItem"; -import Select from "@mui/material/Select"; +import Select from "@mui/material/Select/Select"; import ExpandMoreOutlinedIcon from "@mui/icons-material/ExpandMoreOutlined"; type Props = { diff --git a/src/ui/Form/SelectWithOptions.tsx b/src/ui/Form/SelectWithOptions.tsx index db23f33..1b015cc 100644 --- a/src/ui/Form/SelectWithOptions.tsx +++ b/src/ui/Form/SelectWithOptions.tsx @@ -1,4 +1,5 @@ -import { OutlinedInput, Select, MenuItem, SelectChangeEvent } from "@mui/material"; +import { OutlinedInput, MenuItem } from "@mui/material"; +import Select, { SelectChangeEvent } from "@mui/material/Select/Select"; type Option = string | { label: string; value: string }; diff --git a/src/ui/Questioning/AddStatusDialog.tsx b/src/ui/Questioning/AddStatusDialog.tsx index a6f661f..4ef8368 100644 --- a/src/ui/Questioning/AddStatusDialog.tsx +++ b/src/ui/Questioning/AddStatusDialog.tsx @@ -7,10 +7,10 @@ import { FormControl, InputLabel, MenuItem, - Select, } from "@mui/material"; import ExpandMoreOutlinedIcon from "@mui/icons-material/ExpandMoreOutlined"; import { collectStatus } from "../../constants/collectStatus.ts"; +import Select from "@mui/material/Select/Select"; const options = collectStatus.filter(state => ["HC", "REFUSAL", "WASTE"].includes(state.value)); diff --git a/src/ui/Questioning/QuestioningCommentsCard.tsx b/src/ui/Questioning/QuestioningCommentsCard.tsx index f8afd5f..064d69e 100644 --- a/src/ui/Questioning/QuestioningCommentsCard.tsx +++ b/src/ui/Questioning/QuestioningCommentsCard.tsx @@ -46,6 +46,10 @@ export const QuestioningCommentsCard = ({ questioning, refetch }: Props) => { "post", ); + const comments = questioning.listComments + ? questioning.listComments.sort((a, b) => b.commentDate!.localeCompare(a.commentDate!)) + : []; + const handleChangeTab = (_: SyntheticEvent, newValue: Tab) => { setCurrentTab(newValue); }; @@ -105,9 +109,7 @@ export const QuestioningCommentsCard = ({ questioning, refetch }: Props) => { ))} - {currentTab === Tab.Questioning && ( - - )} + {currentTab === Tab.Questioning && } {currentTab === Tab.SurveyUnit && } @@ -137,5 +139,9 @@ export const CommentListSU = ({ surveyUnitId }: { surveyUnitId?: string }) => { ); } - return ; + const comments = data.comments + ? data.comments.sort((a, b) => b.commentDate!.localeCompare(a.commentDate!)) + : []; + + return ; }; diff --git a/src/ui/Questioning/QuestioningInfos.tsx b/src/ui/Questioning/QuestioningInfos.tsx index 363e763..d4667e5 100644 --- a/src/ui/Questioning/QuestioningInfos.tsx +++ b/src/ui/Questioning/QuestioningInfos.tsx @@ -1,10 +1,12 @@ -import { Button, Card, Stack, Typography } from "@mui/material"; +import { Button, Card, Divider, List, ListItem, ListItemText, Stack, Typography } from "@mui/material"; import { Row } from "../Row.tsx"; import { Link } from "../Link.tsx"; import OpenInNewIcon from "@mui/icons-material/OpenInNew"; import { StatesCard } from "./StatesCard.tsx"; import { QuestioningCommentsCard } from "./QuestioningCommentsCard.tsx"; +import InfoOutlinedIcon from "@mui/icons-material/InfoOutlined"; import { APISchemas } from "../../types/api.ts"; +import { CardtitleWithIcon } from "../CardtitleWithIcon.tsx"; type Props = { questioning: APISchemas["QuestioningDetailsDto"]; @@ -12,25 +14,62 @@ type Props = { }; export const QuestioningInfos = ({ questioning, refetch }: Props) => { - const surveyUnitLabel = - questioning.surveyUnitIdentificationCode !== "" - ? questioning.surveyUnitIdentificationCode - : questioning.surveyUnitId; + const surveyUnitLabel = questioning.surveyUnitLabel ? `${questioning.surveyUnitLabel} : ` : ""; + const surveyUnitInformations = + questioning.surveyUnitLabel || questioning.surveyUnitIdentificationCode + ? `${questioning.surveyUnitIdentificationName} (${surveyUnitLabel}${questioning.surveyUnitIdentificationCode})` + : questioning.surveyUnitIdentificationName; + + const sortedConctacts = questioning.listContactIdentifiers?.sort((a, b) => a.localeCompare(b)) ?? []; return ( - - Informations - - + + + + + Répondant(s) + + } + /> + + + {questioning.listContactIdentifiers && + sortedConctacts.map(contact => ( + } + > + Voir + + } + > +
+ {`#${contact}`}} + /> + +
+
+ ))} +
Unité enquêtée - {surveyUnitLabel} + {surveyUnitInformations}