Skip to content

Commit

Permalink
added reject status
Browse files Browse the repository at this point in the history
  • Loading branch information
madhurMongia committed Dec 29, 2024
1 parent 9e4ac1a commit 82a72bd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
9 changes: 7 additions & 2 deletions src/app/[pohid]/[chain]/[request]/ActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ interface ActionBarProps extends JSX.IntrinsicAttributes {
arbitrator: any;
extraData: any;
};
rejected: boolean;
}

export default withClientConnected<ActionBarProps>(function ActionBar({
Expand All @@ -78,6 +79,7 @@ export default withClientConnected<ActionBarProps>(function ActionBar({
// advanceRequestsOnChainVouches,
expired,
arbitrationHistory,
rejected,
}) {
const chain = useChainParam()!;
const { address } = useAccount();
Expand Down Expand Up @@ -302,7 +304,7 @@ export default withClientConnected<ActionBarProps>(function ActionBar({
<span
className={`rounded-full px-3 py-1 text-white bg-status-${statusColor}`}
>
{camelToTitle(status, revocation, expired)}
{camelToTitle(status, revocation, expired,rejected)}
</span>
</div>
<div className="flex w-full flex-col justify-between gap-[12px] font-normal md:flex-row md:items-center">
Expand Down Expand Up @@ -464,6 +466,7 @@ export default withClientConnected<ActionBarProps>(function ActionBar({
currentChallenge.reason.id,
revocation,
expired,
rejected
)}
</strong>
</>
Expand Down Expand Up @@ -500,7 +503,9 @@ export default withClientConnected<ActionBarProps>(function ActionBar({
{status === "resolved" && (
<>
<span>
Request was accepted
{!rejected
? "Request was accepted"
: "Request was rejected"}
<TimeAgo
className={`ml-1 text-status-${statusColor}`}
time={lastStatusChange}
Expand Down
3 changes: 3 additions & 0 deletions src/app/[pohid]/[chain]/[request]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ export default async function Request({ params }: PageProps) {
onChainVouches = request.vouches.map((v) => v.voucher.id as Address);
}

const rejected = request.status.id === "resolved" && !request.humanity.winnerClaim.some(claim => claim.index === request.index);

const hasExpired = () => {
if (request.status.id === "resolved") {
if (!request.revocation && request.humanity.winnerClaim.length > 0) {
Expand Down Expand Up @@ -287,6 +289,7 @@ export default async function Request({ params }: PageProps) {
onChainVouches={onChainVouches}
offChainVouches={offChainVouches}
arbitrationHistory={request.arbitratorHistory}
rejected={rejected}
/>

<div className="border-stroke bg-whiteBackground mb-6 rounded border shadow">
Expand Down
7 changes: 3 additions & 4 deletions src/components/Request/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,12 @@ function Card({
humanity: { id: pohId, winnerClaim },
expired,
}: CardInterface) {
const rejected = status === "resolved" && !winnerClaim.some(claim => claim.index === index);
console.log(rejected);
const statusTitle = queryToStatus(status, revocation, expired);
const statusColor = colorForStatus(status, revocation, expired);

const chain = idToChain(chainId)!;

return (
<Link
href={`/${prettifyId(pohId)}/${chain.name.toLowerCase()}/${index}`}
Expand All @@ -124,9 +125,7 @@ function Card({
<div className={`h-1 w-full bg-status-${statusColor}`} />
<div className="centered p-2 font-medium">
<span className={`text-status-${statusColor}`}>
{status === "resolved" && expired && !revocation
? "Expired"
: camelToTitle(statusTitle, revocation, expired)}
{camelToTitle(statusTitle, revocation, expired,rejected)}
</span>
<span className={`dot ml-2 bg-status-${statusColor}`} />
</div>
Expand Down
9 changes: 8 additions & 1 deletion src/utils/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export const camelToTitle = (
strIn: string,
revocation?: boolean,
expired?: boolean,
rejected?: boolean
) => {
let str: string = strIn;
switch (strIn) {
Expand All @@ -26,7 +27,13 @@ export const camelToTitle = (
break;
case "resolved":
str = strIn;
str = revocation ? "revoked" : expired ? "expired" : "included";
str = revocation
? "revoked"
: rejected
? "rejected"
: expired
? "expired"
: "included";
break;
}
const result = str.replace(/([A-Z])/g, " $1");
Expand Down

0 comments on commit 82a72bd

Please sign in to comment.