AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. import { Form, Head } from '@inertiajs/react';
  2. import { ExternalLink, Monitor, Smartphone, Sparkles } from 'lucide-react';
  3. import { useState } from 'react';
  4. import StoreDesignController from '@/actions/App/Http/Controllers/StoreDesignController';
  5. import { Badge } from '@/components/ui/badge';
  6. import { Button } from '@/components/ui/button';
  7. import {
  8. Card,
  9. CardContent,
  10. CardDescription,
  11. CardHeader,
  12. CardTitle,
  13. } from '@/components/ui/card';
  14. import { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group';
  15. import { cn } from '@/lib/utils';
  16. import { dashboard } from '@/routes';
  17. import type { Store } from '@/types';
  18. type Device = 'desktop' | 'mobile';
  19. export default function ShowStore({ store }: { store: Store }) {
  20. const [device, setDevice] = useState<Device>('desktop');
  21. const previewUrl = StoreDesignController.preview.url(store.slug);
  22. return (
  23. <>
  24. <Head title={store.name} />
  25. <div className="mx-auto w-full max-w-6xl space-y-6 p-4">
  26. <div className="flex flex-wrap items-start justify-between gap-3">
  27. <div>
  28. <h1 className="text-xl font-semibold">{store.name}</h1>
  29. <p className="text-sm text-muted-foreground">
  30. {store.category_label} · {store.language_label}
  31. </p>
  32. </div>
  33. <Badge
  34. variant={
  35. store.status === 'published'
  36. ? 'default'
  37. : 'secondary'
  38. }
  39. >
  40. {store.status_label}
  41. </Badge>
  42. </div>
  43. <Card>
  44. <CardHeader>
  45. <CardTitle>Brand description</CardTitle>
  46. <CardDescription>
  47. This is what the AI will use to design your store.
  48. </CardDescription>
  49. </CardHeader>
  50. <CardContent>
  51. <p className="text-sm whitespace-pre-line">
  52. {store.description}
  53. </p>
  54. </CardContent>
  55. </Card>
  56. {store.has_design ? (
  57. <section className="space-y-3">
  58. <div className="flex flex-wrap items-center justify-between gap-3">
  59. <h2 className="font-medium">Store design</h2>
  60. <div className="flex items-center gap-2">
  61. <ToggleGroup
  62. type="single"
  63. variant="outline"
  64. size="sm"
  65. value={device}
  66. onValueChange={(value) => {
  67. if (value) {
  68. setDevice(value as Device);
  69. }
  70. }}
  71. aria-label="Preview size"
  72. >
  73. <ToggleGroupItem
  74. value="desktop"
  75. aria-label="Desktop preview"
  76. >
  77. <Monitor />
  78. </ToggleGroupItem>
  79. <ToggleGroupItem
  80. value="mobile"
  81. aria-label="Mobile preview"
  82. >
  83. <Smartphone />
  84. </ToggleGroupItem>
  85. </ToggleGroup>
  86. <Button variant="outline" size="sm" asChild>
  87. <a
  88. href={previewUrl}
  89. target="_blank"
  90. rel="noreferrer"
  91. >
  92. <ExternalLink />
  93. Open full page
  94. </a>
  95. </Button>
  96. </div>
  97. </div>
  98. <div className="flex justify-center rounded-xl border bg-muted/40 p-3">
  99. <iframe
  100. title={`Preview of ${store.name}`}
  101. src={previewUrl}
  102. className={cn(
  103. 'h-[70vh] min-h-[480px] rounded-lg border bg-white transition-[width]',
  104. device === 'mobile'
  105. ? 'w-[390px] max-w-full'
  106. : 'w-full',
  107. )}
  108. />
  109. </div>
  110. </section>
  111. ) : (
  112. <div className="flex flex-wrap items-center justify-between gap-4 rounded-xl border border-dashed p-6">
  113. <div className="flex items-start gap-3">
  114. <Sparkles className="mt-0.5 size-5 shrink-0 text-muted-foreground" />
  115. <div>
  116. <h2 className="font-medium">Store design</h2>
  117. <p className="mt-1 max-w-md text-sm text-muted-foreground">
  118. AI design is not available yet. For now you
  119. can apply a sample design to see how a store
  120. looks.
  121. </p>
  122. </div>
  123. </div>
  124. <Form
  125. {...StoreDesignController.applySample.form(
  126. store.slug,
  127. )}
  128. >
  129. {({ processing }) => (
  130. <Button
  131. disabled={processing}
  132. data-test="apply-sample-design-button"
  133. >
  134. Apply sample design
  135. </Button>
  136. )}
  137. </Form>
  138. </div>
  139. )}
  140. </div>
  141. </>
  142. );
  143. }
  144. ShowStore.layout = {
  145. breadcrumbs: [
  146. {
  147. title: 'Dashboard',
  148. href: dashboard(),
  149. },
  150. {
  151. title: 'Store',
  152. href: '#',
  153. },
  154. ],
  155. };