forked from Cylo-Traders/Agrocylo-PIP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcampaignStatus.ts
More file actions
109 lines (105 loc) · 3.28 KB
/
Copy pathcampaignStatus.ts
File metadata and controls
109 lines (105 loc) · 3.28 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import type { CampaignStatusTag } from './soroban/types';
export interface StatusMeta {
label: string;
bg: string;
bgLight: string;
text: string;
border: string;
}
/** Tailwind class sets per CampaignStatus, matching the palette in tailwind.config.ts. */
export const STATUS_META: Record<CampaignStatusTag, StatusMeta> = {
Active: {
label: 'Active',
bg: 'bg-status-active',
bgLight: 'bg-status-active-light',
text: 'text-status-active-dark',
border: 'border-status-active/20',
},
Funding: {
label: 'Funding',
bg: 'bg-status-funding',
bgLight: 'bg-status-funding-light',
text: 'text-status-funding-dark',
border: 'border-status-funding/20',
},
Funded: {
label: 'Funded',
bg: 'bg-status-funded',
bgLight: 'bg-status-funded-light',
text: 'text-status-funded-dark',
border: 'border-status-funded/20',
},
InProduction: {
label: 'In Production',
bg: 'bg-status-inproduction',
bgLight: 'bg-status-inproduction-light',
text: 'text-status-inproduction-dark',
border: 'border-status-inproduction/20',
},
Harvested: {
label: 'Harvested',
bg: 'bg-status-harvested',
bgLight: 'bg-status-harvested-light',
text: 'text-status-harvested-dark',
border: 'border-status-harvested/20',
},
Disputed: {
label: 'Disputed',
bg: 'bg-status-disputed',
bgLight: 'bg-status-disputed-light',
text: 'text-status-disputed-dark',
border: 'border-status-disputed/20',
},
Resolved: {
label: 'Resolved',
bg: 'bg-status-resolved',
bgLight: 'bg-status-resolved-light',
text: 'text-status-resolved-dark',
border: 'border-status-resolved/20',
},
Settled: {
label: 'Settled',
bg: 'bg-status-settled',
bgLight: 'bg-status-settled-light',
text: 'text-status-settled-dark',
border: 'border-status-settled/20',
},
Failed: {
label: 'Failed',
bg: 'bg-status-failed',
bgLight: 'bg-status-failed-light',
text: 'text-status-failed-dark',
border: 'border-status-failed/20',
},
};
/**
* The "happy path" lifecycle steps shown in the campaign stepper.
* `statuses` lists every CampaignStatus that maps onto that step — Active and
* Funding both represent the funding phase (a campaign starts Active and
* flips to Funding on its first contribution).
*/
export const LIFECYCLE_STEPS: {
key: string;
label: string;
statuses: CampaignStatusTag[];
}[] = [
{ key: 'funding', label: 'Funding', statuses: ['Active', 'Funding'] },
{ key: 'funded', label: 'Funded', statuses: ['Funded'] },
{ key: 'production', label: 'In Production', statuses: ['InProduction'] },
{ key: 'harvested', label: 'Harvested', statuses: ['Harvested'] },
{ key: 'settled', label: 'Settled', statuses: ['Settled'] },
];
/**
* Index into LIFECYCLE_STEPS the campaign is at (or most recently passed
* through) for statuses that branch off the happy path.
*/
export function lifecycleStepIndex(status: CampaignStatusTag): number {
const direct = LIFECYCLE_STEPS.findIndex((step) =>
step.statuses.includes(status),
);
if (direct !== -1) return direct;
// Disputed/Resolved/Failed can occur from Active, Funding, or Funded — we
// can't tell which without more history, so anchor on "funded" as the
// latest point a dispute/failure could realistically occur from.
return 1;
}