Skip to content

Commit 5b80c78

Browse files
author
ledouxm
committed
fix: add visite_details field + fix pdf issues
1 parent 3582302 commit 5b80c78

14 files changed

Lines changed: 36 additions & 22 deletions

File tree

packages/backend/src/db/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,8 @@ export const stateReport = pgTable(
649649
titre_edifice: text("titre_edifice"),
650650
// contexte de la visite
651651
natureVisite: text("nature_visite"),
652-
visite_partielle_parties: text("visite_partielle_parties"),
653652
visite_partielle_details: text("visite_partielle_details"),
653+
visite_details: text("visite_details"),
654654
bilanQuinquennal: boolean("bilan_quinquennal").default(true),
655655
dateVisite: timestamp("date_visite", { mode: "string" }),
656656
redactedBy: text("redacted_by"),

packages/backend/src/features/mail/dsfrMailWrapper.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ const DSFR_CSS = `
113113
[data-ogsc] .link { color: #7C7CFF !important; }
114114
}
115115
body {
116+
font-family:'Marianne',Arial,Helvetica,sans-serif !important;
116117
width: 100%;
117118
background-color: #ffffff;
118119
margin: 0;
@@ -173,7 +174,7 @@ export function wrapWithDsfrMail({
173174
<tr><td align="center" class="darkmode">
174175
<table style="min-width:600px; margin:0 auto; width:600px;" class="wlkm-mw darkmode" width="600" cellspacing="0" cellpadding="0" role="presentation" border="0" bgcolor="#ffffff" align="center">
175176
<tr><td class="darkmode">
176-
<table style="margin:0 auto; width:496px;" class="wlkm-cl darkmode" width="496" cellspacing="0" cellpadding="0" role="presentation" border="0" bgcolor="#ffffff" align="center">
177+
<table style="padding-left:10px;padding-right:10px;width:496px;" class="wlkm-cl darkmode" width="496" cellspacing="0" cellpadding="0" role="presentation" border="0" bgcolor="#ffffff" align="center">
177178
<tr><td class="darkmode-1" width="496" align="left" valign="top" style="padding:4px 0px 8px 0px; line-height:18px; font-size:12px; color:#6b6b6b; font-family:'Marianne',Arial,Helvetica,sans-serif;">
178179
<span style="font-family:'Marianne',Arial,Helvetica,sans-serif !important;">${escapeHtml(preheader)}</span>
179180
</td></tr>
@@ -192,8 +193,8 @@ export function wrapWithDsfrMail({
192193
<tr><td align="center">
193194
<table style="min-width:600px; margin:0 auto; width:600px; border-left:1px #e5e5e5 solid; border-right:1px #e5e5e5 solid; border-top:1px #e5e5e5 solid;" class="wlkm-mw darkmode" width="600" cellspacing="0" cellpadding="0" role="presentation" border="0" bgcolor="#ffffff" align="center">
194195
<tr><td>
195-
<table style="margin:0 auto; width:496px;" class="wlkm-cl darkmode" width="496" cellspacing="0" cellpadding="0" role="presentation" border="0" bgcolor="#ffffff" align="center">
196-
<tr><td style="width:100%;" width="100%" valign="top" align="center">
196+
<table style="width:100%;" class="wlkm-cl darkmode" width="496" cellspacing="0" cellpadding="0" role="presentation" border="0" bgcolor="#ffffff" align="center">
197+
<tr ><td style="width:100%; padding-left:10px; padding-right:10px;" width="100%" valign="top" align="center">
197198
<!-- Marianne logo left -->
198199
<table style="border-collapse:collapse;" width="76" cellspacing="0" cellpadding="0" role="presentation" border="0" align="left" bgcolor="#ffffff" class="darkmode">
199200
<tr><td align="center">
@@ -237,7 +238,7 @@ export function wrapWithDsfrMail({
237238
<tr><td align="center">
238239
<table style="min-width:600px; margin:0 auto; width:600px; border-left:1px #e5e5e5 solid; border-right:1px #e5e5e5 solid;" class="wlkm-mw darkmode-4" width="600" cellspacing="0" cellpadding="0" role="presentation" border="0" bgcolor="#ECECFE" align="center">
239240
<tr><td>
240-
<table style="margin:0 auto; width:496px;" class="wlkm-cl darkmode" width="496" cellspacing="0" cellpadding="0" role="presentation" border="0" bgcolor="#ECECFE" align="center">
241+
<table style="width:100%;" class="wlkm-cl darkmode" width="496" cellspacing="0" cellpadding="0" role="presentation" border="0" bgcolor="#ECECFE" align="center">
241242
<tr><td class="darkmode-4" width="496" align="left" valign="top" style="padding:20px 10px 20px 10px; line-height:32px; font-size:24px; color:#161616; font-family:'Marianne',Arial,Helvetica,sans-serif;">
242243
<span style="font-family:'Marianne',Arial,Helvetica,sans-serif !important;"><strong>${escapeHtml(title)}</strong></span>
243244
</td></tr>

packages/backend/src/services/uploadService.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const client = new S3Client({
1818

1919
export const upload = async () => {};
2020
const bucketUrl = `${ENV.MINIO_URL}/${ENV.MINIO_BUCKET}`;
21-
console.log(bucketUrl);
2221
const addAttachmentPrefix = (filePath: string) => "attachment/" + filePath;
2322

2423
export class UploadService {
@@ -69,7 +68,6 @@ export class UploadService {
6968
.where("attachment_id", "like", "%.pdf")
7069
.selectAll()
7170
.executeTakeFirst();
72-
console.log(attachment);
7371
if (!attachment) throw new AppError(404, "PDF not found");
7472

7573
const command = new GetObjectCommand({ Bucket: bucketUrl, Key: addAttachmentPrefix(attachment.attachment_id) });

packages/frontend/src/db/AppSchema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ const state_report = new Table({
227227

228228
nature_visite: column.text,
229229
visite_partielle_details: column.text,
230+
visite_details: column.text,
230231
date_visite: column.text,
231232
personnes_presentes: column.text,
232233
redacted_by: column.text,

packages/frontend/src/features/state-report/WithReferencePop.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ const CreateButton = () => {
260260
})
261261
.map(([key]) => key);
262262

263-
console.log(alertsQuery.data);
264263
const alertErrors = alertsQuery.data
265264
?.map((alert) => {
266265
const errors = checkAlertErrors(alert);

packages/frontend/src/features/state-report/alerts/StateReportAlertsMenu.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ export const StateReportAlertsMenu = ({ onClose }: StateReportAlertModalContentP
4545

4646
const { constatId } = routeApi.useParams();
4747
const existingSectionsQuery = useQuery(constatPdfQueries.alerts({ constatId }));
48-
console.log("existingSectionsQuery", existingSectionsQuery.data);
4948
const existingSections = existingSectionsQuery.data ?? [];
5049

5150
return (
@@ -188,8 +187,6 @@ const AlertSectionsList = ({
188187
.returningAll()
189188
.execute();
190189

191-
console.log("Created new alert", newAlert);
192-
193190
fieldArray.append({ ...newAlert[0], attachments: [] });
194191
},
195192
});
@@ -262,7 +259,6 @@ const AlertSectionsList = ({
262259
}
263260

264261
const chunked = chunk(alertSectionStaticData, isDesktop ? 2 : 1);
265-
console.log({ alertSectionStaticData, alertSections });
266262
return (
267263
<>
268264
{chunked.map((chunk, index) => (

packages/frontend/src/features/state-report/pdf/ConstatPdf.queries.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ export const constatPdfQueries = {
143143
queryOptions({
144144
queryKey: ["state-report-alerts", constatId],
145145
queryFn: async () => {
146-
console.log("fetching alerts for constatId", constatId);
147146
const alerts = await db
148147
.selectFrom("state_report_alert")
149148
.selectAll()

packages/frontend/src/features/state-report/pdf/ConstatPdf.send.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ export const SendConstatPdf = () => {
3131
};
3232

3333
const BlobViewer = ({ blob }: BlobProviderParams) => {
34-
console.log("blob");
3534
if (!blob) return null;
3635
return <PDFViewerPaginated blob={blob} />;
3736
};

packages/frontend/src/features/state-report/steps/ConstatDetaille.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { RadioButtons } from "@codegouvfr/react-dsfr/RadioButtons";
66
import { Box, Dialog, DialogTitle, Grid, Stack, Typography } from "@mui/material";
77
import { useMutation } from "@tanstack/react-query";
88
import { getRouteApi } from "@tanstack/react-router";
9-
import { useState } from "react";
9+
import { useEffect, useRef, useState } from "react";
1010
import useDebounce from "react-use/lib/useDebounce";
1111
import { v4 } from "uuid";
1212
import { useUser } from "../../../contexts/AuthContext";
@@ -24,6 +24,7 @@ import { fr } from "@codegouvfr/react-dsfr";
2424
import { ButtonsSwitch } from "../WithReferencePop";
2525
import { chunk } from "pastable";
2626
import { getIsSectionVisited } from "@patrinotes/pdf/utils";
27+
import { useClickAway } from "react-use";
2728

2829
const routeApi = getRouteApi("/constat/$constatId");
2930
export const ConstatDetaille = () => {
@@ -192,6 +193,11 @@ const SectionModal = ({
192193
}) => {
193194
const isCustom = selectedSection && !defaultSections.includes(selectedSection.section!);
194195

196+
const ref = useRef<HTMLDivElement>(null);
197+
useClickAway(ref, () => {
198+
onClose();
199+
});
200+
195201
return (
196202
<Dialog
197203
open={selectedSection !== null}
@@ -206,7 +212,7 @@ const SectionModal = ({
206212
},
207213
}}
208214
>
209-
<Box p={{ xs: "16px" }}>
215+
<Box p={{ xs: "16px" }} ref={ref}>
210216
<ModalCloseButton onClose={onClose} />
211217

212218
<DialogTitle
@@ -249,6 +255,13 @@ const SectionForm = ({
249255
},
250256
});
251257

258+
// sync form values when modal is closed
259+
useEffect(() => {
260+
return () => {
261+
syncMutation.mutate();
262+
};
263+
}, []);
264+
252265
const syncMutation = useMutation({
253266
mutationFn: async () => {
254267
if (Object.keys(diff).length === 0) {
@@ -316,6 +329,7 @@ const SectionForm = ({
316329
sx={{ mb: "16px !important" }}
317330
textArea
318331
disabled={isDisabled || isRecording}
332+
hintText="Cause(s) probable(s) des désordres, incidences sur d’autres éléments…"
319333
label="Commentaires"
320334
nativeTextAreaProps={{
321335
rows: 6,

packages/frontend/src/features/state-report/steps/ContexteVisite.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const ContexteVisite = () => {
2727
pt={{ xs: "16px", lg: "14px" }}
2828
mb="40px"
2929
sx={{
30-
input: {
30+
"input, textarea": {
3131
maxWidth: "588px",
3232
},
3333
}}
@@ -47,8 +47,18 @@ export const ContexteVisite = () => {
4747
Contexte de la visite
4848
</Typography>
4949
<MandatoryFieldReminder />
50+
5051
<NatureVisiteRadioButtons isDisabled={isDisabled} />
52+
<Input
53+
textArea
54+
hintText="Déclenchement de la visite, durée, conditions..."
55+
nativeTextAreaProps={{
56+
rows: 4,
57+
}}
58+
label="Détails de la visite"
59+
/>
5160
<BilanQuinquennalRadioButtons isDisabled={isDisabled} />
61+
5262
<Divider mb="16px" />
5363
<DateInput
5464
isDisabled={isDisabled}
@@ -224,7 +234,7 @@ const NatureVisiteRadioButtons = ({ isDisabled }: { isDisabled: boolean }) => {
224234
}));
225235

226236
return (
227-
<Stack gap={0} mb="16px">
237+
<Stack gap={0} mb="1.5rem">
228238
<RadioButtons
229239
disabled={isDisabled}
230240
orientation={isDesktop ? "horizontal" : "vertical"}

0 commit comments

Comments
 (0)