Skip to content

Commit

Permalink
feat: add questioning page data (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
RenauxLeaInsee authored Nov 27, 2024
1 parent 65738c6 commit 602f3e4
Show file tree
Hide file tree
Showing 19 changed files with 650 additions and 427 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "platine-management",
"private": true,
"version": "2.0.1",
"version": "2.1.0",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
7 changes: 1 addition & 6 deletions src/pages/QuestioningPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
Empty file removed src/pages/SearchSurveyForm.tsx
Empty file.
4 changes: 3 additions & 1 deletion src/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,8 @@ export type APISchemas = {
listContactIdentifiers?: Array<string>
surveyUnitId?: string
surveyUnitIdentificationCode?: string
surveyUnitIdentificationName?: string
surveyUnitLabel?: string
listEvents?: Array<APISchemas["QuestioningEventDto"]>
lastEvent?: string
/* Format: date-time */
Expand Down Expand Up @@ -1586,7 +1588,7 @@ export type APIEndpoints = {
}
}
"/api/questionings/{id}/questioning-communications": {
responses: { get: {} }
responses: { get: Array<APISchemas["QuestioningCommunicationDto"]> }
requests: {
method?: "get"
urlParams: {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/CardtitleWithIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Props = {
export const CardtitleWithIcon = ({ IconComponent, title }: Props) => {
return (
<Row spacing={2}>
<IconComponent />
<IconComponent alt="" />
<Typography variant="headlineSmall" component="h2">
{title}
</Typography>
Expand Down
2 changes: 1 addition & 1 deletion src/ui/FilterSelect.tsx
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
3 changes: 2 additions & 1 deletion src/ui/Form/SelectWithOptions.tsx
Original file line number Diff line number Diff line change
@@ -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 };

Expand Down
2 changes: 1 addition & 1 deletion src/ui/Questioning/AddStatusDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
14 changes: 10 additions & 4 deletions src/ui/Questioning/QuestioningCommentsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down Expand Up @@ -105,9 +109,7 @@ export const QuestioningCommentsCard = ({ questioning, refetch }: Props) => {
))}
</Tabs>
<Stack sx={{ py: 2, px: 1 }} gap={0.5}>
{currentTab === Tab.Questioning && (
<CommentsList comments={questioning.listComments ?? []} sx={{ px: 2.5 }} />
)}
{currentTab === Tab.Questioning && <CommentsList comments={comments} sx={{ px: 2.5 }} />}
{currentTab === Tab.SurveyUnit && <CommentListSU surveyUnitId={questioning.surveyUnitId} />}
</Stack>
</Stack>
Expand Down Expand Up @@ -137,5 +139,9 @@ export const CommentListSU = ({ surveyUnitId }: { surveyUnitId?: string }) => {
);
}

return <CommentsList comments={data.comments ?? []} sx={{ px: 2.5 }} />;
const comments = data.comments
? data.comments.sort((a, b) => b.commentDate!.localeCompare(a.commentDate!))
: [];

return <CommentsList comments={comments} sx={{ px: 2.5 }} />;
};
59 changes: 49 additions & 10 deletions src/ui/Questioning/QuestioningInfos.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,75 @@
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"];
refetch: () => void;
};

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 (
<Row gap={3} alignItems={"start"}>
<Card sx={{ p: 3, flex: 1 }} elevation={2}>
<Stack gap={2}>
<Typography variant={"headlineSmall"} component="h2">
Informations
</Typography>

<CardtitleWithIcon IconComponent={InfoOutlinedIcon} title={"Informations"} />
<List dense sx={{ py: 0 }}>
<ListItem sx={{ px: 0 }}>
<ListItemText
primary={
<Typography variant="titleSmall" component="h3">
Répondant(s)
</Typography>
}
/>
</ListItem>
<Divider variant="fullWidth" />
{questioning.listContactIdentifiers &&
sortedConctacts.map(contact => (
<ListItem
key={contact}
sx={{ px: 0 }}
secondaryAction={
<Button
component={Link}
to={`/contacts/${contact}`}
sx={{ typography: "titleSmall" }}
size="large"
endIcon={<OpenInNewIcon />}
>
Voir
</Button>
}
>
<div style={{ "width": "100%" }}>
<ListItemText
primary={<Typography variant="bodyMedium">{`#${contact}`}</Typography>}
/>
<Divider variant="fullWidth" />
</div>
</ListItem>
))}
</List>
<Stack gap={1} sx={{ pr: 2 }}>
<Typography variant="titleSmall" component="h3">
Unité enquêtée
</Typography>
<Row justifyContent={"space-between"}>
<Typography variant="bodyMedium">{surveyUnitLabel}</Typography>
<Typography variant="bodyMedium">{surveyUnitInformations}</Typography>
<Button
component={Link}
to={`/survey-units/${questioning.surveyUnitId}`}
Expand Down
8 changes: 2 additions & 6 deletions src/ui/Questioning/SearchQuestioningTableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ export const SearchQuestioningTableRow = ({ questioning, stateFilter }: Props) =
{questioning.listContactIdentifiers?.map(contact => `#${contact}`).join(", ")}
</TableCell>
)}
<TableCell>
{questioning.surveyUnitIdentificationCode !== ""
? questioning.surveyUnitIdentificationCode
: questioning.surveyUnitId}
</TableCell>
<TableCell>{questioning.surveyUnitIdentificationCode}</TableCell>
<TableCell>
{questioning.lastEvent && (
<Chip
Expand Down Expand Up @@ -80,7 +76,7 @@ export const SearchQuestioningTableRow = ({ questioning, stateFilter }: Props) =
: "N/A"}
</TableCell>
{/* TODO use it when get quality data */}
{/* {stateFilter === "recovery" && <TableCell>{questioning.quality}</TableCell>} */}
{stateFilter === "recovery" && <TableCell>TODO DATA</TableCell>}
<TableCell align="right">
<ChevronRightIcon fontSize="navigateIcon" color="primary" />
</TableCell>
Expand Down
3 changes: 2 additions & 1 deletion src/ui/Search/FilterListBySelector.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Box, FormControl, MenuItem, Select, SelectChangeEvent } from "@mui/material";
import { Box, FormControl, MenuItem } from "@mui/material";
import { Row } from "../Row.tsx";
import React from "react";
import Select, { SelectChangeEvent } from "@mui/material/Select/Select";

