Skip to content

Commit

Permalink
fix(item): update extra display
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihoub2 committed Feb 3, 2025
1 parent df1e2b1 commit a33c7ce
Showing 1 changed file with 76 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,67 @@ const MessagePreview: React.FC<MessagePreviewProps> = ({
{data?.objectId && (
<Text size="sm">
ID de l'objet concerné:{" "}
<strong>{data.objectId?.length > 50 ? data.objectId.slice(0, 47) + "..." : data.objectId}</strong>
<CopyButton text={data.objectId} copiedText={copiedText} onCopy={copyToClipboard} />
<strong>
{data.objectId?.length > 50
? data.objectId.slice(0, 47) + "..."
: data.objectId}
</strong>
<CopyButton
text={data.objectId}
copiedText={copiedText}
onCopy={copyToClipboard}
/>
</Text>
)}
<Text size="sm">
Nom: {data?.name ? <strong>{data.name}</strong> : "non renseigné"}
{data?.name && <CopyButton text={data.name} copiedText={copiedText} onCopy={copyToClipboard} />}
{data?.name && (
<CopyButton
text={data.name}
copiedText={copiedText}
onCopy={copyToClipboard}
/>
)}
</Text>
{data?.email && (
<Text size="sm">
Email: <strong>{data?.email}</strong>
<CopyButton text={data.email} copiedText={copiedText} onCopy={copyToClipboard} />
<CopyButton
text={data.email}
copiedText={copiedText}
onCopy={copyToClipboard}
/>
</Text>
)}
</Col>
<Col>
{data?.extra && (
<Col>
<ul>
{Object.entries(data.extra).map(([key, value]) => (
<div key={key}>
<Text size="sm">
{capitalizeFirstLetter(key)}: <strong>{value as string}</strong>
<CopyButton text={value as string} copiedText={copiedText} onCopy={copyToClipboard} />
</Text>
</div>
))}
{Object.entries(data.extra).map(([key, value]) => {
if (value === "") return null;

const displayKey =
key === "subApplication"
? "Sujet"
: capitalizeFirstLetter(key);

const capitalizedValue =
value.charAt(0).toUpperCase() + value.slice(1);

return (
<div key={key}>
<Text size="sm">
{displayKey}: <strong>{capitalizedValue}</strong>
<CopyButton
text={capitalizedValue}
copiedText={copiedText}
onCopy={copyToClipboard}
/>
</Text>
</div>
);
})}
</ul>
</Col>
)}
Expand All @@ -75,7 +109,8 @@ const MessagePreview: React.FC<MessagePreviewProps> = ({
<Text size="sm">
Traité par :{" "}
<strong>
{data.team[0]} le {new Date(data.treated_at).toLocaleDateString()} à{" "}
{data.team[0]} le{" "}
{new Date(data.treated_at).toLocaleDateString()} à{" "}
{new Date(data.treated_at).toLocaleTimeString()}
</strong>
</Text>
Expand All @@ -84,11 +119,14 @@ const MessagePreview: React.FC<MessagePreviewProps> = ({
<Col>
{data?.comment && (
<Text size="sm">
Commentaire ({data.team ? data.team[0] : ""}) <strong>: {data.comment}</strong>
Commentaire ({data.team ? data.team[0] : ""}){" "}
<strong>: {data.comment}</strong>
</Text>
)}
</Col>
{["structures", "publications", "persons", "network"].includes(data?.objectType) && (
{["structures", "publications", "persons", "network"].includes(
data?.objectType
) && (
<Row>
{data.objectType === "structures" && (
<>
Expand All @@ -102,7 +140,11 @@ const MessagePreview: React.FC<MessagePreviewProps> = ({
</Link>
</Col>
<Col>
<Link size="sm" target="_blank" href={`http://185.161.45.213/ui/organizations/${data.objectId}`}>
<Link
size="sm"
target="_blank"
href={`http://185.161.45.213/ui/organizations/${data.objectId}`}
>
Sur dataESR
</Link>
</Col>
Expand All @@ -118,7 +160,11 @@ const MessagePreview: React.FC<MessagePreviewProps> = ({
Sur scanR
</Link>
<br />
<Link size="sm" target="_blank" href={`http://185.161.45.213/ui/publications/${data.objectId}`}>
<Link
size="sm"
target="_blank"
href={`http://185.161.45.213/ui/publications/${data.objectId}`}
>
Sur dataESR
</Link>
</>
Expand All @@ -133,7 +179,11 @@ const MessagePreview: React.FC<MessagePreviewProps> = ({
Sur scanR
</Link>
<br />
<Link size="sm" target="_blank" href={`http://185.161.45.213/ui/persons/${data.objectId}`}>
<Link
size="sm"
target="_blank"
href={`http://185.161.45.213/ui/persons/${data.objectId}`}
>
Sur dataESR
</Link>
</>
Expand All @@ -152,7 +202,10 @@ const MessagePreview: React.FC<MessagePreviewProps> = ({
</Container>
<Row className={contributorMessageClassName}>
<Text className="fr-mt-3w">
<HighlightedMessage message={data?.message} highlightedQuery={highlightedQuery} />
<HighlightedMessage
message={data?.message}
highlightedQuery={highlightedQuery}
/>
</Text>
<EditModal
refetch={refetch}
Expand All @@ -164,10 +217,12 @@ const MessagePreview: React.FC<MessagePreviewProps> = ({
/>
</Row>
<Row className="fr-mb-5w fr-mt-3w">
<Button onClick={() => setShowModal(true)}>Éditer la contribution</Button>
<Button onClick={() => setShowModal(true)}>
Éditer la contribution
</Button>
</Row>
</>
)
);
};

export default MessagePreview;

0 comments on commit a33c7ce

Please sign in to comment.