Skip to content

Commit

Permalink
fix(schema): update code with new schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihoub2 committed Sep 10, 2024
1 parent 9cd1757 commit 4f39eb1
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 24 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,3 @@ jobs:
mattermost_webhook_url: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
mattermost_channel: ${{ env.MM_NOTIFICATION_CHANNEL}}
deployment_url: ${{ env.DEPLOYMENT_URL }}
- name: 🎉 Celebrate Success in Mattermost
if: success()
run: |
curl -X POST -H 'Content-Type: application/json' -d '{"text": "🎉 Woohoo! Le déploiement est *green* et tout fonctionne bien! C'est l'heure de faire la fête! 🥳🍾"}' ${{ secrets.MATTERMOST_WEBHOOK_URL }}
31 changes: 20 additions & 11 deletions src/components/last-mail/lasts-mails-sent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ const LatestMails: React.FC<LatestMailsProps> = ({ data }) => {
const [scrollIndex, setScrollIndex] = useState(0);
const [isMouseOver, setIsMouseOver] = useState(false);

const filteredMails = data.data
.filter((mail) => mail.mailSent)
if (data.length === 0) {
return <Text>Aucun email trouvé.</Text>;
}

const filteredMails = data
.filter((mail) => mail?.threads?.[0]?.responseMessage)
.sort((a, b) => {
const dateA = new Date(a.mailSentDate || "").getTime();
const dateB = new Date(b.mailSentDate || "").getTime();
const dateA = new Date(a?.threads?.[0]?.timestamp || "").getTime();
const dateB = new Date(b?.threads?.[0]?.timestamp || "").getTime();
return dateB - dateA;
});

Expand Down Expand Up @@ -86,14 +90,19 @@ const LatestMails: React.FC<LatestMailsProps> = ({ data }) => {
}}
>
<Text size="xs">
<strong>{mail.responseFrom}</strong> le{" "}
<i>{new Date(mail.mailSentDate || "").toLocaleDateString()}</i> à{" "}
<strong>{mail.name}</strong>{" "}
{mail.mailSent && (
<strong>{mail.threads?.[0]?.team?.join(", ") || "Équipe"}</strong>{" "}
le{" "}
<i>
{new Date(
mail.threads?.[0]?.timestamp || ""
).toLocaleDateString()}
</i>{" "}
à <strong>{mail.name}</strong>{" "}
{mail.threads?.[0]?.responseMessage && (
<>
{mail.mailSent.length > 100
? mail.mailSent.substring(0, 150) + "..."
: mail.mailSent}{" "}
{(mail.threads[0].responseMessage as string).length > 100
? mail.threads[0].responseMessage.substring(0, 150) + "..."
: mail.threads[0].responseMessage}{" "}
<Link
key={mail._id}
href={`/contact?query=${mail._id}`}
Expand Down
9 changes: 3 additions & 6 deletions src/pages/api-operation-page/link-publications/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,23 @@ const ContributionPage: React.FC<ContributionPageProps> = () => {
}, [location.pathname]);

const url = buildURL(location, sort, status, query.join(" "), page);

const {
data: fetchedData,
isLoading,
isError,
refetch,
} = ContributionData(url);

const getTags = ContributionData(productionUrl);
const allTags = getTags?.data?.data?.map((tag) => tag?.tags);
const allTags = getTags?.data?.map((tag) => tag?.tags);

useEffect(() => {
setData(fetchedData);
}, [fetchedData]);

const meta = (fetchedData as { meta: any })?.meta;
const maxPage = meta ? Math.ceil(meta?.total / 10) : 1;
const contrib: Contribute_Production[] = (
fetchedData as { data: Contribute_Production[] }
)?.data;

const contrib: Contribute_Production[] = fetchedData;
const handleSearch = (value: string) => {
const trimmedValue = value.trim();
if (trimmedValue !== "" && !query.includes(trimmedValue)) {
Expand Down
11 changes: 8 additions & 3 deletions src/pages/contribution-page/contribution-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface ContributionItemProps {
refetch: () => void;
allTags: string[];
}

const ContributionItem: React.FC<ContributionItemProps> = ({
data,
highlightedQuery,
Expand All @@ -36,6 +37,10 @@ const ContributionItem: React.FC<ContributionItemProps> = ({
});
};

// Récupérer la première réponse dans les threads pour remplacer mailSent et responseFrom
const firstThread = data?.threads?.[0];
const firstResponse = firstThread?.responses?.[0];

return (
<>
<Row>
Expand All @@ -53,9 +58,9 @@ const ContributionItem: React.FC<ContributionItemProps> = ({
{StatusLabel({ status: data?.status })}
</Badge>
)}
{data?.responseFrom && (
{firstResponse?.team && (
<Badge size="sm" color="blue-ecume" className="fr-mr-1w fr-mb-1w">
{`Réponse envoyée par ${data.responseFrom}`}
{`Réponse envoyée par ${firstResponse.team.join(", ")}`}
</Badge>
)}
{data?.comment && data?.team?.length > 0 && (
Expand Down Expand Up @@ -90,7 +95,7 @@ const ContributionItem: React.FC<ContributionItemProps> = ({
<FaCopy size={14} color="#2196f3" className="copy-icon" />
</button>
</Title>
{!data?.mailSent && (
{!firstResponse && (
<Notice type="info" closeMode="disallow" className="fr-mb-2w">
Aucune réponse apportée à ce message pour l'instant
</Notice>
Expand Down

0 comments on commit 4f39eb1

Please sign in to comment.