import { AccountBase } from "@/app/providers/AccountProvider/AccountProvider"; import { useAccountProvider } from "@/app/providers/AccountProvider/useAccountProvider"; import { Avatar, Box, Flex, Popover, Text } from "@mantine/core"; import { UserAccountSelect } from "../UserAccountSelect/UserAccountSelect"; import { IconPlus } from "@tabler/icons-react"; import { modals } from "@mantine/modals"; import { useNavigate } from "react-router-dom"; import { useState } from "react"; interface DiceDropdownProps { children: React.ReactNode; onClick?: (accountBase: AccountBase) => void; selectedPublicKey?: string; } export function DiceDropdown(props: DiceDropdownProps) { const { allAccounts } = useAccountProvider(); const navigate = useNavigate(); const [opened, setOpened] = useState(false); const createAccount = () => { modals.openConfirmModal({ title: 'Create account', centered: true, children: ( You may be create new account or import existing ), withCloseButton: false, labels: { confirm: 'Create new', cancel: "Import" }, cancelProps: { autoFocus: false, style: { outline: 'none' } }, onCancel: () => { navigate("/exists-seed"); }, onConfirm: () => { navigate("/create-seed"); } }); } return ( setOpened(!opened)}> {props.children} {allAccounts.map((accountBase: AccountBase) => { return ( { if (props.onClick) { props.onClick(accountBase); } setOpened(false); }}>) })} { createAccount(); setOpened(false); }} pl={'xs'} pr={'xs'} pt={10} pb={10} gap={'xs'} align={'center'}> New account ); }