From 1d9ceb813821466f165dccac399b0093fed9955d Mon Sep 17 00:00:00 2001 From: madhurMongia Date: Tue, 31 Dec 2024 18:57:05 +0530 Subject: [PATCH] feat: add rejected status handling and update UI components --- src/app/[pohid]/[chain]/[request]/page.tsx | 6 ++++-- src/components/Request/Card.tsx | 12 ++++++++---- src/components/Request/Grid.tsx | 4 ++-- src/config/misc.ts | 3 ++- tailwind.config.cjs | 5 +++++ 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/app/[pohid]/[chain]/[request]/page.tsx b/src/app/[pohid]/[chain]/[request]/page.tsx index c39f3de..d709893 100644 --- a/src/app/[pohid]/[chain]/[request]/page.tsx +++ b/src/app/[pohid]/[chain]/[request]/page.tsx @@ -98,7 +98,9 @@ export default async function Request({ params }: PageProps) { Date.now() / 1000 ); } - } else return true; + return false; + } + return false; } } else if (request.status.id === "transferring") { return ( @@ -106,7 +108,7 @@ export default async function Request({ params }: PageProps) { Date.now() / 1000 ); } - return true; + return false; }; const expired = hasExpired(); diff --git a/src/components/Request/Card.tsx b/src/components/Request/Card.tsx index 564467e..4f68751 100644 --- a/src/components/Request/Card.tsx +++ b/src/components/Request/Card.tsx @@ -110,10 +110,10 @@ function Card({ humanity: { id: pohId, winnerClaim }, expired, }: CardInterface) { - const rejected = status === "resolved" && !winnerClaim.some(claim => claim.index === index); - console.log(rejected); + const rejected = status === "resolved" && !winnerClaim.some(claim => claim.index === index) && !revocation; + const statusTitle = queryToStatus(status, revocation, expired); - const statusColor = colorForStatus(status, revocation, expired); + const statusColor = colorForStatus(status, revocation, expired,rejected); const chain = idToChain(chainId)!; return ( @@ -125,7 +125,11 @@ function Card({
- {camelToTitle(statusTitle, revocation, expired,rejected)} + {status === "resolved" && expired && !revocation + ? "Expired" + : rejected + ? "Rejected" + : camelToTitle(statusTitle, revocation, expired)}
diff --git a/src/components/Request/Grid.tsx b/src/components/Request/Grid.tsx index 58f73de..3e86746 100644 --- a/src/components/Request/Grid.tsx +++ b/src/components/Request/Grid.tsx @@ -90,14 +90,14 @@ const isRequestExpired = ( Number(request.humanity.registration?.expirationTime) < Date.now() / 1000 ); - } // else return (Number(request.creationTime) + Number(humanityLifespan) < Date.now() / 1000) + } } else if (request.status.id === "transferring") { return ( Number(request.creationTime) + Number(humanityLifespan) < Date.now() / 1000 ); } - return true; + return false; }; const normalize = ( diff --git a/src/config/misc.ts b/src/config/misc.ts index 66d69b9..6129958 100644 --- a/src/config/misc.ts +++ b/src/config/misc.ts @@ -17,6 +17,7 @@ export const colorForStatus = ( status: string, revocation: boolean, expired: boolean, + rejected: boolean, ) => { switch (status) { case "vouching": @@ -29,7 +30,7 @@ export const colorForStatus = ( case "disputed": return "challenged"; case "resolved": - return revocation ? "removed" : expired ? "expired" : "registered"; + return revocation ? "removed" : expired ? "expired" : rejected ? "rejected" : "registered"; default: throw new Error("status error"); } diff --git a/tailwind.config.cjs b/tailwind.config.cjs index db7de87..88b284f 100644 --- a/tailwind.config.cjs +++ b/tailwind.config.cjs @@ -31,6 +31,7 @@ module.exports = { expired: "#333333", transferred: "#3F6212", transferring: "#ba7264", + rejected: "#D90429", }, }, dark: { @@ -54,6 +55,7 @@ module.exports = { expired: "#DAF0FF", transferred: "#8BC34A", transferring: "#795548", + rejected: "#F25F5F", }, }, }, @@ -107,5 +109,8 @@ module.exports = { "border-status-expired", "border-status-transferred", "border-status-transferring", + "bg-status-rejected", + "text-status-rejected", + "border-status-rejected", ], };