Skip to content

Commit

Permalink
feat(frontend): formCancelAction prop for BtcSendTokenWizard (#2757)
Browse files Browse the repository at this point in the history
# Motivation

Extending BtcSendTokenWizard with an additional prop that tells
component which button should it render - close or back.
  • Loading branch information
DenysKarmazynDFINITY authored Oct 9, 2024
1 parent ab19db9 commit 965e089
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/frontend/src/btc/components/send/BtcSendTokenWizard.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<script lang="ts">
import type { WizardStep } from '@dfinity/gix-components';
import { getContext } from 'svelte';
import { createEventDispatcher, getContext } from 'svelte';
import BtcSendForm from '$btc/components/send/BtcSendForm.svelte';
import BtcSendProgress from '$btc/components/send/BtcSendProgress.svelte';
import BtcSendReview from '$btc/components/send/BtcSendReview.svelte';
import { SEND_CONTEXT_KEY, type SendContext } from '$icp-eth/stores/send.store';
import SendQrCodeScan from '$lib/components/send/SendQRCodeScan.svelte';
import ButtonBack from '$lib/components/ui/ButtonBack.svelte';
import ButtonCancel from '$lib/components/ui/ButtonCancel.svelte';
import {
btcAddressMainnet,
btcAddressRegtest,
Expand All @@ -21,6 +23,7 @@
export let destination = '';
export let amount: number | undefined = undefined;
export let sendProgressStep: string;
export let formCancelAction: 'back' | 'close' = 'close';
let source: string;
$: source =
Expand All @@ -32,6 +35,11 @@
const { sendToken } = getContext<SendContext>(SEND_CONTEXT_KEY);
const dispatch = createEventDispatcher();
const close = () => dispatch('icClose');
const back = () => dispatch('icSendBack');
// TODO: implement send function when related services are ready
const send = () => {};
</script>
Expand All @@ -49,7 +57,15 @@
bind:networkId
on:icQRCodeScan
{source}
/>
>
<svelte:fragment slot="cancel">
{#if formCancelAction === 'back'}
<ButtonBack on:click={back} />
{:else}
<ButtonCancel on:click={close} />
{/if}
</svelte:fragment>
</BtcSendForm>
{:else if currentStep?.name === WizardStepsSend.QR_CODE_SCAN}
<SendQrCodeScan
expectedToken={$sendToken}
Expand Down

0 comments on commit 965e089

Please sign in to comment.