From 5b4b2d35af5e18d8812b0eb51c0cf31b6c238159 Mon Sep 17 00:00:00 2001 From: Mihoub Date: Tue, 12 Nov 2024 12:28:57 +0100 Subject: [PATCH] chore(client): clean code, and add filters on last sent mails page --- .../src/api/contribution-api/getSentMails.tsx | 1 - .../contribution-production-card.tsx | 5 +++- .../link-publications/export-to-xlsx.tsx | 1 - .../link-publications/index.tsx | 2 +- .../components}/contribution-item.tsx | 2 +- .../components}/contributor-info.tsx | 2 +- .../components}/contributor-summary.tsx | 2 +- .../components}/message-preview.tsx | 6 ++--- .../components}/staff-action.tsx | 24 +++++++++---------- .../components}/styles.scss | 0 .../components}/utils/capitalize.tsx | 0 .../components}/utils/copy-button.tsx | 0 .../components}/utils/index.tsx | 0 .../index.tsx | 6 ++--- .../pages/last-mails-sent/components/item.tsx | 13 +++++++++- .../last-mails-sent/components/selectors.tsx | 3 +-- client/src/pages/last-mails-sent/index.tsx | 15 ++++++++---- client/src/types/index.ts | 2 +- server/routes/receive-email/index.ts | 2 +- 19 files changed, 51 insertions(+), 35 deletions(-) rename client/src/{components/items => pages/contact-contributionbyobject-page/components}/contribution-item.tsx (98%) rename client/src/{components/items => pages/contact-contributionbyobject-page/components}/contributor-info.tsx (89%) rename client/src/{components/items => pages/contact-contributionbyobject-page/components}/contributor-summary.tsx (97%) rename client/src/{components/items => pages/contact-contributionbyobject-page/components}/message-preview.tsx (97%) rename client/src/{components/items => pages/contact-contributionbyobject-page/components}/staff-action.tsx (91%) rename client/src/{components/items => pages/contact-contributionbyobject-page/components}/styles.scss (100%) rename client/src/{components/items => pages/contact-contributionbyobject-page/components}/utils/capitalize.tsx (100%) rename client/src/{components/items => pages/contact-contributionbyobject-page/components}/utils/copy-button.tsx (100%) rename client/src/{components/items => pages/contact-contributionbyobject-page/components}/utils/index.tsx (100%) diff --git a/client/src/api/contribution-api/getSentMails.tsx b/client/src/api/contribution-api/getSentMails.tsx index d904925..e95d266 100644 --- a/client/src/api/contribution-api/getSentMails.tsx +++ b/client/src/api/contribution-api/getSentMails.tsx @@ -16,7 +16,6 @@ const useSentEmails = () => { ["sentEmails"], fetchSentEmails ); - console.log(data); return { data, isLoading, isError, refetch }; }; diff --git a/client/src/pages/api-operation-page/link-publications/contribution-production-card.tsx b/client/src/pages/api-operation-page/link-publications/contribution-production-card.tsx index 96b8332..78f3702 100644 --- a/client/src/pages/api-operation-page/link-publications/contribution-production-card.tsx +++ b/client/src/pages/api-operation-page/link-publications/contribution-production-card.tsx @@ -13,7 +13,10 @@ import StaffProductionActions from "./staff-production-action"; import { useState } from "react"; import { FaCopy } from "react-icons/fa"; import { Contribute_Production } from "../../../types"; -import { BadgeStatus, StatusLabel } from "../../../components/items/utils"; +import { + BadgeStatus, + StatusLabel, +} from "../../contact-contributionbyobject-page/components/utils"; const ContributionProductionItem = ({ data, diff --git a/client/src/pages/api-operation-page/link-publications/export-to-xlsx.tsx b/client/src/pages/api-operation-page/link-publications/export-to-xlsx.tsx index e62f8bd..8367a65 100644 --- a/client/src/pages/api-operation-page/link-publications/export-to-xlsx.tsx +++ b/client/src/pages/api-operation-page/link-publications/export-to-xlsx.tsx @@ -58,7 +58,6 @@ const ExcelExportButton: React.FC = ({ refetch }) => { }; const handleExportClick = async () => { - console.log(dataList); const dataToExport = dataList .filter((item) => item.export === true) .map((item) => ({ diff --git a/client/src/pages/api-operation-page/link-publications/index.tsx b/client/src/pages/api-operation-page/link-publications/index.tsx index 2ddf4c6..778c425 100644 --- a/client/src/pages/api-operation-page/link-publications/index.tsx +++ b/client/src/pages/api-operation-page/link-publications/index.tsx @@ -141,7 +141,7 @@ const ContributionPage: React.FC = () => { status={status} setSort={setSort} setStatus={setStatus} - searchInMessage={""} + searchInMessage={true} setSearchInMessage={""} /> diff --git a/client/src/components/items/contribution-item.tsx b/client/src/pages/contact-contributionbyobject-page/components/contribution-item.tsx similarity index 98% rename from client/src/components/items/contribution-item.tsx rename to client/src/pages/contact-contributionbyobject-page/components/contribution-item.tsx index 096b80b..3c79f99 100644 --- a/client/src/components/items/contribution-item.tsx +++ b/client/src/pages/contact-contributionbyobject-page/components/contribution-item.tsx @@ -2,7 +2,7 @@ import React, { useState } from "react"; import { Badge, Col, Row, Text, Notice, Title } from "@dataesr/dsfr-plus"; import ContributorInfo from "./contributor-info"; import StaffActions from "./staff-action"; -import { ContributionItemProps } from "../../types"; +import { ContributionItemProps } from "../../../types"; import { BadgeColor, BadgeStatus, diff --git a/client/src/components/items/contributor-info.tsx b/client/src/pages/contact-contributionbyobject-page/components/contributor-info.tsx similarity index 89% rename from client/src/components/items/contributor-info.tsx rename to client/src/pages/contact-contributionbyobject-page/components/contributor-info.tsx index 158961d..a2d65a2 100644 --- a/client/src/components/items/contributor-info.tsx +++ b/client/src/pages/contact-contributionbyobject-page/components/contributor-info.tsx @@ -1,4 +1,4 @@ -import { Contribution } from "../../types"; +import { Contribution } from "../../../types"; import MessagePreview from "./message-preview"; const ContributorInfo = ({ diff --git a/client/src/components/items/contributor-summary.tsx b/client/src/pages/contact-contributionbyobject-page/components/contributor-summary.tsx similarity index 97% rename from client/src/components/items/contributor-summary.tsx rename to client/src/pages/contact-contributionbyobject-page/components/contributor-summary.tsx index 6e51999..07073ac 100644 --- a/client/src/components/items/contributor-summary.tsx +++ b/client/src/pages/contact-contributionbyobject-page/components/contributor-summary.tsx @@ -6,7 +6,7 @@ import { SideMenuItem, Text, } from "@dataesr/dsfr-plus"; -import { ContributorSummaryProps } from "../../types"; +import { ContributorSummaryProps } from "../../../types"; import { BadgeColor, BadgeStatus, diff --git a/client/src/components/items/message-preview.tsx b/client/src/pages/contact-contributionbyobject-page/components/message-preview.tsx similarity index 97% rename from client/src/components/items/message-preview.tsx rename to client/src/pages/contact-contributionbyobject-page/components/message-preview.tsx index fa122dc..5ed52c5 100644 --- a/client/src/components/items/message-preview.tsx +++ b/client/src/pages/contact-contributionbyobject-page/components/message-preview.tsx @@ -1,8 +1,8 @@ import { Button, Col, Container, Link, Row, Text } from "@dataesr/dsfr-plus"; -import type { Contribution } from "../../types"; -import HighlightedMessage from "../highlighted-message"; +import type { Contribution } from "../../../types"; +import HighlightedMessage from "../../../components/highlighted-message"; import { useLocation } from "react-router-dom"; -import EditModal from "../edit-modal"; +import EditModal from "../../../components/edit-modal"; import { useState, useCallback } from "react"; import { capitalizeFirstLetter } from "./utils/capitalize"; import { CopyButton } from "./utils/copy-button"; diff --git a/client/src/components/items/staff-action.tsx b/client/src/pages/contact-contributionbyobject-page/components/staff-action.tsx similarity index 91% rename from client/src/components/items/staff-action.tsx rename to client/src/pages/contact-contributionbyobject-page/components/staff-action.tsx index 0d49e4a..152f914 100644 --- a/client/src/components/items/staff-action.tsx +++ b/client/src/pages/contact-contributionbyobject-page/components/staff-action.tsx @@ -1,6 +1,6 @@ import { Col, Text } from "@dataesr/dsfr-plus"; -import EmailSender from "../../api/send-mail"; -import type { Contribution } from "../../types"; +import EmailSender from "../../../api/send-mail"; +import type { Contribution } from "../../../types"; import { useLocation } from "react-router-dom"; // import { useMutation, useQueryClient } from "@tanstack/react-query"; import "./styles.scss"; @@ -17,16 +17,16 @@ const StaffActions = ({ }) => { const location = useLocation(); - let baseUrl = "contacts"; - if (location?.pathname?.includes("scanr-contributionpage")) { - baseUrl = "contribute"; - } else if (location?.pathname?.includes("removeuser")) { - baseUrl = "remove-user"; - } else if (location?.pathname?.includes("namechange")) { - baseUrl = "update-user-data"; - } else if (location?.pathname?.includes("apioperations")) { - baseUrl = "production"; - } + // let baseUrl = "contacts"; + // if (location?.pathname?.includes("scanr-contributionpage")) { + // baseUrl = "contribute"; + // } else if (location?.pathname?.includes("removeuser")) { + // baseUrl = "remove-user"; + // } else if (location?.pathname?.includes("namechange")) { + // baseUrl = "update-user-data"; + // } else if (location?.pathname?.includes("apioperations")) { + // baseUrl = "production"; + // } const contributorClassName = location.pathname.includes("contributionpage") ? "staffSide" diff --git a/client/src/components/items/styles.scss b/client/src/pages/contact-contributionbyobject-page/components/styles.scss similarity index 100% rename from client/src/components/items/styles.scss rename to client/src/pages/contact-contributionbyobject-page/components/styles.scss diff --git a/client/src/components/items/utils/capitalize.tsx b/client/src/pages/contact-contributionbyobject-page/components/utils/capitalize.tsx similarity index 100% rename from client/src/components/items/utils/capitalize.tsx rename to client/src/pages/contact-contributionbyobject-page/components/utils/capitalize.tsx diff --git a/client/src/components/items/utils/copy-button.tsx b/client/src/pages/contact-contributionbyobject-page/components/utils/copy-button.tsx similarity index 100% rename from client/src/components/items/utils/copy-button.tsx rename to client/src/pages/contact-contributionbyobject-page/components/utils/copy-button.tsx diff --git a/client/src/components/items/utils/index.tsx b/client/src/pages/contact-contributionbyobject-page/components/utils/index.tsx similarity index 100% rename from client/src/components/items/utils/index.tsx rename to client/src/pages/contact-contributionbyobject-page/components/utils/index.tsx diff --git a/client/src/pages/contact-contributionbyobject-page/index.tsx b/client/src/pages/contact-contributionbyobject-page/index.tsx index f50d7f3..d6eda75 100644 --- a/client/src/pages/contact-contributionbyobject-page/index.tsx +++ b/client/src/pages/contact-contributionbyobject-page/index.tsx @@ -15,8 +15,8 @@ import { Contribution, ContributionPageProps } from "../../types"; import BottomPaginationButtons from "../../components/pagination/bottom-buttons"; import TopPaginationButtons from "../../components/pagination/top-buttons"; import Selectors from "../../components/selectors"; -import ContributionItem from "../../components/items/contribution-item"; -import ContributorSummary from "../../components/items/contributor-summary"; +import ContributionItem from "./components/contribution-item"; +import ContributorSummary from "./components/contributor-summary"; import { contactUrl, contributionUrl } from "../../config/api"; const ContactAndContributionPage: React.FC = ({ @@ -26,7 +26,7 @@ const ContactAndContributionPage: React.FC = ({ const [status, setStatus] = useState("choose"); const [query, setQuery] = useState([]); const [page, setPage] = useState(1); - const [searchInMessage, setSearchInMessage] = useState(true); + const [searchInMessage, setSearchInMessage] = useState(false); const [highlightedQuery, setHighlightedQuery] = useState(""); const [selectedContribution, setSelectedContribution] = useState(""); const location = useLocation(); diff --git a/client/src/pages/last-mails-sent/components/item.tsx b/client/src/pages/last-mails-sent/components/item.tsx index 9f98c4c..3686e56 100644 --- a/client/src/pages/last-mails-sent/components/item.tsx +++ b/client/src/pages/last-mails-sent/components/item.tsx @@ -46,7 +46,18 @@ const LastMailsSentItem: React.FC = ({ data }) => { > {collectionNameMapping[email.collectionName]} - + {(collectionNameMapping[email.collectionName] === + "Changement de nom" || + collectionNameMapping[email.collectionName] === + "Lier des publications") && ( + + Scanr + + )} {email.fromApplication && ( { const handleProfileChange = (event) => { setStatus(event.target.value); @@ -9,7 +8,7 @@ const Selectors = ({ uniqueProfiles, setStatus }) => {