| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- import { Form, Head, Link } from '@inertiajs/react';
- import StoreController from '@/actions/App/Http/Controllers/StoreController';
- import Heading from '@/components/heading';
- import InputError from '@/components/input-error';
- import { Button } from '@/components/ui/button';
- import { Input } from '@/components/ui/input';
- import { Label } from '@/components/ui/label';
- import { dashboard } from '@/routes';
- import { create } from '@/routes/stores';
- import type { SelectOption } from '@/types';
-
- const fieldClass =
- 'w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm';
-
- export default function CreateStore({
- categories,
- languages,
- }: {
- categories: SelectOption[];
- languages: SelectOption[];
- }) {
- return (
- <>
- <Head title="Create store" />
-
- <div className="mx-auto w-full max-w-2xl space-y-6 p-4">
- <Heading
- title="Create a store"
- description="Tell us about your brand. The AI will use this to design your store."
- />
-
- <Form {...StoreController.store.form()} className="space-y-6">
- {({ processing, errors }) => (
- <>
- <div className="grid gap-2">
- <Label htmlFor="name">Store name</Label>
- <Input
- id="name"
- name="name"
- required
- maxLength={60}
- autoFocus
- placeholder="e.g. Sambal Nenek"
- />
- <InputError message={errors.name} />
- </div>
-
- <div className="grid gap-6 sm:grid-cols-2">
- <div className="grid gap-2">
- <Label htmlFor="category">Category</Label>
- <select
- id="category"
- name="category"
- required
- defaultValue=""
- className={`${fieldClass} h-9 py-1`}
- >
- <option value="" disabled>
- Choose a category
- </option>
- {categories.map((category) => (
- <option
- key={category.value}
- value={category.value}
- >
- {category.label}
- </option>
- ))}
- </select>
- <InputError message={errors.category} />
- </div>
-
- <div className="grid gap-2">
- <Label htmlFor="language">
- Store language
- </Label>
- <select
- id="language"
- name="language"
- required
- defaultValue={languages[0]?.value}
- className={`${fieldClass} h-9 py-1`}
- >
- {languages.map((language) => (
- <option
- key={language.value}
- value={language.value}
- >
- {language.label}
- </option>
- ))}
- </select>
- <InputError message={errors.language} />
- </div>
- </div>
-
- <div className="grid gap-2">
- <Label htmlFor="description">
- Describe your brand
- </Label>
- <textarea
- id="description"
- name="description"
- required
- rows={5}
- maxLength={1000}
- className={fieldClass}
- placeholder="What do you sell, who is it for, and what feeling should the store give? e.g. Homemade sambal from a family recipe, premium, warm and traditional but modern."
- />
- <p className="text-xs text-muted-foreground">
- The more detail you give, the better the
- design.
- </p>
- <InputError message={errors.description} />
- </div>
-
- <div className="flex items-center gap-3">
- <Button
- disabled={processing}
- data-test="create-store-button"
- >
- Create store
- </Button>
- <Button variant="ghost" asChild>
- <Link href={dashboard()}>Cancel</Link>
- </Button>
- </div>
- </>
- )}
- </Form>
- </div>
- </>
- );
- }
-
- CreateStore.layout = {
- breadcrumbs: [
- {
- title: 'Dashboard',
- href: dashboard(),
- },
- {
- title: 'Create store',
- href: create(),
- },
- ],
- };
|