dangerous delete
This commit is contained in:
parent
8a5c3da385
commit
d5e2312dd6
3 changed files with 22 additions and 4 deletions
|
|
@ -72,7 +72,7 @@
|
||||||
--muted-foreground: oklch(0.794 0.0372 307.1032);
|
--muted-foreground: oklch(0.794 0.0372 307.1032);
|
||||||
--accent: oklch(0.3649 0.0508 308.4911);
|
--accent: oklch(0.3649 0.0508 308.4911);
|
||||||
--accent-foreground: oklch(0.9647 0.0091 341.8035);
|
--accent-foreground: oklch(0.9647 0.0091 341.8035);
|
||||||
--destructive: oklch(0.2258 0.0524 12.6119);
|
--destructive: oklch(0.5248 0.1368 20.8317);
|
||||||
--destructive-foreground: oklch(1 0 0);
|
--destructive-foreground: oklch(1 0 0);
|
||||||
--border: oklch(0.3286 0.0154 343.4461);
|
--border: oklch(0.3286 0.0154 343.4461);
|
||||||
--input: oklch(0.3387 0.0195 332.8347);
|
--input: oklch(0.3387 0.0195 332.8347);
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@
|
||||||
<Input id="name" name="name" placeholder="My Rule" required />
|
<Input id="name" name="name" placeholder="My Rule" required />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
<Label for="attach">Attach</Label>
|
<Label for="attach">Rule Type</Label>
|
||||||
<select
|
<select
|
||||||
id="attach"
|
id="attach"
|
||||||
name="attach"
|
name="attach"
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
import { session } from '$lib/state/session.svelte';
|
import { session } from '$lib/state/session.svelte';
|
||||||
import { LocalToasts } from '$lib/builders/local-toasts.svelte';
|
import { LocalToasts } from '$lib/builders/local-toasts.svelte';
|
||||||
import { ResultAsync } from 'neverthrow';
|
import { ResultAsync } from 'neverthrow';
|
||||||
|
import TrashIcon from '~icons/lucide/trash';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
rule: Doc<'user_rules'>;
|
rule: Doc<'user_rules'>;
|
||||||
|
|
@ -21,6 +22,7 @@
|
||||||
const client = useConvexClient();
|
const client = useConvexClient();
|
||||||
|
|
||||||
let updating = $state(false);
|
let updating = $state(false);
|
||||||
|
let deleting = $state(false);
|
||||||
|
|
||||||
const toasts = new LocalToasts({ id });
|
const toasts = new LocalToasts({ id });
|
||||||
|
|
||||||
|
|
@ -53,15 +55,31 @@
|
||||||
|
|
||||||
updating = false;
|
updating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function deleteRule() {
|
||||||
|
deleting = true;
|
||||||
|
|
||||||
|
await client.mutation(api.user_rules.remove, {
|
||||||
|
ruleId: rule._id,
|
||||||
|
sessionToken: session.current?.session.token ?? '',
|
||||||
|
});
|
||||||
|
|
||||||
|
deleting = false;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Card.Root>
|
<Card.Root>
|
||||||
<Card.Header>
|
<Card.Header>
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
<Card.Title>{rule.name}</Card.Title>
|
<Card.Title>{rule.name}</Card.Title>
|
||||||
|
<Button variant="destructive" size="icon" onclick={deleteRule} disabled={deleting}>
|
||||||
|
<TrashIcon class="size-4" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
</Card.Header>
|
</Card.Header>
|
||||||
<Card.Content tag="form" onsubmit={updateRule}>
|
<Card.Content tag="form" onsubmit={updateRule}>
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
<Label for="attach">Attach</Label>
|
<Label for="attach">Rule Type</Label>
|
||||||
<select
|
<select
|
||||||
id="attach"
|
id="attach"
|
||||||
name="attach"
|
name="attach"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue