Block create-list flow when no stores exist
Tapping "+ New list" with zero stores now shows a warning toast with an "Add a store" action linking to /stores, instead of opening a form whose required store dropdown would be empty. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -194,12 +194,6 @@ Replace the single free-form instructions textarea with an ordered list of discr
|
||||
- Keep `Instructions` as a migration fallback column, or do a single-step cutover migration?
|
||||
- Should steps support rich text (bold ingredient names, timers) or stay plain text for v1?
|
||||
|
||||
## Lists
|
||||
|
||||
### Block create-list flow when no stores exist
|
||||
- A shopping list requires a `Store` (see `ListSummary.store` and the `newStoreId` state in `lists/+page.svelte`), so the create-list flow shouldn't be available until at least one store exists.
|
||||
- Behavior: if user tries to open the create-list UI (or hits the create-list page directly via URL) with zero stores, surface a `toast.warning()` (or modal) that says "You need to create a store first" with a CTA linking to `/stores`. Don't render the empty/broken create form.
|
||||
|
||||
## Stores
|
||||
|
||||
### Store types / categorization
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<script lang="ts">
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { goto } from '$app/navigation';
|
||||
import { api } from '$lib/api';
|
||||
import { toast } from '$lib/toast.svelte';
|
||||
import { startConnection, stopConnection } from '$lib/signalr';
|
||||
import type { HubConnection } from '@microsoft/signalr';
|
||||
|
||||
@@ -64,6 +66,16 @@
|
||||
await stopConnection();
|
||||
});
|
||||
|
||||
function toggleCreate() {
|
||||
if (!showCreate && stores.length === 0) {
|
||||
toast.warning('You need to create a store first', {
|
||||
action: { label: 'Add a store', onClick: () => goto('/stores') }
|
||||
});
|
||||
return;
|
||||
}
|
||||
showCreate = !showCreate;
|
||||
}
|
||||
|
||||
async function createList() {
|
||||
if (!newName.trim() || !newStoreId) return;
|
||||
await api<{ id: number }>('/api/lists', {
|
||||
@@ -79,7 +91,7 @@
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<h2 class="text-2xl font-bold">Shopping Lists</h2>
|
||||
<button
|
||||
onclick={() => (showCreate = !showCreate)}
|
||||
onclick={toggleCreate}
|
||||
class="rounded-full bg-primary px-4 py-2 text-sm font-semibold text-white"
|
||||
>
|
||||
{showCreate ? 'Cancel' : '+ New list'}
|
||||
|
||||
Reference in New Issue
Block a user