Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(frontend): formCancelAction prop for BtcSendTokenWizard #2757

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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