Skip to content

Commit

Permalink
Merge pull request #622 from MTES-MCT/master
Browse files Browse the repository at this point in the history
Release 09/01/2025
  • Loading branch information
gaspard-lonchampt authored Jan 9, 2025
2 parents 0a51244 + 720534d commit 0afd60c
Show file tree
Hide file tree
Showing 26 changed files with 467 additions and 283 deletions.
50 changes: 50 additions & 0 deletions common/assets/images/interfaced-logos/Chronodrive.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions common/utils/apiQueries.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,15 @@ export const COMPANY_SIGNUP_MUTATION = gql`
$usualName: String!
$phoneNumber: String
$businessType: String
$nbWorkers: Int
) {
signUp {
company(
siren: $siren
usualName: $usualName
phoneNumber: $phoneNumber
businessType: $businessType
nbWorkers: $nbWorkers
) {
employment {
id
Expand Down
2 changes: 1 addition & 1 deletion web/common/AlertEmailDelay.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const AlertEmailDelay = () => {
<Notice
sx={{ marginY: 2 }}
style={{ paddingBottom: 0 }}
type="warning"
type="info"
description={
<>
Il est possible que&nbsp;:
Expand Down
1 change: 1 addition & 0 deletions web/common/ButtonGoHome.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const ButtonGoHome = () => {
onClick={() => {
history.push("/home");
}}
style={{ margin: "auto" }}
>
Aller dans mon espace
</Button>
Expand Down
162 changes: 83 additions & 79 deletions web/common/WayHeardOfMobilic.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import RadioGroup from "@mui/material/RadioGroup";
import Grid from "@mui/material/Grid";
import FormControlLabel from "@mui/material/FormControlLabel";
import Radio from "@mui/material/Radio";
import TextField from "@mui/material/TextField";
import React from "react";
import { makeStyles } from "@mui/styles";
import { RadioButtons } from "@codegouvfr/react-dsfr/RadioButtons";
import { Input } from "@codegouvfr/react-dsfr/Input";
import { MandatorySuffix } from "./forms/MandatorySuffix";

export const WAY_HEARD_OF_MOBILIC_CHOICES = [
{
Expand Down Expand Up @@ -41,81 +36,90 @@ export const WAY_HEARD_OF_MOBILIC_CHOICES = [

export const HEARD_OF_MOBILIC_OTHER_VALUE = "OTHER";

const useStyles = makeStyles(theme => ({
wayKnowingMobilicSection: {
textAlign: "left",
marginTop: theme.spacing(2),
marginBottom: theme.spacing(2),
color: theme.palette.grey[700]
},
wayKnowingMobilicTitle: {
marginBottom: theme.spacing(1)
}
}));
export function WayHeardOfMobilic({
setWayHeardOfMobilic,
touched = false,
required
}) {
const [selectValue, setSelectValue] = React.useState("");
const [otherValue, setOtherValue] = React.useState("");

export const WayHeardOfMobilic = ({ setWayHeardOfMobilicValue }) => {
const classes = useStyles();
const [wayHeardOfMobilicSelect, setWayHeardOfMobilicSelect] = React.useState(
""
const selectError = React.useMemo(() => touched && !selectValue, [
selectValue,
touched
]);

const otherError = React.useMemo(
() =>
touched && selectValue === HEARD_OF_MOBILIC_OTHER_VALUE && !otherValue,
[touched, selectValue, otherValue]
);

const handleChangeWayHeardOfMobilic = event => {
setWayHeardOfMobilicSelect(event.target.value);
setWayHeardOfMobilicValue(event.target.value);
React.useEffect(() => {
setWayHeardOfMobilic(
selectValue === HEARD_OF_MOBILIC_OTHER_VALUE ? otherValue : selectValue
);
}, [selectValue, otherValue]);

React.useEffect(() => {
if (selectValue !== HEARD_OF_MOBILIC_OTHER_VALUE) {
setOtherValue("");
}
}, [selectValue]);

const handleRadioChange = event => {
const newValue = event.target.value;
setSelectValue(newValue);
};

const handleOtherInputChange = event => {
const value = event.target.value.trimStart();
setOtherValue(value);
};

return (
<Box className={classes.wayKnowingMobilicSection}>
<Typography className={classes.wayKnowingMobilicTitle}>
Comment avez-vous connu Mobilic ?
</Typography>
<RadioGroup
aria-label="how-did-you-know-mobilic"
name="controlled-radio-buttons-group"
value={wayHeardOfMobilicSelect}
onChange={handleChangeWayHeardOfMobilic}
>
<Grid container rowSpacing={2}>
{WAY_HEARD_OF_MOBILIC_CHOICES.map(choice => (
<Grid item xs={12} sm={6} key={choice.value}>
<FormControlLabel
value={choice.value}
control={<Radio size={"small"} />}
label={choice.label}
/>
</Grid>
))}
<Grid item xs={12} sm={6}>
<FormControlLabel
key={HEARD_OF_MOBILIC_OTHER_VALUE}
control={
<Radio
size={"small"}
value={HEARD_OF_MOBILIC_OTHER_VALUE}
color="primary"
label="Autre"
/>
}
label={
wayHeardOfMobilicSelect === HEARD_OF_MOBILIC_OTHER_VALUE ? (
<TextField
label="Précisez"
variant="standard"
inputProps={{
maxLength: 250
}}
onChange={e => {
setWayHeardOfMobilicValue(e.target.value.trimStart());
}}
/>
) : (
"Autre"
)
}
/>
</Grid>
</Grid>
</RadioGroup>
</Box>
<>
<RadioButtons
legend={
<>
Comment avez-vous connu Mobilic ? <MandatorySuffix />
</>
}
options={[
...WAY_HEARD_OF_MOBILIC_CHOICES.map(choice => ({
value: choice.value,
label: choice.label,
nativeInputProps: { value: choice.value }
})),
{
value: HEARD_OF_MOBILIC_OTHER_VALUE,
label: "Autre",
nativeInputProps: { value: HEARD_OF_MOBILIC_OTHER_VALUE }
}
]}
value={selectValue}
required={required}
state={selectError ? "error" : "default"}
stateRelatedMessage={
selectError ? "Veuillez compléter ce champ" : undefined
}
onChange={handleRadioChange}
/>
{selectValue === HEARD_OF_MOBILIC_OTHER_VALUE && (
<Input
label="Précisez"
nativeInputProps={{
value: otherValue,
onChange: handleOtherInputChange,
maxLength: 250
}}
state={otherError ? "error" : "default"}
stateRelatedMessage={
otherError ? "Veuillez compléter ce champ" : undefined
}
required={required}
/>
)}
</>
);
};
}
63 changes: 63 additions & 0 deletions web/common/forms/NumericInput.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import React from "react";
import { Input } from "./Input";

export const NumericInput = ({
initialValue,
onChangeValue,
label,
required = false,
min = 0,
max
}) => {
const [value, setValue] = React.useState(initialValue);
const [touched, setTouched] = React.useState(false);
const state = React.useMemo(
() => (touched && (value < min || value > max) ? "error" : "default"),
[touched, min, max, value]
);
React.useEffect(() => {
onChangeValue(value);
}, [value]);
const errorMessage = React.useMemo(() => {
if (!touched) {
return "";
}
if (!max || isNaN(parseInt(max))) {
return `Veuillez entrer une valeur supérieure à ${min}`;
}
return `Veuillez entrer une valeur comprise entre ${min} et ${max}`;
}, [touched, min, max, value]);

const handleChange = event => {
const inputValue = event.target.value;
if (!inputValue) {
setValue(inputValue);
}

const parsedValue = parseInt(inputValue);

if (!isNaN(parsedValue)) {
setValue(parsedValue);
} else {
event.target.value = value;
}
};

return (
<Input
label={label}
required={required}
nativeInputProps={{
value: value,
onInput: handleChange,
inputMode: "numeric",
pattern: "[0-9]*",
type: "number",
onBlur: () => setTouched(true)
}}
type="number"
state={state}
stateRelatedMessage={errorMessage}
/>
);
};
8 changes: 8 additions & 0 deletions web/common/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { FranceConnectCallback } from "../signup/FranceConnectCallback";
import { Invite } from "../signup/invite";
import Signup from "../signup/root";
import { SignupSelection } from "../signup/SignupSelection";
import { SecurityAccreditation } from "../landing/accreditation";

function UserReadRedirect() {
const { token } = useParams();
Expand Down Expand Up @@ -204,6 +205,13 @@ export const ROUTES = [
component: <Accessibility />,
menuItemFilter: () => false
},
{
path: "/security-accreditation",
label: "Sécurité",
accessible: () => true,
component: <SecurityAccreditation />,
menuItemFilter: () => false
},
{
path: "/legal-notices",
label: "Mentions légales",
Expand Down
5 changes: 4 additions & 1 deletion web/control/components/Alerts/InfractionDay.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import { useControl } from "../../../controller/utils/contextControl";
import { capitalizeFirstLetter } from "common/utils/string";
import classNames from "classnames";

const controlHistoryDepth =
parseInt(process.env.REACT_APP_USER_CONTROL_HISTORY_DEPTH) || 28;

const gregorian_fr = {
name: "gregorian_fr",
months: [
Expand Down Expand Up @@ -74,7 +77,7 @@ export const InfractionDay = ({ alerts, sanction }) => {
]);

const maxDate = new Date(unixToJSTimestamp(controlData.creationTime));
const minDate = addDaysToDate(new Date(maxDate), -28);
const minDate = addDaysToDate(new Date(maxDate), -controlHistoryDepth);

const onSelectedDatesChange = values => {
const selectedTimestamps = values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import { formatDateTime, formatDay } from "common/utils/time";
import { Description } from "../../../common/typography/Description";
import { Stack } from "@mui/material";

const controlHistoryDepth =
process.env.REACT_APP_USER_CONTROL_HISTORY_DEPTH || 28;

export function ControllerControlHistory({ controlTime, tokenInfo }) {
return (
<Stack rowGap={1}>
<>
<Typography variant="h6" component="h2" sx={{ lineHeight: "0.5rem" }}>
Historique récent (28 jours)
Historique récent ({controlHistoryDepth} jours)
</Typography>
<Description noMargin>
Du{" "}
Expand Down
Loading

0 comments on commit 0afd60c

Please sign in to comment.