mirror of
https://github.com/aleksilassila/reiverr.git
synced 2026-04-18 23:53:19 +02:00
feat: Deleting episodes and seasons, work in mm redesign
This commit is contained in:
53
src/lib/components/Dialog/ConfirmDialog.svelte
Normal file
53
src/lib/components/Dialog/ConfirmDialog.svelte
Normal file
@@ -0,0 +1,53 @@
|
||||
<script lang="ts">
|
||||
import Container from '../../../Container.svelte';
|
||||
import Button from '../Button.svelte';
|
||||
import Modal from '../Modal/Modal.svelte';
|
||||
import { modalStack } from '../Modal/modal.store';
|
||||
|
||||
export let modalId: symbol;
|
||||
|
||||
type ActionFn = (() => Promise<any>) | (() => any);
|
||||
export let confirm: ActionFn;
|
||||
export let cancel: ActionFn = () => {};
|
||||
|
||||
let fetching = false;
|
||||
|
||||
function handleAction(actionFn: ActionFn) {
|
||||
const result = actionFn();
|
||||
if (result) {
|
||||
fetching = true;
|
||||
result.then(() => {
|
||||
fetching = false;
|
||||
modalStack.close(modalId);
|
||||
});
|
||||
} else {
|
||||
modalStack.close(modalId);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal {modalId}>
|
||||
<div class="h-full flex items-center justify-center bg-secondary-950/75">
|
||||
<div class="bg-secondary-800 rounded-xl max-w-lg p-16">
|
||||
<div class="text-xl font-semibold tracking-wide mb-2">
|
||||
<slot name="header" />
|
||||
</div>
|
||||
<div class="font-medium text-zinc-300 mb-8">
|
||||
<slot />
|
||||
</div>
|
||||
<Container direction="horizontal" class="flex">
|
||||
<Button
|
||||
type="secondary"
|
||||
inactive={fetching}
|
||||
on:clickOrSelect={() => handleAction(confirm)}
|
||||
class="mr-4"
|
||||
>
|
||||
Confirm
|
||||
</Button>
|
||||
<Button type="secondary" inactive={fetching} on:clickOrSelect={() => handleAction(cancel)}
|
||||
>Cancel</Button
|
||||
>
|
||||
</Container>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
0
src/lib/components/Dialog/Dialog.ts
Normal file
0
src/lib/components/Dialog/Dialog.ts
Normal file
Reference in New Issue
Block a user