diff --git a/src/components/Dialog.tsx b/src/components/Dialog.tsx deleted file mode 100644 index e2c78b2..0000000 --- a/src/components/Dialog.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import { Dialog } from "@kobalte/core"; -import { ParentComponent } from "solid-js"; - -import { Button, SmallHeader } from "~/components"; -import { useI18n } from "~/i18n/context"; - -const OVERLAY = "fixed inset-0 z-50 bg-black/50 backdrop-blur-sm"; -const DIALOG_POSITIONER = "fixed inset-0 z-50 flex items-center justify-center"; -const DIALOG_CONTENT = - "w-[80vw] max-w-[400px] p-4 bg-gray/50 backdrop-blur-md shadow-xl rounded-xl border border-white/10"; - -// TODO: implement this like toast so it's just one global confirm and I can call it with `confirm({ title: "Are you sure?", description: "This will delete your node" })` -export const ConfirmDialog: ParentComponent<{ - open: boolean; - loading: boolean; - onCancel: () => void; - onConfirm: () => void; -}> = (props) => { - const i18n = useI18n(); - return ( - - - - - - - - - {i18n.t( - "modals.confirm_dialog.are_you_sure" - )} - - - - - {props.children} - - - {i18n.t("modals.confirm_dialog.cancel")} - - - {i18n.t("modals.confirm_dialog.confirm")} - - - - - - - - ); -}; diff --git a/src/components/NWCBudgetEditor.tsx b/src/components/NWCBudgetEditor.tsx index cb57dab..058be05 100644 --- a/src/components/NWCBudgetEditor.tsx +++ b/src/components/NWCBudgetEditor.tsx @@ -44,7 +44,9 @@ export function NWCBudgetEditor(props: { : false, budget_amount: props.initialProfile?.budget_amount?.toString() || "0", - interval: "Day" + interval: + (props.initialProfile + ?.budget_period as BudgetForm["interval"]) || "Day" }, validate: (values) => { const errors: Record = {}; @@ -107,6 +109,7 @@ export function NWCBudgetEditor(props: { {(field, _fieldProps) => ( ); }; + +export const ConfirmDialog: ParentComponent<{ + open: boolean; + loading: boolean; + onCancel: () => void; + onConfirm: () => void; +}> = (props) => { + const i18n = useI18n(); + return ( + + + + + + + + + {i18n.t( + "modals.confirm_dialog.are_you_sure" + )} + + + + + {props.children} + + + {i18n.t("modals.confirm_dialog.cancel")} + + + {i18n.t("modals.confirm_dialog.confirm")} + + + + + + + + ); +}; diff --git a/src/i18n/en/translations.ts b/src/i18n/en/translations.ts index 7381a78..48775b0 100644 --- a/src/i18n/en/translations.ts +++ b/src/i18n/en/translations.ts @@ -286,7 +286,8 @@ export default { careful: "Be careful where you share this connection! Requests within budget will paid automatically.", spent: "Spent", - remaining: "Remaining" + remaining: "Remaining", + confirm_delete: "Are you sure you want to delete this connection?" }, emergency_kit: { title: "Emergency Kit", diff --git a/src/routes/settings/Connections.tsx b/src/routes/settings/Connections.tsx index 1dfc42f..61527bb 100644 --- a/src/routes/settings/Connections.tsx +++ b/src/routes/settings/Connections.tsx @@ -16,6 +16,7 @@ import { BackLink, Button, Collapser, + ConfirmDialog, DefaultMain, KeyValue, LargeHeader, @@ -93,6 +94,12 @@ function NwcDetails(props: { const i18n = useI18n(); const [state, _actions] = useMegaStore(); + const [confirmOpen, setConfirmOpen] = createSignal(false); + + function confirmDelete() { + setConfirmOpen(true); + } + async function deleteProfile() { try { await state.mutiny_wallet?.delete_nwc_profile(props.profile.index); @@ -138,9 +145,6 @@ function NwcDetails(props: { {props.profile.budget_period} - - - @@ -155,9 +159,17 @@ function NwcDetails(props: { {i18n.t("settings.connections.open_in_primal")} - + {i18n.t("settings.connections.delete_connection")} + setConfirmOpen(false)} + > + {i18n.t("settings.connections.confirm_delete")} + ); }