[O] Make confirm callback nullable

pull/131/head
Azalea 2025-03-20 06:28:28 -04:00
parent 917f8476b9
commit edf5dd133b
2 changed files with 5 additions and 5 deletions

View File

@ -13,9 +13,9 @@
export let error: string | null
export let loading: boolean = false
function doConfirm(fn: () => void) {
function doConfirm(fn?: () => void) {
confirm = null
fn()
fn && fn()
}
</script>
@ -27,9 +27,9 @@
<div class="actions">
{#if confirm.cancel}
<button on:click={() => doConfirm(confirm!!.cancel!!)}>{t('action.cancel')}</button>
<button on:click={() => doConfirm(confirm?.cancel)}>{t('action.cancel')}</button>
{/if}
<button on:click={() => doConfirm(confirm!!.confirm)} class:error={confirm.dangerous}>{t('action.confirm')}</button>
<button on:click={() => doConfirm(confirm?.confirm)} class:error={confirm.dangerous}>{t('action.confirm')}</button>
</div>
</div>
</div>

View File

@ -50,7 +50,7 @@ export interface CardSummary {
export interface ConfirmProps {
title: string
message: string
confirm: () => void
confirm?: () => void
cancel?: () => void
dangerous?: boolean
}