export const FilterListBySelector = () => {
const [selectedOption, setSelectedOption] = React.useState("mostRecent");
Expand Down
2 changes: 1 addition & 1 deletion src/ui/Search/SearchFilters.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import FormControl from "@mui/material/FormControl";
import { Row } from "../Row.tsx";
import InputLabel from "@mui/material/InputLabel";
import Select from "@mui/material/Select";
import ExpandMoreOutlinedIcon from "@mui/icons-material/ExpandMoreOutlined";
import MenuItem from "@mui/material/MenuItem";
import { SearchTextField } from "../SearchTextField.tsx";
import { TextFieldProps } from "@mui/material/TextField";
import { ListItemText } from "@mui/material";
import CheckIcon from "@mui/icons-material/Check";
import Select from "@mui/material/Select/Select";

type Props = Pick<TextFieldProps, "sx"> & {
hasResetButton: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/ui/Search/SearchSurveySelect.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import FormControl from "@mui/material/FormControl";
import InputLabel from "@mui/material/InputLabel";
import MenuItem from "@mui/material/MenuItem";
import Select, { SelectProps } from "@mui/material/Select";
import Select, { SelectProps } from "@mui/material/Select/Select";
import { useId } from "react";

type Props = { options: string[] } & SelectProps;
Expand Down
18 changes: 12 additions & 6 deletions src/ui/SearchTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import CloseIcon from "@mui/icons-material/Close";
type Props = {
hasResetButton: boolean;
label: string;
onReset?: () => void;
inputProps: (name: "searchParam") => {
id: "searchParam";
name: "searchParam";
Expand All @@ -13,7 +14,7 @@ type Props = {
};
};

export const SearchTextField = ({ hasResetButton, label, inputProps }: Props) => {
export const SearchTextField = ({ hasResetButton, label, inputProps, onReset }: Props) => {
return (
<TextField
id="search-field"
Expand All @@ -28,11 +29,16 @@ export const SearchTextField = ({ hasResetButton, label, inputProps }: Props) =>
InputProps={{
endAdornment: (
<InputAdornment position="end">
{hasResetButton && (
<IconButton aria-label={"Réinitialiser la recherche"} type={"reset"} edge="end">
{<CloseIcon color="primary" />}
</IconButton>
)}
{hasResetButton &&
(onReset ? (
<IconButton aria-label={"Réinitialiser la recherche"} onClick={onReset} edge="end">
{<CloseIcon color="primary" />}
</IconButton>
) : (
<IconButton aria-label={"Réinitialiser la recherche"} type="reset" edge="end">
{<CloseIcon color="primary" />}
</IconButton>
))}
<IconButton
aria-label={"Lancer la recherche"}
variant="contained"
Expand Down
3 changes: 2 additions & 1 deletion src/ui/Survey/SurveyHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Row } from "../Row.tsx";
import { IconButton, MenuItem, Select, SelectChangeEvent, Stack, Typography } from "@mui/material";
import { IconButton, MenuItem, Select, Stack, Typography } from "@mui/material";
import ArrowBackIosNewIcon from "@mui/icons-material/ArrowBackIosNew";
import { useNavigate } from "react-router-dom";
import { BinocularIcon } from "../Icon/BinocularIcon.tsx";
import { useState } from "react";
import { APISchemas } from "../../types/api.ts";
import { useFetchQuery } from "../../hooks/useFetchQuery.ts";
import { SelectChangeEvent } from "@mui/material/Select/Select";

type Props = {
survey: APISchemas["SurveyDto"];
Expand Down
8 changes: 8 additions & 0 deletions src/ui/SurveyUnit/SurveyUnitCommentsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ type CommentType = {
} & Pick<StackProps, "sx">;

export const CommentsList = ({ comments, sx }: CommentType) => {
if (comments.length === 0) {
return (
<Typography variant="titleSmall" color={theme.palette.text.tertiary} sx={{ px: 2 }}>
Aucun commentaire ajouté.
</Typography>
);
}

return (
comments?.length > 0 && (
<List
Expand Down
4 changes: 3 additions & 1 deletion src/ui/TableComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { FormEventHandler } from "react";
import { theme } from "../theme.tsx";
import Button from "@mui/material/Button";
import Card from "@mui/material/Card";
import Select, { SelectChangeEvent } from "@mui/material/Select";
import { FormControl, InputLabel, MenuItem } from "@mui/material";
import ExpandMoreOutlinedIcon from "@mui/icons-material/ExpandMoreOutlined";
import Select, { SelectChangeEvent } from "@mui/material/Select/Select";

export interface Column {
id: string;
Expand Down Expand Up @@ -79,11 +79,13 @@ const CustomPageSizeSelector = ({
<FormControl sx={{ width: "160px", mr: 2 }} variant="filled">
<InputLabel id={"selectPaginationLabel"}>{"Lignes par page"}</InputLabel>
<Select
labelId="selectPaginationLabel"
variant="filled"
defaultValue={defaultValue.toString()}
onChange={onChange}
fullWidth
disableUnderline
inputProps={{ "aria-labelledby": "selectPaginationLabel" }}
IconComponent={props => <ExpandMoreOutlinedIcon {...props} sx={{ color: "text.primary" }} />}
>
{[10, 20, 50].map(pageSize => (
Expand Down
Loading

0 comments on commit 602f3e4

Please sign in to comment.