mirror of https://github.com/hykilpikonna/AquaDX
[O] Make confirm callback nullable
parent
917f8476b9
commit
edf5dd133b
|
@ -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>
|
||||
|
|
|
@ -50,7 +50,7 @@ export interface CardSummary {
|
|||
export interface ConfirmProps {
|
||||
title: string
|
||||
message: string
|
||||
confirm: () => void
|
||||
confirm?: () => void
|
||||
cancel?: () => void
|
||||
dangerous?: boolean
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue