web_lib

Common web application libraries
git clone https://radroots.dev/git/web_lib.git
Log | Files | Refs | LICENSE

home.svelte (1818B)


      1 <script lang="ts">
      2     import ButtonSimple from "$lib/components/button/button-simple.svelte";
      3     import LayoutPage from "$lib/components/layout/layout-page.svelte";
      4     import LayoutView from "$lib/components/layout/layout-view.svelte";
      5     import NavigationTabs from "$lib/components/navigation/navigation-tabs.svelte";
      6     import PageToolbar from "$lib/components/navigation/page-toolbar.svelte";
      7     import type { LibContext } from "$lib/types/context";
      8     import type { IViewBasis, IViewHomeData } from "$lib/types/views";
      9     import { idb_kv_init_page } from "$lib/utils/keyval";
     10     import { get_context } from "@radroots/apps-lib";
     11 
     12     import { handle_err, type CallbackPromise } from "@radroots/utils";
     13     import { onMount } from "svelte";
     14 
     15     const { ls } = get_context<LibContext>(`lib`);
     16 
     17     let {
     18         basis,
     19     }: {
     20         basis: IViewBasis<{
     21             data?: IViewHomeData;
     22             on_handle_farms: CallbackPromise;
     23             on_handle_products: CallbackPromise;
     24         }>;
     25     } = $props();
     26 
     27     onMount(async () => {
     28         try {
     29             if (!basis.kv_init_prevent) await idb_kv_init_page();
     30         } catch (e) {
     31             handle_err(e, `on_mount`);
     32         }
     33     });
     34 </script>
     35 
     36 {#if basis.data}
     37     {@const { data: basis_data } = basis}
     38     <LayoutView>
     39         <PageToolbar
     40             basis={{
     41                 header: {
     42                     label: `${$ls(`common.general`)}`,
     43                 },
     44             }}
     45         />
     46         <LayoutPage>
     47             <ButtonSimple
     48                 basis={{
     49                     label: `${$ls(`common.farms`)}`,
     50                     callback: async () => {
     51                         await basis.on_handle_farms();
     52                     },
     53                 }}
     54             />
     55         </LayoutPage>
     56     </LayoutView>
     57     <NavigationTabs />
     58 {/if}