@@ -20,6 +20,57 @@ const props = defineProps({
2020})
2121
2222const expand = ref ([" inactive" , " active" ].includes (props .proposal .status ))
23+
24+ const getStartDate = () => {
25+ let timeToFormat = null
26+
27+ if ([" inactive" , " applied" , " rejected" , " removed" ].includes (props .proposal .status )) {
28+ timeToFormat = props .proposal .created_at
29+ } else if (props .proposal .status === " active" ) {
30+ timeToFormat = props .proposal .activation_time
31+ }
32+
33+ return DateTime .fromISO (timeToFormat).setLocale (" en" ).toLocaleString (DateTime .DATE_MED )
34+ }
35+ const getEndDate = () => {
36+ let timeToFormat = null
37+
38+ if ([" inactive" , " removed" ].includes (props .proposal .status )) {
39+ timeToFormat = props .proposal .deposit_time
40+ } else if ([" applied" , " rejected" , " active" ].includes (props .proposal .status )) {
41+ timeToFormat = props .proposal .end_time
42+ }
43+
44+ return DateTime .fromISO (timeToFormat).setLocale (" en" ).toLocaleString (DateTime .DATE_MED )
45+ }
46+
47+ const getTimelineDuration = () => {
48+ let timeToFormat = null
49+ let timeDiffToFormat = null
50+
51+ if ([" inactive" , " applied" , " rejected" , " removed" ].includes (props .proposal .status )) {
52+ timeDiffToFormat = props .proposal .created_at
53+ } else if (props .proposal .status === " active" ) {
54+ timeDiffToFormat = props .proposal .activation_time
55+ }
56+
57+ if ([" inactive" , " removed" ].includes (props .proposal .status )) {
58+ timeToFormat = props .proposal .deposit_time
59+ } else if ([" applied" , " rejected" , " active" ].includes (props .proposal .status )) {
60+ timeToFormat = props .proposal .end_time
61+ }
62+
63+ return DateTime .fromISO (timeToFormat).diff (DateTime .fromISO (timeDiffToFormat), " days" ).toObject ().days .toFixed (0 )
64+ }
65+
66+ const getStartLabel = () => {
67+ if ([" inactive" , " removed" ].includes (props .proposal .status )) return " Created at"
68+ if ([" active" , " applied" , " rejected" ].includes (props .proposal .status )) return " Voting start"
69+ }
70+ const getEndLabel = () => {
71+ if ([" inactive" , " removed" ].includes (props .proposal .status )) return " Deposit end"
72+ if ([" active" , " applied" , " rejected" ].includes (props .proposal .status )) return " Voting end"
73+ }
2374 </script >
2475
2576<template >
@@ -33,63 +84,57 @@ const expand = ref(["inactive", "active"].includes(props.proposal.status))
3384 <Badge >
3485 <Flex align =" center" justify =" between" wide >
3586 <Text size =" 12" weight =" 600" color =" secondary" >
36- {{ DateTime.fromISO(proposal.activation_time).setLocale("en").toLocaleString(DateTime.DATE_MED ) }}
87+ {{ getStartDate( ) }}
3788 </Text >
3889
3990 <div v-for =" dot in 4" class =" dot" />
4091
4192 <Flex align =" center" gap =" 6" >
4293 <Icon name =" time" size =" 12" color =" secondary" />
43- <Text size =" 12" weight =" 600" color =" primary" >
44- {{
45- DateTime.fromISO(proposal.end_time)
46- .diff(DateTime.fromISO(proposal.activation_time), "days")
47- .toObject()
48- .days.toFixed(0)
49- }}
50- Days
94+ <Text size =" 12" weight =" 600" color =" secondary" >
95+ {{ getTimelineDuration() }}
96+ day<template v-if =" getTimelineDuration () > 1 " >s</template >
5197 </Text >
5298 </Flex >
5399
54100 <div v-for =" dot in 4" class =" dot" />
55101
56102 <Text size =" 12" weight =" 600" color =" secondary" align =" right" >
57- {{
58- DateTime.fromISO(proposal.end_time)
59-
60- .setLocale("en")
61- .toLocaleString(DateTime.DATE_MED)
62- }}
103+ {{ getEndDate() }}
63104 </Text >
64105 </Flex >
65106 </Badge >
66107
67108 <Flex align =" center" justify =" between" >
68- <Text size =" 12" weight =" 600" color =" tertiary" >Voting Start </Text >
69- <Text size =" 12" weight =" 600" color =" tertiary" >Voting End </Text >
109+ <Text size =" 12" weight =" 600" color =" tertiary" >{{ getStartLabel() }} </Text >
110+ <Text size =" 12" weight =" 600" color =" tertiary" >{{ getEndLabel() }} </Text >
70111 </Flex >
71112
72113 <template v-if =" expand " >
73114 <Flex direction =" column" gap =" 16" :class =" $style.timeline" >
74115 <Flex gap =" 12" >
75116 <div :class =" $style.circle" />
76-
77117 <Flex direction =" column" gap =" 8" >
78- <Text size =" 13" weight =" 600" color =" secondary" >Proposal submitted </Text >
118+ <Text size =" 13" weight =" 600" color =" secondary" >Created at </Text >
79119 <Text size =" 12" weight =" 500" color =" tertiary" >{{ DateTime.fromISO(proposal.created_at).toFormat("FF") }}</Text >
80120 </Flex >
81121 </Flex >
82- <Flex gap =" 12" >
122+ <Flex v-if =" ['removed', 'inactive'].includes(proposal.status)" gap =" 12" >
123+ <div :class =" $style.circle" />
124+ <Flex direction =" column" gap =" 8" >
125+ <Text size =" 13" weight =" 600" color =" secondary" >Deposit end</Text >
126+ <Text size =" 12" weight =" 500" color =" tertiary" >{{ DateTime.fromISO(proposal.deposit_time).toFormat("FF") }}</Text >
127+ </Flex >
128+ </Flex >
129+ <Flex v-if =" ['active', 'applied', 'rejected'].includes(proposal.status)" gap =" 12" >
83130 <div :class =" $style.circle" />
84-
85131 <Flex direction =" column" gap =" 8" >
86132 <Text size =" 13" weight =" 600" color =" secondary" >Voting started</Text >
87133 <Text size =" 12" weight =" 500" color =" tertiary" >{{ DateTime.fromISO(proposal.activation_time).toFormat("FF") }}</Text >
88134 </Flex >
89135 </Flex >
90- <Flex gap =" 12" >
136+ <Flex v-if = " ['active', 'applied', 'rejected'].includes(proposal.status) " gap =" 12" >
91137 <div :class =" $style.circle" />
92-
93138 <Flex direction =" column" gap =" 8" >
94139 <Text size =" 13" weight =" 600" color =" secondary" >End of voting</Text >
95140 <Text size =" 12" weight =" 500" color =" tertiary" >
0 commit comments