app

Local-first trade for farms and co-ops
git clone https://radroots.dev/git/app.git
Log | Files | Refs | README | LICENSE

+page.svelte (1101B)


      1 <script lang="ts">
      2   import SearchForm from '../lib/components/SearchForm.svelte';
      3   import PageHeading from '../lib/components/primitives/PageHeading.svelte';
      4   import {
      5     normalizePublicQuery,
      6     queryErrorMessage
      7   } from '../lib/catalog/query-input';
      8   import { searchHref } from '../lib/routes';
      9   import { internalHref } from '../lib/navigation-url';
     10   let error = $state<string | undefined>();
     11   function search(input: string) {
     12     const query = normalizePublicQuery(input);
     13     if (!query.ok) {
     14       error = queryErrorMessage(query.error);
     15       return;
     16     }
     17     error = undefined;
     18     const target = internalHref(searchHref(query.text));
     19     if (target === undefined) {
     20       error = queryErrorMessage('invalid_query');
     21       return;
     22     }
     23     globalThis.location.assign(target);
     24   }
     25 </script>
     26 
     27 <svelte:head>
     28   <title>HarvestCircle</title>
     29 </svelte:head>
     30 
     31 <div class="page page--reading stack">
     32   <PageHeading
     33     title="Find food"
     34     description="Browse without connecting. Connect when you want to list food or send a message."
     35   />
     36   <SearchForm onsubmit={search} {error} />
     37 </div>