Skip to content

Commit

Permalink
feat: add rejected status handling and update UI components
Browse files Browse the repository at this point in the history
  • Loading branch information
madhurMongia committed Dec 31, 2024
1 parent 82a72bd commit 1d9ceb8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/app/[pohid]/[chain]/[request]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,17 @@ export default async function Request({ params }: PageProps) {
Date.now() / 1000
);
}
} else return true;
return false;
}
return false;
}
} else if (request.status.id === "transferring") {
return (
Number(request.creationTime) + Number(contractData.humanityLifespan) <
Date.now() / 1000
);
}
return true;
return false;
};

const expired = hasExpired();
Expand Down
12 changes: 8 additions & 4 deletions src/components/Request/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -125,7 +125,11 @@ function Card({
<div className={`h-1 w-full bg-status-${statusColor}`} />
<div className="centered p-2 font-medium">
<span className={`text-status-${statusColor}`}>
{camelToTitle(statusTitle, revocation, expired,rejected)}
{status === "resolved" && expired && !revocation
? "Expired"
: rejected
? "Rejected"
: camelToTitle(statusTitle, revocation, expired)}
</span>
<span className={`dot ml-2 bg-status-${statusColor}`} />
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Request/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down
3 changes: 2 additions & 1 deletion src/config/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const colorForStatus = (
status: string,
revocation: boolean,
expired: boolean,
rejected: boolean,
) => {
switch (status) {
case "vouching":
Expand All @@ -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");
}
Expand Down
5 changes: 5 additions & 0 deletions tailwind.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module.exports = {
expired: "#333333",
transferred: "#3F6212",
transferring: "#ba7264",
rejected: "#D90429",
},
},
dark: {
Expand All @@ -54,6 +55,7 @@ module.exports = {
expired: "#DAF0FF",
transferred: "#8BC34A",
transferring: "#795548",
rejected: "#F25F5F",
},
},
},
Expand Down Expand Up @@ -107,5 +109,8 @@ module.exports = {
"border-status-expired",
"border-status-transferred",
"border-status-transferring",
"bg-status-rejected",
"text-status-rejected",
"border-status-rejected",
],
};

0 comments on commit 1d9ceb8

Please sign in to comment.