@@ -14,7 +14,6 @@ import { cn } from "@/common/ui/utils";
14
14
import { VotingRoundVoteRow } from "./VoteRow" ;
15
15
import { VotingRoundWinnerRow } from "./WinnerRow" ;
16
16
import { useVotingRoundResults } from "../hooks/results" ;
17
- import { sortByAccumulatedWeight } from "../utils/weight" ;
18
17
19
18
export type VotingRoundResultsTableProps = ByPotId & { } ;
20
19
@@ -26,63 +25,65 @@ export const VotingRoundResultsTable: React.FC<VotingRoundResultsTableProps> = (
26
25
( ) =>
27
26
roundResults . data === undefined
28
27
? null
29
- : sortByAccumulatedWeight ( values ( roundResults . data . winners ) , "desc" ) . map (
30
- ( winner , index ) => (
31
- < AccordionItem key = { winner . accountId } value = { winner . accountId } >
32
- < AccordionTrigger
33
- className = { cn ( "py-0 underline-offset-4 hover:bg-[#FEF6EE]" , {
34
- "bg-neutral-50/40" : expandedRows . includes ( winner . accountId ) ,
35
- } ) }
28
+ : values ( roundResults . data . winners ) . map ( ( winner ) => (
29
+ < AccordionItem
30
+ key = { winner . accountId }
31
+ value = { winner . accountId }
32
+ style = { { order : winner . rank } }
33
+ >
34
+ < AccordionTrigger
35
+ className = { cn ( "py-0 underline-offset-4 hover:bg-[#FEF6EE]" , {
36
+ "bg-neutral-50/40" : expandedRows . includes ( winner . accountId ) ,
37
+ } ) }
38
+ >
39
+ < VotingRoundWinnerRow key = { winner . accountId } data = { winner } rank = { winner . rank } />
40
+ </ AccordionTrigger >
41
+
42
+ < AccordionContent className = "gap-3 bg-neutral-50/40 px-6 pt-3" >
43
+ < div
44
+ className = { cn (
45
+ "flex justify-between text-nowrap rounded-lg" ,
46
+ "bg-neutral-50 text-xs text-neutral-500" ,
47
+ ) }
36
48
>
37
- < VotingRoundWinnerRow key = { winner . accountId } data = { winner } rank = { index + 1 } />
38
- </ AccordionTrigger >
39
-
40
- < AccordionContent className = "gap-3 bg-neutral-50/40 px-6 pt-3" >
41
49
< div
42
- className = { cn (
43
- "flex justify-between text-nowrap rounded-lg" ,
44
- "bg-neutral-50 text-xs text-neutral-500" ,
45
- ) }
50
+ className = { "mr-a inline-flex h-10 items-center justify-start gap-2 px-4 py-2" }
46
51
>
47
- < div
48
- className = { "mr-a inline-flex h-10 items-center justify-start gap-2 px-4 py-2" }
49
- >
50
- < span className = "font-600 uppercase leading-none" > { "Voters" } </ span >
52
+ < span className = "font-600 uppercase leading-none" > { "Voters" } </ span >
53
+ </ div >
54
+
55
+ < div className = "hidden md:flex" >
56
+ < div className = "flex h-10 items-center px-4 py-2" >
57
+ < span className = "font-600 w-80 text-end uppercase leading-none" >
58
+ { "Weight amplifiers" }
59
+ </ span >
51
60
</ div >
52
61
53
- < div className = "hidden md:flex" >
54
- < div className = "flex h-10 items-center px-4 py-2" >
55
- < span className = "font-600 w-80 text-end uppercase leading-none" >
56
- { "Weight amplifiers" }
57
- </ span >
58
- </ div >
59
-
60
- < div className = "flex h-10 items-center px-4 py-2" >
61
- < span className = "font-600 w-14 text-end uppercase leading-none" >
62
- { "Weight" }
63
- </ span >
64
- </ div >
65
-
66
- < span className = "flex h-10 items-center px-4 py-2" >
67
- < span className = "w-50 font-600 text-end uppercase leading-none" >
68
- { "Timestamp" }
69
- </ span >
62
+ < div className = "flex h-10 items-center px-4 py-2" >
63
+ < span className = "font-600 w-14 text-end uppercase leading-none" >
64
+ { "Weight" }
70
65
</ span >
71
66
</ div >
72
- </ div >
73
67
74
- { winner . votes . map ( ( vote ) => (
75
- < VotingRoundVoteRow
76
- key = { vote . timestamp + vote . voter }
77
- compact
78
- data = { vote }
79
- { ...{ potId } }
80
- />
81
- ) ) }
82
- </ AccordionContent >
83
- </ AccordionItem >
84
- ) ,
85
- ) ,
68
+ < span className = "flex h-10 items-center px-4 py-2" >
69
+ < span className = "w-50 font-600 text-end uppercase leading-none" >
70
+ { "Timestamp" }
71
+ </ span >
72
+ </ span >
73
+ </ div >
74
+ </ div >
75
+
76
+ { winner . votes . map ( ( vote ) => (
77
+ < VotingRoundVoteRow
78
+ key = { vote . timestamp + vote . voter }
79
+ compact
80
+ data = { vote }
81
+ { ...{ potId } }
82
+ />
83
+ ) ) }
84
+ </ AccordionContent >
85
+ </ AccordionItem >
86
+ ) ) ,
86
87
87
88
[ expandedRows , potId , roundResults . data ] ,
88
89
) ;
0 commit comments