|
1 | 1 | import { VoteStatus } from '@vocdoni/davinci-sdk' |
2 | | -import { AlertTriangle, CheckCircle, Clock, Cpu, Info, Package, RefreshCw, Shield } from 'lucide-react' |
3 | | -import { useEffect, useMemo } from 'react' |
| 2 | +import { AlertTriangle, CheckCircle, Clock, Copy, Cpu, Info, Package, RefreshCw, Shield } from 'lucide-react' |
| 3 | +import { useEffect, useMemo, useState } from 'react' |
4 | 4 | import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '~components/ui/accordion' |
5 | 5 | import { Badge } from '~components/ui/badge' |
6 | 6 | import { Button } from '~components/ui/button' |
@@ -37,6 +37,13 @@ export function VoteProgressTracker({ onVoteAgain, processId, voteId }: VoteProg |
37 | 37 | const { data: voteStatusData, isLoading, error } = useVoteStatus(processId, voteId) |
38 | 38 | const { sequencerNetwork } = useSequencerNetwork() |
39 | 39 | const networkName = getSequencerNetworkName(sequencerNetwork) || 'Ethereum' |
| 40 | + const [copied, setCopied] = useState(false) |
| 41 | + |
| 42 | + const handleCopyVoteId = async () => { |
| 43 | + await navigator.clipboard.writeText(voteId) |
| 44 | + setCopied(true) |
| 45 | + setTimeout(() => setCopied(false), 2000) |
| 46 | + } |
40 | 47 |
|
41 | 48 | const progressSteps: ProgressStep[] = useMemo( |
42 | 49 | () => [ |
@@ -140,6 +147,34 @@ export function VoteProgressTracker({ onVoteAgain, processId, voteId }: VoteProg |
140 | 147 | </AccordionTrigger> |
141 | 148 | <AccordionContent className='px-6 pb-6'> |
142 | 149 | <div className='space-y-6'> |
| 150 | + {/* Vote ID Section */} |
| 151 | + <div className='bg-davinci-soft-neutral/30 p-4 rounded-lg border border-davinci-callout-border'> |
| 152 | + <div className='flex items-center justify-between gap-3'> |
| 153 | + <div className='flex-1 min-w-0'> |
| 154 | + <p className='text-xs font-medium text-davinci-black-alt/70 mb-1'>Vote ID</p> |
| 155 | + <p className='text-sm font-mono text-davinci-black-alt truncate'>{voteId}</p> |
| 156 | + </div> |
| 157 | + <Button |
| 158 | + onClick={handleCopyVoteId} |
| 159 | + variant='outline' |
| 160 | + size='sm' |
| 161 | + className='flex-shrink-0 border-davinci-callout-border' |
| 162 | + > |
| 163 | + {copied ? ( |
| 164 | + <> |
| 165 | + <CheckCircle className='w-3 h-3 mr-1 text-green-600' /> |
| 166 | + <span className='text-green-600'>Copied!</span> |
| 167 | + </> |
| 168 | + ) : ( |
| 169 | + <> |
| 170 | + <Copy className='w-3 h-3 mr-1' /> |
| 171 | + Copy |
| 172 | + </> |
| 173 | + )} |
| 174 | + </Button> |
| 175 | + </div> |
| 176 | + </div> |
| 177 | + |
143 | 178 | {/* Current Status Display */} |
144 | 179 | <div className='flex items-center justify-between'> |
145 | 180 | <div className='flex items-center gap-3'> |
|
0 commit comments