feat: add collaborative shopping lists with items and invitations
Some checks failed
CI / Verify (push) Has been cancelled

API: lists, items and invitations modules (list, create, get, update,
set-primary, items create/list, invitation create/accept/list-pending),
BetterAuth session helper, list membership, mailer and Prisma schema plus
migrations.

Web: lists overview, list detail (items) and list management (settings)
views, item and invitation forms/hooks, sign-up and invitation accept pages.

Shared: shopping list DTOs.

Tooling: ignore the generated TanStack Router cache (apps/web/.tanstack).
This commit is contained in:
Jose Selesan
2026-10-16 10:12:11 -03:00
parent 964a3c7217
commit 6aa86a3b68
81 changed files with 3476 additions and 269 deletions

View File

@@ -0,0 +1,55 @@
import { zodResolver } from '@hookform/resolvers/zod'
import { PlusIcon } from 'lucide-react'
import { useForm } from 'react-hook-form'
import { z } from 'zod'
import { Button } from '@/components/ui/button'
import { Field, FieldError } from '@/components/ui/field'
import { Input } from '@/components/ui/input'
import { useCreateItem } from '@/hooks/use-items'
const createItemSchema = z.object({
name: z.string().trim().min(1, 'Escribe un artículo').max(120, 'Máximo 120 caracteres'),
})
type CreateItemValues = z.infer<typeof createItemSchema>
type CreateItemFormProps = {
listId: string
/** Focus the input when the form mounts, so the user can type right away. */
autoFocus?: boolean
}
/** Input to add an item to a list. Submits with Enter or the button. */
export function CreateItemForm({ listId, autoFocus = false }: CreateItemFormProps) {
const createItem = useCreateItem(listId)
const form = useForm<CreateItemValues>({
resolver: zodResolver(createItemSchema),
defaultValues: { name: '' },
})
const onSubmit = form.handleSubmit((values) => {
createItem.mutate(values, { onSuccess: () => form.reset() })
})
return (
<form onSubmit={onSubmit} className="flex items-start gap-2">
<Field className="flex-1" data-invalid={!!form.formState.errors.name}>
<Input
aria-label="Nuevo artículo"
autoComplete="off"
placeholder="Añade un artículo…"
autoFocus={autoFocus}
{...form.register('name')}
/>
<FieldError errors={[form.formState.errors.name]} />
</Field>
<Button type="submit" disabled={createItem.isPending}>
<PlusIcon />
{createItem.isPending ? 'Agregando…' : 'Agregar'}
</Button>
</form>
)
}