@fortawesome/free-solid-svg-icons#faIdBadge TypeScript Examples

The following examples show how to use @fortawesome/free-solid-svg-icons#faIdBadge. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SettingsMysteriumId.tsx    From mysterium-vpn-desktop with MIT License 4 votes vote down vote up
SettingsMysteriumId: React.FC = observer(function SettingsMysteriumId() {
    const { payment, identity } = useStores()

    // Export
    const [exportPrompt, setExportPrompt] = useState(false)
    const handleExportInitiate = () => {
        setExportPrompt(true)
    }

    const handleExportSubmit = ({ passphrase }: ExportIdentityFormFields) => {
        setExportPrompt(false)
        const res = identity.exportIdentity({ id: identity.identity?.id ?? "", passphrase })
        toast.promise(res, {
            loading: "Creating backup...",
            success: function successToast(filename) {
                return (
                    <span>
                        <b>Identity backed up!</b>
                        <br />
                        {filename}
                    </span>
                )
            },
            error: function errorToast(reason) {
                return (
                    <span>
                        <b>Identity backup failed ?</b>
                        <br />
                        Error: {reason}
                    </span>
                )
            },
        })
    }
    const handleExportCancel = () => {
        setExportPrompt(false)
    }

    // Import
    const [importPrompt, setImportPrompt] = useState(false)
    const [importFilename, setImportFilename] = useState("")
    const handleImportInitiate = async () => {
        const filename = await identity.importIdentityChooseFile()
        if (!filename) {
            return
        }
        setImportFilename(filename)
        setImportPrompt(true)
    }
    const handleImportSubmit = async ({ passphrase }: ImportIdentityFormFields) => {
        setImportPrompt(false)
        const res = identity.importIdentity({ filename: importFilename, passphrase })
        toast.promise(res, {
            loading: "Importing identity...",
            success: function successToast() {
                return (
                    <span>
                        <b>Mysterium ID imported!</b>
                    </span>
                )
            },
            error: function errorToast(reason) {
                return (
                    <span>
                        <b>Mysterium ID import failed ?</b>
                        <br />
                        Error: {reason}
                    </span>
                )
            },
        })
    }
    const handleImportCancel = () => {
        setImportPrompt(false)
    }

    return (
        <>
            <Section>
                <SectionIcon icon={faIdBadge} color="#ffffff88" size="2x" />
                <Title>Identity ({identity.identity?.registrationStatus})</Title>
                <Explanation>
                    Identity is your Mysterium internal user ID. Never send ether or any kind of ERC20 tokens there.
                </Explanation>
                <TextInput disabled value={identity.identity?.id} />
            </Section>
            <Section>
                <SectionIcon icon={faFileExport} color="#ffffff88" size="2x" />
                <Title>Backup/Restore</Title>
                <Explanation>
                    We don&apos;t store any account data. Make sure to back up your private key to keep your{" "}
                    {payment.appCurrency}s safe.
                </Explanation>
                <div>
                    <LightButton style={{ marginRight: 20 }} onClick={handleExportInitiate}>
                        Backup
                    </LightButton>
                    <LightButton onClick={handleImportInitiate}>Restore from backup</LightButton>
                </div>
            </Section>
            <ExportIdentityPrompt visible={exportPrompt} onSubmit={handleExportSubmit} onCancel={handleExportCancel} />
            <ImportIdentityPrompt visible={importPrompt} onSubmit={handleImportSubmit} onCancel={handleImportCancel} />
        </>
    )
})