AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. import { Form, Head, Link } from '@inertiajs/react';
  2. import StoreController from '@/actions/App/Http/Controllers/StoreController';
  3. import Heading from '@/components/heading';
  4. import InputError from '@/components/input-error';
  5. import { Button } from '@/components/ui/button';
  6. import { Input } from '@/components/ui/input';
  7. import { Label } from '@/components/ui/label';
  8. import { dashboard } from '@/routes';
  9. import { create } from '@/routes/stores';
  10. import type { SelectOption } from '@/types';
  11. const fieldClass =
  12. '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';
  13. export default function CreateStore({
  14. categories,
  15. languages,
  16. }: {
  17. categories: SelectOption[];
  18. languages: SelectOption[];
  19. }) {
  20. return (
  21. <>
  22. <Head title="Create store" />
  23. <div className="mx-auto w-full max-w-2xl space-y-6 p-4">
  24. <Heading
  25. title="Create a store"
  26. description="Tell us about your brand. The AI will use this to design your store."
  27. />
  28. <Form {...StoreController.store.form()} className="space-y-6">
  29. {({ processing, errors }) => (
  30. <>
  31. <div className="grid gap-2">
  32. <Label htmlFor="name">Store name</Label>
  33. <Input
  34. id="name"
  35. name="name"
  36. required
  37. maxLength={60}
  38. autoFocus
  39. placeholder="e.g. Sambal Nenek"
  40. />
  41. <InputError message={errors.name} />
  42. </div>
  43. <div className="grid gap-6 sm:grid-cols-2">
  44. <div className="grid gap-2">
  45. <Label htmlFor="category">Category</Label>
  46. <select
  47. id="category"
  48. name="category"
  49. required
  50. defaultValue=""
  51. className={`${fieldClass} h-9 py-1`}
  52. >
  53. <option value="" disabled>
  54. Choose a category
  55. </option>
  56. {categories.map((category) => (
  57. <option
  58. key={category.value}
  59. value={category.value}
  60. >
  61. {category.label}
  62. </option>
  63. ))}
  64. </select>
  65. <InputError message={errors.category} />
  66. </div>
  67. <div className="grid gap-2">
  68. <Label htmlFor="language">
  69. Store language
  70. </Label>
  71. <select
  72. id="language"
  73. name="language"
  74. required
  75. defaultValue={languages[0]?.value}
  76. className={`${fieldClass} h-9 py-1`}
  77. >
  78. {languages.map((language) => (
  79. <option
  80. key={language.value}
  81. value={language.value}
  82. >
  83. {language.label}
  84. </option>
  85. ))}
  86. </select>
  87. <InputError message={errors.language} />
  88. </div>
  89. </div>
  90. <div className="grid gap-2">
  91. <Label htmlFor="description">
  92. Describe your brand
  93. </Label>
  94. <textarea
  95. id="description"
  96. name="description"
  97. required
  98. rows={5}
  99. maxLength={1000}
  100. className={fieldClass}
  101. 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."
  102. />
  103. <p className="text-xs text-muted-foreground">
  104. The more detail you give, the better the
  105. design.
  106. </p>
  107. <InputError message={errors.description} />
  108. </div>
  109. <div className="flex items-center gap-3">
  110. <Button
  111. disabled={processing}
  112. data-test="create-store-button"
  113. >
  114. Create store
  115. </Button>
  116. <Button variant="ghost" asChild>
  117. <Link href={dashboard()}>Cancel</Link>
  118. </Button>
  119. </div>
  120. </>
  121. )}
  122. </Form>
  123. </div>
  124. </>
  125. );
  126. }
  127. CreateStore.layout = {
  128. breadcrumbs: [
  129. {
  130. title: 'Dashboard',
  131. href: dashboard(),
  132. },
  133. {
  134. title: 'Create store',
  135. href: create(),
  136. },
  137. ],
  138. };