import { Trans } from "@lingui-solid/solid/macro"; import { useMutation } from "@tanstack/solid-query"; import { useClient } from "@revolt/client"; import { Dialog, DialogProps } from "@revolt/ui"; import { useModals } from ".."; import { Modals } from "../types"; /** * Modal to delete a bot */ export function DeleteBotModal( props: DialogProps & Modals & { type: "delete_bot" }, ) { const client = useClient(); const { showError, mfaFlow } = useModals(); const deleteBot = useMutation(() => ({ mutationFn: async () => { const mfa = await client().account.mfa(); await mfaFlow(mfa as never); await props.bot.delete(); // TODO: should use ticket in API }, onError: showError, })); return ( Delete {props.bot.user!.displayName}?} actions={[ { text: Cancel }, { text: Delete, onClick: () => deleteBot.mutateAsync(), }, ]} isDisabled={deleteBot.isPending} > Once it's deleted, there's no going back. ); }