From cfb3258133d09a5e01d9078eb3db862a8544bbc8 Mon Sep 17 00:00:00 2001 From: prokawsar Date: Mon, 22 Jul 2024 09:23:32 +0600 Subject: [PATCH 01/10] Seperate save history button --- src/routes/(app)/+page.svelte | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte index 26fc690..849cb6e 100644 --- a/src/routes/(app)/+page.svelte +++ b/src/routes/(app)/+page.svelte @@ -47,11 +47,13 @@ const removePaper = async (idx: string) => { paperCount = paperCount.filter((field) => field.id != idx) + if (perPaperResult.has(idx)) perPaperResult.delete(idx) + perPaperResult = perPaperResult getAllInputs() } const calculatePaperCost = async () => { - if (!paperCount.length || hasNullValue) return + if (hasNullValue) return perPaperResult.clear() finalPrice = 0 paperCount.forEach((paper) => { @@ -62,15 +64,6 @@ }) perPaperResult = perPaperResult - // Saving to history - if ($totalHistoryStore < MAX_HISTORY) { - addHistory({ - name: customer_name, - final_price: finalPrice, - papers: paperCount - }) - $totalHistoryStore = await getTotalHistory() - } // mixpanel data prepare const perPageData: number[] = [] perPaperResult.forEach((data) => { @@ -83,6 +76,17 @@ }) } + const saveHistory = async () => { + if ($totalHistoryStore < MAX_HISTORY) { + addHistory({ + name: customer_name, + final_price: finalPrice, + papers: paperCount + }) + $totalHistoryStore = await getTotalHistory() + } + } + const clearAll = () => { paperCount = [{ ...paperFields, id: makeid(5) }] finalPrice = 0 @@ -109,7 +113,7 @@ paperCount.find((paper) => { return !paper.length || !paper.width || !paper.thickness || !paper.rate }) - + $: showSaveHistory = perPaperResult.size == paperCount.length // Handling and maintaining focused input index $: inputsArray = inputs && Array.from(inputs) $: focusedInputID = $focusedInputStore && $focusedInputStore.getAttribute('id') @@ -156,13 +160,20 @@ Maximum history reached, delete some history!

{/if} -
+
+ {#if showSaveHistory} +
Date: Mon, 22 Jul 2024 18:38:15 +0600 Subject: [PATCH 02/10] Settings ui wip --- src/lib/elements/Input.svelte | 2 +- src/routes/(app)/+layout.svelte | 23 +++++++++++++++++------ src/routes/(app)/+page.svelte | 6 +++++- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/lib/elements/Input.svelte b/src/lib/elements/Input.svelte index 745e8a5..78ce9f3 100644 --- a/src/lib/elements/Input.svelte +++ b/src/lib/elements/Input.svelte @@ -32,6 +32,6 @@ diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte index 7c203ff..397cc52 100644 --- a/src/routes/(app)/+layout.svelte +++ b/src/routes/(app)/+layout.svelte @@ -6,6 +6,7 @@ import { navigating } from '$app/stores' import Loader from '$lib/elements/Loader.svelte' import mixpanel from 'mixpanel-browser' + import { slide } from 'svelte/transition' //Import Mixpanel SDK mixpanel.init(PUBLIC_MIX_TOKEN, { @@ -13,6 +14,8 @@ track_pageview: true, persistence: 'localStorage' }) + + let showSettings = false
@@ -23,13 +26,11 @@
{/if} -