Skip to content

Commit

Permalink
Offline message for save history
Browse files Browse the repository at this point in the history
  • Loading branch information
prokawsar committed Jul 26, 2024
1 parent ff148f6 commit dad6290
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/routes/(app)/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
let inputGroupRef: HTMLDivElement
let focusedIndex = 0
let customer_name = ''
let isSavingHistory = false
const addPaper = async () => {
paperCount.push({ ...paperFields, id: makeid(5) })
Expand Down Expand Up @@ -79,12 +80,20 @@
const saveHistory = async () => {
if ($totalHistoryStore < MAX_HISTORY) {
addHistory({
isSavingHistory = true
const response = await addHistory({
name: customer_name,
final_price: finalPrice,
papers: paperCount
})
if (response && response?.message.indexOf('TypeError') != -1) {
toast.error('Failed to save history, you are offline!')
isSavingHistory = false
return
}
$totalHistoryStore = await getTotalHistory()
isSavingHistory = false
toast.success('Cost details saved successfully')
}
}
Expand Down Expand Up @@ -172,6 +181,7 @@
/>
{#if showSaveHistory}
<Button
disabled={isSavingHistory}
on:click={saveHistory}
text="Save cost"
classNames="text-sm animate-pulse !w-[30%] !px-1"
Expand Down

0 comments on commit dad6290

Please sign in to comment.