Skip to content

Commit

Permalink
feat(message-preview): truncate long objectId
Browse files Browse the repository at this point in the history
  • Loading branch information
ahonestla committed Jan 8, 2025
1 parent ae023af commit 7561908
Showing 1 changed file with 16 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,19 @@ const MessagePreview: React.FC<MessagePreviewProps> = ({
<Col>
{data?.objectId && (
<Text size="sm">
ID de l'objet concerné: <strong>{data.objectId}</strong>
<CopyButton
text={data.objectId}
copiedText={copiedText}
onCopy={copyToClipboard}
/>
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} />
</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>
Expand All @@ -73,13 +60,8 @@ const MessagePreview: React.FC<MessagePreviewProps> = ({
{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}
/>
{capitalizeFirstLetter(key)}: <strong>{value as string}</strong>
<CopyButton text={value as string} copiedText={copiedText} onCopy={copyToClipboard} />
</Text>
</div>
))}
Expand All @@ -93,8 +75,7 @@ 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 @@ -103,14 +84,11 @@ 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 @@ -124,11 +102,7 @@ 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 @@ -144,11 +118,7 @@ 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 @@ -163,11 +133,7 @@ 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 @@ -186,10 +152,7 @@ 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 @@ -201,12 +164,10 @@ 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 7561908

Please sign in to comment.