Skip to content

Commit

Permalink
fix(staffactions): small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihoub2 committed Oct 9, 2024
1 parent e9e16fd commit 5f63e6c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 45 deletions.
2 changes: 1 addition & 1 deletion client/src/components/items/contribution-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const ContributionItem: React.FC<ContributionItemProps> = ({
};

const firstThread = data?.threads?.[0];
const firstResponse = firstThread?.responses?.[0];
const firstResponse = firstThread?.responses?.[1];

return (
<>
Expand Down
83 changes: 39 additions & 44 deletions client/src/components/items/staff-action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ const StaffActions = ({
<>
{data?.threads?.length > 0 && (
<Col className={contributorClassName}>
{/* Afficher le toggle uniquement s'il y a plus de 2 objets dans threads */}
{data.threads.length > 2 && (
<Toggle
label="Marquer toutes les réponses comme lues"
Expand All @@ -132,49 +131,45 @@ const StaffActions = ({
/>
)}

{data.threads.map((thread, threadIndex) =>
thread.responses.map((response, index) => {
const responseDate = new Date(
response.timestamp
).toLocaleDateString();
const responseTime = new Date(
response.timestamp
).toLocaleTimeString();

if (displayedDates.has(responseDate + responseTime)) {
return null;
}

displayedDates.add(responseDate + responseTime);

const responder = response.team.includes("user")
? data.name
: response.team.join(", ");

return (
<div
key={`${threadIndex}-${index}`}
className="response-container"
>
<Text
size="sm"
className={
response.team.includes("user") ? "user-side" : "staffSide"
}
>
{responder && (
<>
Réponse apportée par {responder} le {responseDate} à{" "}
{responseTime} :
<br />
{response.responseMessage}
</>
)}
</Text>
</div>
);
})
)}
{data.threads.map((thread, threadIndex) => {
const teamResponses = thread.responses.filter(
(response) => !response.team.includes("user")
);

return teamResponses.length > 0
? teamResponses.map((response, index) => {
const responseDate = new Date(
response.timestamp
).toLocaleDateString();
const responseTime = new Date(
response.timestamp
).toLocaleTimeString();

if (displayedDates.has(responseDate + responseTime)) {
return null;
}

displayedDates.add(responseDate + responseTime);

const responder = response.team.join(", ");

return (
<div key={`${threadIndex}-${index}`}>
<Text size="sm" className="staffSide">
{responder && (
<>
Réponse apportée par {responder} le {responseDate} à{" "}
{responseTime} :
<br />
{response.responseMessage}
</>
)}
</Text>
</div>
);
})
: null;
})}
</Col>
)}

Expand Down

0 comments on commit 5f63e6c

Please sign in to comment.