From a8415cf782f53294662a888ddec7cc48264edeeb Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Thu, 25 Jul 2024 22:09:05 +0200 Subject: [PATCH] ui fixes --- .../stock-screener/[strategyId]/+page.svelte | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/routes/stock-screener/[strategyId]/+page.svelte b/src/routes/stock-screener/[strategyId]/+page.svelte index 69fa2e5b..0a2eb5f9 100644 --- a/src/routes/stock-screener/[strategyId]/+page.svelte +++ b/src/routes/stock-screener/[strategyId]/+page.svelte @@ -426,7 +426,9 @@ async function handleRule(newRule) { toast.success('Rule added', { style: 'border-radius: 200px; background: #333; color: #fff;' }); + await updateStockScreenerData(); + await handleSave(false); } } @@ -452,16 +454,17 @@ async function updateStockScreenerData() { } -function handleResetAll() { +async function handleResetAll() { ruleOfList = []; ruleOfList = [...ruleOfList]; ruleName = ''; filteredData = []; displayResults = []; + await handleSave(false); } -function handleDeleteRule(state) { +async function handleDeleteRule(state) { for (let i = 0; i < ruleOfList.length; i++) { if (ruleOfList[i].name === state) { ruleOfList.splice(i, 1); // Remove the element at index i from the ruleOfList @@ -480,6 +483,8 @@ function handleDeleteRule(state) { { ruleName = ''; } + + await handleSave(false); } @@ -517,7 +522,7 @@ onMount(async () => { -async function handleSave(state:string) { +async function handleSave(printToast) { if(data?.user) { if(isSaved === false) @@ -535,13 +540,16 @@ async function handleSave(state:string) { const output = (await response.json())?.items - if (output?.id && output?.id?.length !== 0) { - toast.success('Strategy saved!', { - style: 'border-radius: 200px; background: #333; color: #fff;'}); - } else { - toast.error('Something went wrong. Please try again later!', { - style: 'border-radius: 200px; background: #333; color: #fff;'}); + if (printToast === true) { + if (output?.id && output?.id?.length !== 0) { + toast.success('Strategy saved!', { + style: 'border-radius: 200px; background: #333; color: #fff;'}); + } else { + toast.error('Something went wrong. Please try again later!', { + style: 'border-radius: 200px; background: #333; color: #fff;'}); + } } + isSaved = true; } else { @@ -880,7 +888,7 @@ $: charNumber = $screenWidth < 640 ? 20 : 40; Build Strategy -