From fc16cd4b7d37190a7a395891135e9d16d70af144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?VESSE=20L=C3=A9o?= Date: Wed, 2 Oct 2024 15:12:26 +0200 Subject: [PATCH 1/7] feat(comptoir): reinitialise champ de saisie lors de validation --- .../components/comptoir/transactionPopup.svelte | 14 ++++++++++++++ .../lib/components/comptoir/transactions.svelte | 9 ++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/components/comptoir/transactionPopup.svelte b/frontend/src/lib/components/comptoir/transactionPopup.svelte index 6bd799ea..6db96b23 100644 --- a/frontend/src/lib/components/comptoir/transactionPopup.svelte +++ b/frontend/src/lib/components/comptoir/transactionPopup.svelte @@ -10,8 +10,14 @@ import { api } from '$lib/config/config'; import { transactionsApi } from '$lib/requests/requests'; import { formatPrice } from '$lib/utils'; + import { reset } from '__sveltekit/paths'; import Error from '../error.svelte'; import Success from '../success.svelte'; + import Transactions from './transactions.svelte'; + import { createEventDispatcher } from 'svelte'; + import {searchName} from './transactions.svelte'; + + let searchNameResetValue = null; export let transaction: Transaction; export let close: () => void; @@ -27,6 +33,12 @@ }; let menuPopup: MenuPopup | undefined; + const eventDispatcher = createEventDispatcher(); + + async function handleResetInputField(){ + eventDispatcher('reset') + } + async function cancelTransaction() { let res = await transactionsApi().patchTransactionId( newTransaction.account_id, @@ -101,6 +113,7 @@ success = 'Commande terminée'; setTimeout(() => { success = ''; + searchName.set(''); close(); }, 1500); } @@ -361,6 +374,7 @@ {/each} diff --git a/frontend/src/lib/components/readCard.svelte b/frontend/src/lib/components/readCard.svelte index 8ae94f4b..b8e64209 100644 --- a/frontend/src/lib/components/readCard.svelte +++ b/frontend/src/lib/components/readCard.svelte @@ -1,7 +1,9 @@ - + {#if incorrectPin != ''} @@ -142,3 +154,5 @@ {:else} {/if} + + handleInput(e.key)}/> From e1ac66b3bf85831acb2ee89af6f3493ef3165c66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?VESSE=20L=C3=A9o?= Date: Mon, 7 Oct 2024 18:23:03 +0200 Subject: [PATCH 6/7] =?UTF-8?q?(fix):=20fix=20apr=C3=A8s=20review?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/lib/components/borne/pin.svelte | 59 ++++++-------------- frontend/src/routes/borne/+page.svelte | 5 -- 2 files changed, 18 insertions(+), 46 deletions(-) diff --git a/frontend/src/lib/components/borne/pin.svelte b/frontend/src/lib/components/borne/pin.svelte index 4cc147d1..ed84ab20 100644 --- a/frontend/src/lib/components/borne/pin.svelte +++ b/frontend/src/lib/components/borne/pin.svelte @@ -20,47 +20,24 @@ temp_pin = ''; } - function controlPinWithKbd(k: string) { - switch (k) { - case '1': - enterPin(1); - break; - case '2': - enterPin(2); - break; - case '3': - enterPin(3); - break; - case '4': - enterPin(4); - break; - case '5': - enterPin(5); - break; - case '6': - enterPin(6); - break; - case '7': - enterPin(7); - case '8': - enterPin(8); - break; - case '9': - enterPin(9); - break; - case '0': - enterPin(0); - break; - case 'Backspace': - deletePinChar(); - break; - case 'Enter': - validatePin(); - break; - default: - break; - } - } + function isDigit(k: string): boolean { + return /^\d$/.test(k) +} + +function controlPinWithKbd(k: string) { + if (isDigit(k)) { + enterPin(parseInt(k)); + return + } + switch (k) { + case 'Backspace': + deletePinChar(); + break; + case 'Enter': + validatePin(); + break; + } +} diff --git a/frontend/src/routes/borne/+page.svelte b/frontend/src/routes/borne/+page.svelte index 6d79f0ce..4b013230 100644 --- a/frontend/src/routes/borne/+page.svelte +++ b/frontend/src/routes/borne/+page.svelte @@ -19,10 +19,6 @@ import ReadCard from '$lib/components/readCard.svelte'; import { pinIsShown } from '$lib/store/store'; - function handleInput(e:string){ - console.log(e, $pinIsShown, card.pin); - - } $: $pinIsShown @@ -155,4 +151,3 @@ {/if} - handleInput(e.key)}/> From fa60329359e8fef3159fb2e6da255aac5aa79d32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?VESSE=20L=C3=A9o?= Date: Mon, 14 Oct 2024 09:42:23 +0200 Subject: [PATCH 7/7] (chore): remove debug lines --- frontend/src/lib/components/borne/pin.svelte | 34 +++++++++----------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/frontend/src/lib/components/borne/pin.svelte b/frontend/src/lib/components/borne/pin.svelte index ed84ab20..98319588 100644 --- a/frontend/src/lib/components/borne/pin.svelte +++ b/frontend/src/lib/components/borne/pin.svelte @@ -5,7 +5,6 @@ function enterPin(i: number) { temp_pin += i; if (temp_pin.length === 20) { - console.log('e' + temp_pin); callback(temp_pin); temp_pin = ''; } @@ -21,23 +20,23 @@ } function isDigit(k: string): boolean { - return /^\d$/.test(k) -} + return /^\d$/.test(k); + } -function controlPinWithKbd(k: string) { - if (isDigit(k)) { - enterPin(parseInt(k)); - return - } - switch (k) { - case 'Backspace': - deletePinChar(); - break; - case 'Enter': - validatePin(); - break; - } -} + function controlPinWithKbd(k: string) { + if (isDigit(k)) { + enterPin(parseInt(k)); + return; + } + switch (k) { + case 'Backspace': + deletePinChar(); + break; + case 'Enter': + validatePin(); + break; + } + } @@ -50,7 +49,6 @@ function controlPinWithKbd(k: string) { on:click={() => { temp_pin = ''; callback(''); - console.log('click'); }} />