fix: warning noti
change: add loading to overview recipe Signed-off-by: pakintada@gmail.com <Pakin>
This commit is contained in:
parent
ee57dd1163
commit
3388eca2fe
2 changed files with 30 additions and 1 deletions
|
|
@ -28,6 +28,7 @@ export function getNotification() {
|
||||||
toast.warning('Warning', {
|
toast.warning('Warning', {
|
||||||
description: msg
|
description: msg
|
||||||
});
|
});
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
toast(msg);
|
toast(msg);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
import Button from '$lib/components/ui/button/button.svelte';
|
import Button from '$lib/components/ui/button/button.svelte';
|
||||||
import Input from '$lib/components/ui/input/input.svelte';
|
import Input from '$lib/components/ui/input/input.svelte';
|
||||||
import { SearchIcon } from '@lucide/svelte/icons';
|
import { SearchIcon } from '@lucide/svelte/icons';
|
||||||
|
import Spinner from '$lib/components/ui/spinner/spinner.svelte';
|
||||||
|
|
||||||
import DataTable from './data-table.svelte';
|
import DataTable from './data-table.svelte';
|
||||||
import { columns, type RecipeOverview } from './columns';
|
import { columns, type RecipeOverview } from './columns';
|
||||||
|
|
@ -10,6 +11,7 @@
|
||||||
loadRecipe,
|
loadRecipe,
|
||||||
recipeData,
|
recipeData,
|
||||||
recipeFromServerQuery,
|
recipeFromServerQuery,
|
||||||
|
recipeLoading,
|
||||||
recipeOverviewData,
|
recipeOverviewData,
|
||||||
referenceFromPage
|
referenceFromPage
|
||||||
} from '$lib/core/stores/recipeStore.js';
|
} from '$lib/core/stores/recipeStore.js';
|
||||||
|
|
@ -23,6 +25,8 @@
|
||||||
recipes: []
|
recipes: []
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let isRecipeLoading = $state(false);
|
||||||
|
|
||||||
let unsubRecipeData = recipeOverviewData.subscribe((rd) => {
|
let unsubRecipeData = recipeOverviewData.subscribe((rd) => {
|
||||||
if (rd) {
|
if (rd) {
|
||||||
data.recipes = rd == null ? [] : rd;
|
data.recipes = rd == null ? [] : rd;
|
||||||
|
|
@ -40,6 +44,23 @@
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
unsubRecipeData();
|
unsubRecipeData();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
const recipeFetchInterval = setInterval(async () => {
|
||||||
|
// schedule check if recipe is empty
|
||||||
|
if (data.recipes.length == 0) {
|
||||||
|
console.log('loading recipe ....');
|
||||||
|
recipeLoading.set(true);
|
||||||
|
// empty
|
||||||
|
await getRecipes();
|
||||||
|
|
||||||
|
setTimeout(() => recipeLoading.set(false), 3000);
|
||||||
|
}
|
||||||
|
}, 30000);
|
||||||
|
return () => {
|
||||||
|
clearInterval(recipeFetchInterval);
|
||||||
|
};
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="mx-8 flex">
|
<div class="mx-8 flex">
|
||||||
|
|
@ -66,7 +87,14 @@
|
||||||
<!-- table -->
|
<!-- table -->
|
||||||
|
|
||||||
<div class="w-full overflow-auto">
|
<div class="w-full overflow-auto">
|
||||||
<DataTable data={data.recipes} refPage="overview" {columns} />
|
{#if $recipeLoading}
|
||||||
|
<div class="flex items-center justify-center">
|
||||||
|
<p class="mx-4">Please wait</p>
|
||||||
|
<Spinner />
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<DataTable data={data.recipes} refPage="overview" {columns} />
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue