-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
257 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { Button } from '@/components/ui/button' | ||
import { Card } from '@/components/ui/card' | ||
import { Check, Copy, Ellipsis } from 'lucide-react' | ||
import { | ||
Dialog, | ||
DialogContent, | ||
DialogDescription, | ||
DialogHeader, | ||
DialogTrigger, | ||
} from '@/components/ui/dialog' | ||
import { useNavigate } from 'react-router-dom' | ||
import { ellipsisFn } from '@polkadot-ui/utils' | ||
|
||
import copy from 'copy-to-clipboard' | ||
import { useEffect, useState } from 'react' | ||
import { Delegatee } from '@/contexts/DelegateesContext' | ||
|
||
interface Props { | ||
delegatee: Delegatee | ||
} | ||
export const DelegateeCard = ({ delegatee: d }: Props) => { | ||
const [copied, setCopied] = useState<boolean>(false) | ||
const navigate = useNavigate() | ||
|
||
useEffect(() => { | ||
if (copied) { | ||
setTimeout(() => setCopied(false), 1000) | ||
} | ||
}, [copied]) | ||
|
||
const onDelegate = () => { | ||
navigate(`/delegate/${d.address}`) | ||
} | ||
return ( | ||
<Card className="border-2 flex flex-col p-2 mb-5"> | ||
<div className="flex columns-3"> | ||
<div className="p-2 w-[10%]"> | ||
<img className="rounded-3xl" width="100" src={d.image} /> | ||
</div> | ||
<div className="p-2 w-[85%]"> | ||
<div className="font-bold">{d.name}</div> | ||
<div className="">{d.shortDescription}</div> | ||
<Button variant="default" className="mt-2" onClick={onDelegate}> | ||
Delegate | ||
</Button> | ||
</div> | ||
<Dialog> | ||
<DialogTrigger asChild> | ||
<Button | ||
variant={'outline'} | ||
className="text-xs" | ||
onClick={() => console.log('read more')} | ||
> | ||
<Ellipsis className="text-xs" /> | ||
</Button> | ||
</DialogTrigger> | ||
<DialogContent className="sm:max-w-[425px]"> | ||
<DialogHeader> | ||
<div className="font-bold">{d.name}</div> | ||
</DialogHeader> | ||
<DialogDescription className="flex"> | ||
<div>{ellipsisFn(d.address)}</div> | ||
<div className="pl-4 cursor-pointer"> | ||
{copied ? ( | ||
<Check className="text-[green]" /> | ||
) : ( | ||
<Copy | ||
className="cursor-pointer" | ||
onClick={() => { | ||
setCopied(true) | ||
copy(d.address) | ||
}} | ||
/> | ||
)} | ||
</div> | ||
</DialogDescription> | ||
<div className="grid py-4"> | ||
<div className="items-center">{d.longDescription}</div> | ||
</div> | ||
</DialogContent> | ||
</Dialog> | ||
</div> | ||
<div className="w-full"></div> | ||
</Card> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export function convertMiliseconds(miliseconds: number) { | ||
let days = 0 | ||
let hours = 0 | ||
let minutes = 0 | ||
let seconds = 0 | ||
let total_hours = 0 | ||
let total_minutes = 0 | ||
let total_seconds = 0 | ||
|
||
total_seconds = Math.floor(miliseconds / 1000) | ||
total_minutes = Math.floor(total_seconds / 60) | ||
total_hours = Math.floor(total_minutes / 60) | ||
days = Math.floor(total_hours / 24) | ||
|
||
seconds = total_seconds % 60 | ||
minutes = total_minutes % 60 | ||
hours = total_hours % 24 | ||
|
||
return { d: days, h: hours, m: minutes, s: seconds } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.