forked from threesigmaxyz/filecoin-plus-frontend
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrefresh-table-actions.tsx
More file actions
71 lines (67 loc) · 2.48 KB
/
refresh-table-actions.tsx
File metadata and controls
71 lines (67 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { MetaAllocatorSignTransactionButton } from '@/components/refresh/MetaAllocatorSignTransactionButton';
import { RkhApproveTransactionButton } from '@/components/refresh/RkhApproveTransactionButton';
import { RkhSignTransactionButton } from '@/components/refresh/RkhSignTransactionButton';
import { createFilfoxMessageUrl } from '@/lib/factories/create-filfox-message-url';
import { Refresh } from '@/types/refresh';
import { Row } from '@tanstack/react-table';
import { Link } from '@/components/ui/link';
import { useAccount } from '@/hooks';
import {
isAllocated,
isGovernanceTeamRole,
isMetaAllocatorRole,
isRkhRole,
isWaitingForGovernanceReview,
isWaitingForMAApprove,
isWaitingForRkhApprove,
isWaitingForRkhSign,
} from './table.utils';
import { RefreshGovernanceReviewButton } from '@/components/governance-review/RefreshGovernanceReviewButton';
import { AccountRole } from '@/types/account';
export const RefreshTableActions = ({ row }: { row: Row<Refresh> }) => {
const { account } = useAccount();
switch (true) {
case isGovernanceTeamRole(account?.role) && isWaitingForGovernanceReview(row):
return <RefreshGovernanceReviewButton refresh={row.original} />;
case isRkhRole(account?.role) && isWaitingForRkhSign(row):
return (
<RkhSignTransactionButton
dataCap={row.original.dataCap}
address={row.original.msigAddress}
actorId={row.original.actorId}
/>
);
case isRkhRole(account?.role) && isWaitingForRkhApprove(row):
return (
<RkhApproveTransactionButton
address={row.original.msigAddress}
transactionId={row.original.rkhPhase?.messageId!}
datacap={row.original.dataCap}
fromAccount={row.original.rkhPhase?.approvals?.at(0) as string}
/>
);
case isMetaAllocatorRole(account?.role) && isWaitingForMAApprove(row):
return (
<MetaAllocatorSignTransactionButton
githubIssueNumber={row.original.githubIssueNumber}
dataCap={row.original.dataCap}
address={row.original.msigAddress}
maAddress={row.original.maAddress}
metapathwayType={row.original.metapathwayType!}
/>
);
case isAllocated(row):
return (
<Link
className="w-[150px]"
variant="filled"
href={createFilfoxMessageUrl(row.original.transactionCid!)}
target="_blank"
>
View on Filfox
</Link>
);
default:
return null;
}
};