Skip to content

Commit 467e0ed

Browse files
I've refactored the Evidence component for IPFS validation and line length.
Here's what I did: - I made the Attachment link render conditionally based on whether it's a valid IPFS path (meaning it starts with '/ipfs/'). - I also refactored conditions into constants to make sure everything complies with the 80-character line limit.
1 parent 527c970 commit 467e0ed

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/app/[locale]/case/[disputeId]/components/Evidence.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ const Evidence: React.FC<IEvidence> = async ({ evidenceGroupId }) => {
2727
return (
2828
<div className="w-full px-4 space-y-6">
2929
<h3 className="text-primary-text text-lg text-center">{t("title")}</h3>
30-
{data.evidences.map((evidence, i) => (
31-
<div key={evidence.evidenceIndex} className="w-full">
32-
<h4
33-
className="text-base md:text-md text-primary-text font-semibold"
30+
{data.evidences.map((evidence, i) => {
31+
const hasFileURI = evidence.fileURI && evidence.fileURI.length > 0;
32+
const isIpfsPath = hasFileURI && evidence.fileURI.startsWith("/ipfs/");
33+
34+
return (
35+
<div key={evidence.evidenceIndex} className="w-full">
36+
<h4
37+
className="text-base md:text-md text-primary-text font-semibold"
3438
dir="auto"
3539
>
3640
#{i + 1} {evidence.name}
@@ -51,7 +55,7 @@ const Evidence: React.FC<IEvidence> = async ({ evidenceGroupId }) => {
5155
>
5256
{t("from", { user: shortenAddress(evidence.sender.id) })}
5357
</span>
54-
{evidence.fileURI && evidence.fileURI.length > 0 && (
58+
{isIpfsPath && (
5559
<Link
5660
href={ipfsUrl(evidence.fileURI)}
5761
target="_blank"
@@ -73,7 +77,8 @@ const Evidence: React.FC<IEvidence> = async ({ evidenceGroupId }) => {
7377
)}
7478
</div>
7579
</div>
76-
))}
80+
);
81+
})}
7782
</div>
7883
);
7984
};

0 commit comments

Comments
 (0)