Просмотр исходного кода

Show Design, Settings and the store menu as one style of tab row

- Design tab: Logo, Style, Hero, Layouts, Bento tiles, Video and Featured product are one row of tabs instead of separate fold-open boxes; the Logo tab has a signature icon
- Settings: tabs for Payments (Stripe and HitPay together), Contact, Shipping fees, Couriers (EasyParcel and the pickup address) and Announcement bar; "Save settings" is hidden on Payments, which has its own buttons
- One look for every tab row: flat cells, the open tab filled with the border colour, its label and section rising in (off when the device asks for less motion)
- The store menu (Design, Products, Orders, Discounts, Settings, now with icons) and Appearance's Light / Dark / System row use the same look
- The open tab is remembered, so saving stays on it; links like #payments and #easyparcel open their tab
- Settings lets the server check fields, so a mistake in a closed tab opens that tab with a red dot instead of silently blocking the save
- Shared in resources/js/components/stores/section-tabs.tsx
main
fahmisaad 6 часов назад
Родитель
Сommit
4ef9a1a932

+ 8
- 3
PROGRESS.md Просмотреть файл

@@ -4,8 +4,8 @@ This file is the single source of truth for the project plan and status.
4 4
 Update it at the end of every work session.
5 5
 
6 6
 **Last updated:** 2026-12-02
7
-**Current step:** GrabPay and HitPay (DuitNow QR, Touch 'n Go, ShopeePay) are on `main`. The double-check for missed payments and "Complete payment" (order page button, cart reminder, reminder email, merchant notes) are built (not committed yet). Step 9 part 8 on hold
8
-**Next action:** Commit the double-check and "Complete payment". Later: live courier rate at checkout, tracking updates, a lawyer reads the legal pages, backup AI provider, hosting (follow the "Before going live" checklist in Step 10)
7
+**Current step:** GrabPay, HitPay (DuitNow QR, Touch 'n Go, ShopeePay), the double-check for missed payments and "Complete payment" are on `main`. The Design tab, Settings, the store menu and Appearance now share one tab look (not committed yet). Step 9 part 8 on hold
8
+**Next action:** Commit the Design and Settings tabs. Later: live courier rate at checkout, tracking updates, a lawyer reads the legal pages, backup AI provider, hosting (follow the "Before going live" checklist in Step 10)
9 9
 
10 10
 Status marks: `[ ]` not started · `[~]` in progress · `[x]` done
11 11
 
@@ -341,7 +341,7 @@ Changing from Claude to another AI model (or back) must be a settings change, no
341 341
 | Footer                     | simple, centered, **columns** (store name and text, links, shop and help links)                       |
342 342
 | Header, contact, trust row | 2 each, unchanged                                                                                     |
343 343
 
344
-- The Design tab has a **Layouts** box (closed by default) listing every section with its layout in plain words; heroes stay in their own Hero box. `App\StorePlan\SectionLayouts` finds and changes them; only layouts of the section's own type are accepted.
344
+- The Design tab has a **Layouts** tab listing every section with its layout in plain words; heroes stay in their own Hero box. `App\StorePlan\SectionLayouts` finds and changes them; only layouts of the section's own type are accepted.
345 345
 - The AI is told what each new layout looks like and when it suits, and can switch layouts by chat ("make the products slide sideways").
346 346
 - **Show in the preview (added 2026-11-25):** in the Design tab, a section's name (Layouts, Hero, Featured product, Video and Bento boxes) is a button with a small target icon. Clicking it brings the preview into view, scrolls the preview to that section (below the store's sticky header) and outlines it in green with its name for about 2.5 seconds. A section on another page (such as About us) opens that page first. Each section's band in the store carries `data-section="<id>"`; header and footer are found by their tags. Code: `resources/js/components/stores/preview-highlight.tsx`.
347 347
 
@@ -353,6 +353,9 @@ Changing from Claude to another AI model (or back) must be a settings change, no
353 353
 - **Bento** section (`bento`): 3 to 6 tiles, each with title, optional text, a link, and a photo name (like a hero's) or a colour (primary, accent, dark, surface). `mosaic` makes the first tile big; `even` makes them equal. Bento photos are resolved with hero photos (`HeroImages::refs`).
354 354
 - **Video** section (`video`): a YouTube or Vimeo address only (`PlanSchema::VIDEO_PATTERN`, which refuses look-alike addresses). Only a picture shows until the shopper presses play; then a privacy-friendly player loads (youtube-nocookie, Vimeo with do-not-track). The AI may only use a video address the merchant wrote in the chat or the brand description; any other is refused. The sample design has no video on purpose, so the AI never copies one. Uploading video files is not supported yet.
355 355
 - **Design tab boxes (added 2026-11-22):** a **Video** box (paste a YouTube or Vimeo link, heading, short text, layout, and where to put it; edit or remove later, with a preview picture) and a **Bento tiles** box ("Add tiles" puts in 3 starter tiles: the whole range with a product photo, the first collection or the products section, and the brand story; then edit each tile's title, text, link (with suggested links), photo and colour, add or remove tiles between 3 and 6, or remove the set). Both use `App\StorePlan\SectionEditor` and go through the plan checker, so a broken link or a photo from another store is refused.
356
+- **Design tab sections are a row of tabs (changed 2026-12-03):** under the preview, Logo, Style, Hero, Layouts, Bento tiles, Video and Featured product are tabs in one row (`resources/js/components/stores/section-tabs.tsx`, shared with Settings), one open at a time, instead of a stack of fold-open boxes. Logo opens first. A tab only shows when its part exists (Hero, Layouts, Featured product and Style need a matching section or style). Bento tiles and Video show how many there are. Panels stay loaded when hidden, so half-typed changes are kept when switching tabs. The tabs are flat cells filling the row (no button look, no shadow, no underline); the open tab's whole cell takes the section's border colour (light grey) with dark text, and other tabs get a lighter grey on hover. On opening, the tab's label rises in, and the section below rises and fades in. All motion is off for people who turn off animations in their device settings. On phones the row slides sideways; arrow keys move between tabs.
357
+- **Settings is a row of tabs too (changed 2026-12-03):** Payments (Stripe "Get paid" and HitPay together), Contact, Shipping fees, Couriers (EasyParcel and the pickup address together, since EasyParcel says "add your pickup address below") and Announcement bar, same look as the Design tab. Payments opens first, so Stripe sending the merchant back lands on it. "Save settings" is hidden on Payments, which has its own buttons. The open tab is remembered for the browser tab, so saving (which reloads the page) stays on it. Links to a section (`#payments`, `#easyparcel`) open its tab. The form has the browser's own field check turned off (`noValidate`): it cannot show its warning on a field in a closed tab and would block the save silently. The server checks the same rules, and a refused save opens the first tab with a problem and puts a red dot on it.
358
+- **One tab look everywhere (changed 2026-12-03):** the store menu on every store page (Design, Products, Orders, Discounts, Settings, now with icons) and the Light / Dark / System row in Appearance use the same look as the Design and Settings tabs: `tabClass`, `tabRowClass` and `TabLabel` in `section-tabs.tsx`. Switches stay as they are: Desktop / Mobile above the preview and the light/dark switch in the sidebar.
356 359
 
357 360
 ### Our home page (added 2026-11-22)
358 361
 
@@ -789,3 +792,5 @@ Add one line per work session: date, what was done, what is next.
789 792
 | 2026-12-02 | HitPay reminder: the card's guide says to Turn On methods in HitPay first; methods HitPay refuses are remembered, left out of checkout for an hour (the shopper still pays with what is left) and shown as a warning in the card until the merchant saves. 379 tests pass; warning checked in the browser.                                                                                                                                                                                                                                                                                                                                                                                                                                               | Commit                                                          |
790 793
 | 2026-12-02 | Double-check for missed payments: `orders:check-payments` every 5 minutes asks Stripe or HitPay about orders awaiting payment (often at first, hourly later), marks paid the ones that were paid, and turns them "Not paid" after 25 hours; HitPay pages now expire after 23 hours. Scheduler added to `composer run dev`; "Before going live" checklist added to Step 10. 385 tests pass; real run turned old order #1007 into "Not paid".                                                                                                                                                                                                                                                                                                              | Commit                                                          |
791 794
 | 2026-12-03 | "Complete payment": the order keeps its payment page and a 23-hour deadline (Stripe and HitPay pages expire then); order page button with the deadline, "unpaid order" note on the cart page (same browser), one "Complete your payment" email about 30 minutes after an unpaid order (sent by the double-check), and merchant notes for waiting and "Not paid" orders. 398 tests pass.                                                                                                                                                                                                                                                                                                                                                                  | Commit                                                          |
795
+| 2026-12-03 | Design tab: the section boxes under the preview (Logo, Style, Hero, Layouts, Bento tiles, Video, Featured product) are now one row of tabs instead of separate fold-open boxes; the open tab's whole cell takes the section's border colour, and the tab label and section rise in when opened. Checked in the browser on desktop and phone.                                                                                                                                                                                                                                                                                                                                                                                                             | Commit                                                          |
796
+| 2026-12-03 | Settings page in tabs (Payments with Stripe and HitPay, Contact, Shipping fees, Couriers, Announcement bar) using the same tab row as the Design tab, now shared as `section-tabs.tsx`; the store menu and Appearance's Light/Dark/System row got the same look. Open tab remembered across saves, `#payments` links open their tab, a refused save opens the tab with the problem. 398 tests pass; checked in the browser on desktop and phone.                                                                                                                                                                                                                                                                                                                                                                                  | Commit                                                          |

+ 18
- 13
resources/js/components/appearance-tabs.tsx Просмотреть файл

@@ -3,6 +3,11 @@ import { Monitor, Moon, Sun } from 'lucide-react';
3 3
 import type { HTMLAttributes } from 'react';
4 4
 import type { Appearance } from '@/hooks/use-appearance';
5 5
 import { useAppearance } from '@/hooks/use-appearance';
6
+import {
7
+    TabLabel,
8
+    tabClass,
9
+    tabRowClass,
10
+} from '@/components/stores/section-tabs';
6 11
 import { cn } from '@/lib/utils';
7 12
 
8 13
 export default function AppearanceToggleTab({
@@ -19,25 +24,25 @@ export default function AppearanceToggleTab({
19 24
 
20 25
     return (
21 26
         <div
22
-            className={cn(
23
-                'inline-flex gap-1 rounded-lg bg-neutral-100 p-1 dark:bg-neutral-800',
24
-                className,
25
-            )}
27
+            role="radiogroup"
28
+            aria-label="Appearance"
29
+            className={cn(tabRowClass, 'inline-flex max-w-full', className)}
26 30
             {...props}
27 31
         >
28
-            {tabs.map(({ value, icon: Icon, label }) => (
32
+            {tabs.map(({ value, icon, label }) => (
29 33
                 <button
30 34
                     key={value}
35
+                    type="button"
36
+                    role="radio"
37
+                    aria-checked={appearance === value}
31 38
                     onClick={() => updateAppearance(value)}
32
-                    className={cn(
33
-                        'flex items-center rounded-md px-3.5 py-1.5 transition-colors',
34
-                        appearance === value
35
-                            ? 'bg-white shadow-xs dark:bg-neutral-700 dark:text-neutral-100'
36
-                            : 'text-neutral-500 hover:bg-neutral-200/60 hover:text-black dark:text-neutral-400 dark:hover:bg-neutral-700/60',
37
-                    )}
39
+                    className={tabClass(appearance === value)}
38 40
                 >
39
-                    <Icon className="-ml-1 h-4 w-4" />
40
-                    <span className="ml-1.5 text-sm">{label}</span>
41
+                    <TabLabel
42
+                        icon={icon}
43
+                        label={label}
44
+                        selected={appearance === value}
45
+                    />
41 46
                 </button>
42 47
             ))}
43 48
         </div>

+ 7
- 25
resources/js/components/stores/bento-box.tsx Просмотреть файл

@@ -1,5 +1,5 @@
1 1
 import { router, useForm } from '@inertiajs/react';
2
-import { ChevronDown, LayoutGrid, Plus, Trash2, X } from 'lucide-react';
2
+import { Plus, Trash2, X } from 'lucide-react';
3 3
 import type { FormEvent } from 'react';
4 4
 import { useState } from 'react';
5 5
 import BentoSectionController from '@/actions/App/Http/Controllers/BentoSectionController';
@@ -68,29 +68,11 @@ export default function BentoBox({
68 68
     }
69 69
 
70 70
     return (
71
-        <details className="group rounded-xl border p-4" data-test="bento-box">
72
-            <summary className="flex cursor-pointer list-none items-start gap-3 [&::-webkit-details-marker]:hidden">
73
-                <LayoutGrid className="mt-0.5 size-5 shrink-0 text-muted-foreground" />
74
-                <div>
75
-                    <h3 className="font-medium">
76
-                        Bento tiles{' '}
77
-                        {bentos.length > 0 && (
78
-                            <span className="text-muted-foreground">
79
-                                ({bentos.length})
80
-                            </span>
81
-                        )}
82
-                    </h3>
83
-                    <p className="mt-0.5 text-sm text-muted-foreground">
84
-                        Tiles of different sizes that lead shoppers to your
85
-                        range, collections, offers or story. Open to add or
86
-                        change them.
87
-                    </p>
88
-                </div>
89
-                <ChevronDown
90
-                    className="mt-1 ml-auto size-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180"
91
-                    aria-hidden="true"
92
-                />
93
-            </summary>
71
+        <div data-test="bento-box">
72
+            <p className="text-sm text-muted-foreground">
73
+                Tiles of different sizes that lead shoppers to your range,
74
+                collections, offers or story.
75
+            </p>
94 76
 
95 77
             {/* Suggestions for every tile link field. */}
96 78
             <datalist id="bento-links">
@@ -144,7 +126,7 @@ export default function BentoBox({
144 126
                     </Button>
145 127
                 </div>
146 128
             </div>
147
-        </details>
129
+        </div>
148 130
     );
149 131
 }
150 132
 

+ 7
- 21
resources/js/components/stores/featured-picker.tsx Просмотреть файл

@@ -1,5 +1,5 @@
1 1
 import { router } from '@inertiajs/react';
2
-import { ChevronDown, Link2 } from 'lucide-react';
2
+
3 3
 import { useState } from 'react';
4 4
 import FeaturedProductController from '@/actions/App/Http/Controllers/FeaturedProductController';
5 5
 import ProductController from '@/actions/App/Http/Controllers/ProductController';
@@ -47,25 +47,11 @@ export default function FeaturedPicker({
47 47
     }
48 48
 
49 49
     return (
50
-        <details
51
-            className="group rounded-xl border p-4"
52
-            data-test="featured-picker"
53
-        >
54
-            <summary className="flex cursor-pointer list-none items-start gap-3 [&::-webkit-details-marker]:hidden">
55
-                <Link2 className="mt-0.5 size-5 shrink-0 text-muted-foreground" />
56
-                <div>
57
-                    <h3 className="font-medium">Featured product</h3>
58
-                    <p className="mt-0.5 text-sm text-muted-foreground">
59
-                        Choose which of your products this section shows. Its
60
-                        real name, price and photo are used, and the button
61
-                        opens its page.
62
-                    </p>
63
-                </div>
64
-                <ChevronDown
65
-                    className="mt-1 ml-auto size-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180"
66
-                    aria-hidden="true"
67
-                />
68
-            </summary>
50
+        <div data-test="featured-picker">
51
+            <p className="text-sm text-muted-foreground">
52
+                Choose which of your products this section shows. Its real name,
53
+                price and photo are used, and the button opens its page.
54
+            </p>
69 55
 
70 56
             <div className="mt-4 space-y-4">
71 57
                 {products.length === 0 ? (
@@ -155,6 +141,6 @@ export default function FeaturedPicker({
155 141
                     </ul>
156 142
                 )}
157 143
             </div>
158
-        </details>
144
+        </div>
159 145
     );
160 146
 }

+ 7
- 20
resources/js/components/stores/hero-picker.tsx Просмотреть файл

@@ -1,5 +1,5 @@
1 1
 import { router, useForm } from '@inertiajs/react';
2
-import { ChevronDown, Check, ImageIcon, Upload } from 'lucide-react';
2
+import { Check, Upload } from 'lucide-react';
3 3
 import type { FormEvent } from 'react';
4 4
 import { useState } from 'react';
5 5
 import HeroImageController from '@/actions/App/Http/Controllers/HeroImageController';
@@ -35,24 +35,11 @@ export default function HeroPicker({
35 35
     }
36 36
 
37 37
     return (
38
-        <details
39
-            className="group rounded-xl border p-4"
40
-            data-test="hero-picker"
41
-        >
42
-            <summary className="flex cursor-pointer list-none items-start gap-3 [&::-webkit-details-marker]:hidden">
43
-                <ImageIcon className="mt-0.5 size-5 shrink-0 text-muted-foreground" />
44
-                <div>
45
-                    <h3 className="font-medium">Hero</h3>
46
-                    <p className="mt-0.5 text-sm text-muted-foreground">
47
-                        The big banner at the top. Choose its layout and photo,
48
-                        or upload your own banner photo.
49
-                    </p>
50
-                </div>
51
-                <ChevronDown
52
-                    className="mt-1 ml-auto size-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180"
53
-                    aria-hidden="true"
54
-                />
55
-            </summary>
38
+        <div data-test="hero-picker">
39
+            <p className="text-sm text-muted-foreground">
40
+                The big banner at the top. Choose its layout and photo, or
41
+                upload your own banner photo.
42
+            </p>
56 43
 
57 44
             <div className="mt-5 space-y-5">
58 45
                 {sections.map((section) => (
@@ -66,7 +53,7 @@ export default function HeroPicker({
66 53
                     />
67 54
                 ))}
68 55
             </div>
69
-        </details>
56
+        </div>
70 57
     );
71 58
 }
72 59
 

+ 6
- 20
resources/js/components/stores/layout-picker.tsx Просмотреть файл

@@ -1,5 +1,5 @@
1 1
 import { router } from '@inertiajs/react';
2
-import { ChevronDown, LayoutTemplate } from 'lucide-react';
2
+
3 3
 import { useState } from 'react';
4 4
 import SectionLayoutController from '@/actions/App/Http/Controllers/SectionLayoutController';
5 5
 import { SectionName } from '@/components/stores/preview-highlight';
@@ -87,24 +87,10 @@ export default function LayoutPicker({
87 87
     }
88 88
 
89 89
     return (
90
-        <details
91
-            className="group rounded-xl border p-4"
92
-            data-test="layout-picker"
93
-        >
94
-            <summary className="flex cursor-pointer list-none items-start gap-3 [&::-webkit-details-marker]:hidden">
95
-                <LayoutTemplate className="mt-0.5 size-5 shrink-0 text-muted-foreground" />
96
-                <div>
97
-                    <h3 className="font-medium">Layouts</h3>
98
-                    <p className="mt-0.5 text-sm text-muted-foreground">
99
-                        How each part of your store is arranged. Open to change
100
-                        one.
101
-                    </p>
102
-                </div>
103
-                <ChevronDown
104
-                    className="mt-1 ml-auto size-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180"
105
-                    aria-hidden="true"
106
-                />
107
-            </summary>
90
+        <div data-test="layout-picker">
91
+            <p className="text-sm text-muted-foreground">
92
+                How each part of your store is arranged.
93
+            </p>
108 94
 
109 95
             <ul className="mt-4 divide-y">
110 96
                 {sections.map((section) => {
@@ -167,6 +153,6 @@ export default function LayoutPicker({
167 153
                     );
168 154
                 })}
169 155
             </ul>
170
-        </details>
156
+        </div>
171 157
     );
172 158
 }

+ 7
- 24
resources/js/components/stores/logo-box.tsx Просмотреть файл

@@ -1,12 +1,5 @@
1 1
 import { router, useForm, usePage } from '@inertiajs/react';
2
-import {
3
-    Check,
4
-    ChevronDown,
5
-    Sparkles,
6
-    Stamp,
7
-    Trash2,
8
-    Upload,
9
-} from 'lucide-react';
2
+import { Check, Sparkles, Trash2, Upload } from 'lucide-react';
10 3
 import type { FormEvent } from 'react';
11 4
 import { useState } from 'react';
12 5
 import StoreLogoController from '@/actions/App/Http/Controllers/StoreLogoController';
@@ -115,22 +108,12 @@ export function LogoBox({
115 108
             : logo.current?.type === 'drawn' && logo.current.svg === data.drawn;
116 109
 
117 110
     return (
118
-        <details className="group rounded-xl border p-4" data-test="logo-box">
111
+        <div data-test="logo-box">
119 112
             {fontUrl && <link rel="stylesheet" href={fontUrl} />}
120
-            <summary className="flex cursor-pointer list-none items-start gap-3 [&::-webkit-details-marker]:hidden">
121
-                <Stamp className="mt-0.5 size-5 shrink-0 text-muted-foreground" />
122
-                <div>
123
-                    <h3 className="font-medium">Logo</h3>
124
-                    <p className="mt-0.5 text-sm text-muted-foreground">
125
-                        Upload your logo, pick a ready design, or let the AI
126
-                        draw some. It shows on your store right away.
127
-                    </p>
128
-                </div>
129
-                <ChevronDown
130
-                    className="mt-1 ml-auto size-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180"
131
-                    aria-hidden="true"
132
-                />
133
-            </summary>
113
+            <p className="text-sm text-muted-foreground">
114
+                Upload your logo, pick a ready design, or let the AI draw some.
115
+                It shows on your store right away.
116
+            </p>
134 117
 
135 118
             <div className="mt-5 space-y-6">
136 119
                 {/* What the store shows now */}
@@ -314,7 +297,7 @@ export function LogoBox({
314 297
                     )}
315 298
                 </div>
316 299
             </div>
317
-        </details>
300
+        </div>
318 301
     );
319 302
 }
320 303
 

+ 292
- 0
resources/js/components/stores/section-tabs.tsx Просмотреть файл

@@ -0,0 +1,292 @@
1
+import type { LucideIcon } from 'lucide-react';
2
+import type { KeyboardEvent, ReactNode } from 'react';
3
+import { useEffect, useRef, useState } from 'react';
4
+import { cn } from '@/lib/utils';
5
+
6
+export type SectionTab = {
7
+    key: string;
8
+    label: string;
9
+    icon: LucideIcon;
10
+    /** A small number after the label, such as how many tiles there are. */
11
+    count?: number;
12
+    /** Something in this tab needs fixing, such as a field the save refused. */
13
+    hasError?: boolean;
14
+    content: ReactNode;
15
+};
16
+
17
+/**
18
+ * The look shared by every tab row in the app (Design, Settings, the store menu, Appearance): flat cells, and the
19
+ * open one filled with the border colour. Put it on the row's buttons or links.
20
+ */
21
+export function tabClass(selected: boolean): string {
22
+    return cn(
23
+        'flex shrink-0 items-center px-4 py-3 text-sm whitespace-nowrap transition-colors duration-200 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none focus-visible:ring-inset motion-reduce:transition-none',
24
+        selected
25
+            ? 'bg-border font-medium text-foreground'
26
+            : 'text-muted-foreground hover:bg-muted/60 hover:text-foreground',
27
+    );
28
+}
29
+
30
+/** The row around the tabs: a bordered strip that slides sideways on phones. */
31
+export const tabRowClass =
32
+    'flex [scrollbar-width:none] overflow-x-auto rounded-xl border';
33
+
34
+/** A tab's icon and words. They rise in each time the tab opens. */
35
+export function TabLabel({
36
+    icon: Icon,
37
+    label,
38
+    selected,
39
+    count,
40
+    hasError,
41
+    errorTest,
42
+}: {
43
+    icon: LucideIcon;
44
+    label: string;
45
+    selected: boolean;
46
+    count?: number;
47
+    hasError?: boolean;
48
+    errorTest?: string;
49
+}) {
50
+    return (
51
+        // A new key when the tab opens, so the label rises in each time.
52
+        <span
53
+            key={selected ? 'open' : 'closed'}
54
+            className={cn(
55
+                'flex items-center gap-2',
56
+                selected &&
57
+                    'animate-in duration-300 fade-in-50 slide-in-from-bottom-1 motion-reduce:animate-none',
58
+            )}
59
+        >
60
+            <Icon className="size-4" aria-hidden="true" />
61
+            {label}
62
+            {count !== undefined && count > 0 && (
63
+                <span className="text-muted-foreground tabular-nums">
64
+                    {count}
65
+                </span>
66
+            )}
67
+            {hasError && (
68
+                <span
69
+                    className="size-1.5 rounded-full bg-red-600"
70
+                    data-test={errorTest}
71
+                >
72
+                    <span className="sr-only">(needs fixing)</span>
73
+                </span>
74
+            )}
75
+        </span>
76
+    );
77
+}
78
+
79
+function storageKey(name: string): string {
80
+    return `section-tabs:${name}:${window.location.pathname}`;
81
+}
82
+
83
+/** The tab named in the address (#contact), else the one last open on this page. */
84
+function startingTab(name: string, tabs: SectionTab[]): string {
85
+    const keys = tabs.map((tab) => tab.key);
86
+    const hash = window.location.hash.slice(1);
87
+
88
+    if (keys.includes(hash)) {
89
+        return hash;
90
+    }
91
+
92
+    try {
93
+        const saved = window.sessionStorage.getItem(storageKey(name));
94
+
95
+        if (saved && keys.includes(saved)) {
96
+            return saved;
97
+        }
98
+    } catch {
99
+        // Storage can be blocked; the first tab is fine.
100
+    }
101
+
102
+    return keys[0] ?? '';
103
+}
104
+
105
+/**
106
+ * Sections of a page as one row of tabs, one open at a time (the Design tab, Settings).
107
+ * - Every panel stays mounted, so half-typed changes survive switching tabs and the page's form still sends them.
108
+ * - The open tab is remembered for this browser tab, so saving (which reloads the page) keeps you where you were.
109
+ * - A link to an id inside a tab (#payments, #pickup) opens that tab and scrolls to it.
110
+ * - When a save is refused, the first tab with a problem opens.
111
+ */
112
+export default function SectionTabs({
113
+    name,
114
+    label,
115
+    tabs,
116
+    panelClassName,
117
+    onChange,
118
+}: {
119
+    /** Short page name, used for ids and to remember the open tab. */
120
+    name: string;
121
+    /** What the row is, for screen readers. */
122
+    label: string;
123
+    tabs: SectionTab[];
124
+    panelClassName?: string;
125
+    onChange?: (key: string) => void;
126
+}) {
127
+    const [active, setActive] = useState(() => startingTab(name, tabs));
128
+    const buttons = useRef<Record<string, HTMLButtonElement | null>>({});
129
+    const onChangeRef = useRef(onChange);
130
+    const current = tabs.some((tab) => tab.key === active)
131
+        ? active
132
+        : (tabs[0]?.key ?? '');
133
+
134
+    useEffect(() => {
135
+        onChangeRef.current = onChange;
136
+    }, [onChange]);
137
+
138
+    useEffect(() => {
139
+        try {
140
+            window.sessionStorage.setItem(storageKey(name), current);
141
+        } catch {
142
+            // Not remembered; nothing else changes.
143
+        }
144
+
145
+        onChangeRef.current?.(current);
146
+    }, [name, current]);
147
+
148
+    // Links such as Settings#payments: open the tab holding that id, then scroll to it.
149
+    useEffect(() => {
150
+        function openFromHash() {
151
+            const id = window.location.hash.slice(1);
152
+            const target = id ? document.getElementById(id) : null;
153
+            const panel = target?.closest<HTMLElement>(
154
+                `[data-section-tabs="${name}"] [role="tabpanel"]`,
155
+            );
156
+
157
+            if (!target || !panel?.dataset.tabKey) {
158
+                return;
159
+            }
160
+
161
+            setActive(panel.dataset.tabKey);
162
+            requestAnimationFrame(() =>
163
+                target.scrollIntoView({ block: 'start' }),
164
+            );
165
+        }
166
+
167
+        openFromHash();
168
+        window.addEventListener('hashchange', openFromHash);
169
+
170
+        return () => window.removeEventListener('hashchange', openFromHash);
171
+    }, [name]);
172
+
173
+    // A refused save: show the first tab with a problem, unless the open one has one.
174
+    const errorKeys = tabs
175
+        .filter((tab) => tab.hasError)
176
+        .map((tab) => tab.key)
177
+        .join(',');
178
+
179
+    useEffect(() => {
180
+        const withErrors = errorKeys === '' ? [] : errorKeys.split(',');
181
+
182
+        if (withErrors.length > 0) {
183
+            setActive((open) =>
184
+                withErrors.includes(open) ? open : withErrors[0],
185
+            );
186
+        }
187
+    }, [errorKeys]);
188
+
189
+    // Arrow keys move along the row, like any tab list.
190
+    function onKeyDown(event: KeyboardEvent<HTMLDivElement>) {
191
+        const index = tabs.findIndex((tab) => tab.key === current);
192
+        const step =
193
+            event.key === 'ArrowRight' ? 1 : event.key === 'ArrowLeft' ? -1 : 0;
194
+        const target =
195
+            event.key === 'Home'
196
+                ? tabs[0]
197
+                : event.key === 'End'
198
+                  ? tabs[tabs.length - 1]
199
+                  : step !== 0
200
+                    ? tabs[(index + step + tabs.length) % tabs.length]
201
+                    : undefined;
202
+
203
+        if (!target) {
204
+            return;
205
+        }
206
+
207
+        event.preventDefault();
208
+        setActive(target.key);
209
+        buttons.current[target.key]?.focus();
210
+    }
211
+
212
+    if (tabs.length === 0) {
213
+        return null;
214
+    }
215
+
216
+    return (
217
+        <div
218
+            className="rounded-xl border"
219
+            data-section-tabs={name}
220
+            data-test={`${name}-tabs`}
221
+            // A browser check refused a field in a closed tab: open that tab so the field can be seen and fixed.
222
+            onInvalidCapture={(event) => {
223
+                const key = (event.target as HTMLElement).closest<HTMLElement>(
224
+                    '[role="tabpanel"]',
225
+                )?.dataset.tabKey;
226
+
227
+                if (key) {
228
+                    setActive(key);
229
+                }
230
+            }}
231
+        >
232
+            <div
233
+                role="tablist"
234
+                aria-label={label}
235
+                onKeyDown={onKeyDown}
236
+                className={cn(
237
+                    tabRowClass,
238
+                    'rounded-none rounded-t-xl border-0 border-b',
239
+                )}
240
+            >
241
+                {tabs.map((tab) => {
242
+                    const selected = tab.key === current;
243
+
244
+                    return (
245
+                        <button
246
+                            key={tab.key}
247
+                            ref={(element) => {
248
+                                buttons.current[tab.key] = element;
249
+                            }}
250
+                            type="button"
251
+                            role="tab"
252
+                            id={`${name}-tab-${tab.key}`}
253
+                            aria-selected={selected}
254
+                            aria-controls={`${name}-panel-${tab.key}`}
255
+                            tabIndex={selected ? 0 : -1}
256
+                            onClick={() => setActive(tab.key)}
257
+                            data-test={`${name}-tab-${tab.key}`}
258
+                            className={tabClass(selected)}
259
+                        >
260
+                            <TabLabel
261
+                                icon={tab.icon}
262
+                                label={tab.label}
263
+                                selected={selected}
264
+                                count={tab.count}
265
+                                hasError={tab.hasError}
266
+                                errorTest={`${name}-tab-error`}
267
+                            />
268
+                        </button>
269
+                    );
270
+                })}
271
+            </div>
272
+
273
+            {tabs.map((tab) => (
274
+                <div
275
+                    key={tab.key}
276
+                    role="tabpanel"
277
+                    id={`${name}-panel-${tab.key}`}
278
+                    aria-labelledby={`${name}-tab-${tab.key}`}
279
+                    data-tab-key={tab.key}
280
+                    hidden={tab.key !== current}
281
+                    // Rises in each time it is shown: a hidden element replays its animation when it appears.
282
+                    className={cn(
283
+                        'animate-in p-4 duration-300 fade-in slide-in-from-bottom-2 motion-reduce:animate-none',
284
+                        panelClassName,
285
+                    )}
286
+                >
287
+                    {tab.content}
288
+                </div>
289
+            ))}
290
+        </div>
291
+    );
292
+}

+ 53
- 36
resources/js/components/stores/store-nav.tsx Просмотреть файл

@@ -1,10 +1,22 @@
1 1
 import { Link } from '@inertiajs/react';
2
+import type { LucideIcon } from 'lucide-react';
3
+import {
4
+    Package,
5
+    Palette,
6
+    ReceiptText,
7
+    Settings,
8
+    TicketPercent,
9
+} from 'lucide-react';
2 10
 import DiscountCodeController from '@/actions/App/Http/Controllers/DiscountCodeController';
3 11
 import OrderController from '@/actions/App/Http/Controllers/OrderController';
4 12
 import ProductController from '@/actions/App/Http/Controllers/ProductController';
5 13
 import StoreController from '@/actions/App/Http/Controllers/StoreController';
6 14
 import StoreSettingsController from '@/actions/App/Http/Controllers/StoreSettingsController';
7
-import { cn } from '@/lib/utils';
15
+import {
16
+    TabLabel,
17
+    tabClass,
18
+    tabRowClass,
19
+} from '@/components/stores/section-tabs';
8 20
 
9 21
 type Tab = 'design' | 'products' | 'orders' | 'discounts' | 'settings';
10 22
 
@@ -16,49 +28,54 @@ export default function StoreNav({
16 28
     slug: string;
17 29
     current: Tab;
18 30
 }) {
19
-    const tabs: { key: Tab; label: string; href: string }[] = [
20
-        {
21
-            key: 'design',
22
-            label: 'Design',
23
-            href: StoreController.show.url(slug),
24
-        },
25
-        {
26
-            key: 'products',
27
-            label: 'Products',
28
-            href: ProductController.index.url(slug),
29
-        },
30
-        {
31
-            key: 'orders',
32
-            label: 'Orders',
33
-            href: OrderController.index.url(slug),
34
-        },
35
-        {
36
-            key: 'discounts',
37
-            label: 'Discounts',
38
-            href: DiscountCodeController.index.url(slug),
39
-        },
40
-        {
41
-            key: 'settings',
42
-            label: 'Settings',
43
-            href: StoreSettingsController.edit.url(slug),
44
-        },
45
-    ];
31
+    const tabs: { key: Tab; label: string; icon: LucideIcon; href: string }[] =
32
+        [
33
+            {
34
+                key: 'design',
35
+                icon: Palette,
36
+                label: 'Design',
37
+                href: StoreController.show.url(slug),
38
+            },
39
+            {
40
+                key: 'products',
41
+                icon: Package,
42
+                label: 'Products',
43
+                href: ProductController.index.url(slug),
44
+            },
45
+            {
46
+                key: 'orders',
47
+                icon: ReceiptText,
48
+                label: 'Orders',
49
+                href: OrderController.index.url(slug),
50
+            },
51
+            {
52
+                key: 'discounts',
53
+                icon: TicketPercent,
54
+                label: 'Discounts',
55
+                href: DiscountCodeController.index.url(slug),
56
+            },
57
+            {
58
+                key: 'settings',
59
+                icon: Settings,
60
+                label: 'Settings',
61
+                href: StoreSettingsController.edit.url(slug),
62
+            },
63
+        ];
46 64
 
47 65
     return (
48
-        <nav aria-label="Store" className="flex gap-1 border-b">
66
+        <nav aria-label="Store" className={tabRowClass}>
49 67
             {tabs.map((tab) => (
50 68
                 <Link
51 69
                     key={tab.key}
52 70
                     href={tab.href}
53 71
                     aria-current={tab.key === current ? 'page' : undefined}
54
-                    className={cn(
55
-                        '-mb-px border-b-2 px-3 py-2 text-sm font-medium transition-colors',
56
-                        tab.key === current
57
-                            ? 'border-foreground text-foreground'
58
-                            : 'border-transparent text-muted-foreground hover:text-foreground',
59
-                    )}
72
+                    className={tabClass(tab.key === current)}
60 73
                 >
61
-                    {tab.label}
74
+                    <TabLabel
75
+                        icon={tab.icon}
76
+                        label={tab.label}
77
+                        selected={tab.key === current}
78
+                    />
62 79
                 </Link>
63 80
             ))}
64 81
         </nav>

+ 7
- 20
resources/js/components/stores/style-picker.tsx Просмотреть файл

@@ -1,5 +1,5 @@
1 1
 import { router } from '@inertiajs/react';
2
-import { ChevronDown, Check, Palette } from 'lucide-react';
2
+import { Check } from 'lucide-react';
3 3
 import type { CSSProperties } from 'react';
4 4
 import { useState } from 'react';
5 5
 import StoreStyleController from '@/actions/App/Http/Controllers/StoreStyleController';
@@ -105,24 +105,11 @@ export default function StylePicker({
105 105
     const disabled = busy || saving;
106 106
 
107 107
     return (
108
-        <details
109
-            className="group rounded-xl border p-4"
110
-            data-test="style-picker"
111
-        >
112
-            <summary className="flex cursor-pointer list-none items-start gap-3 [&::-webkit-details-marker]:hidden">
113
-                <Palette className="mt-0.5 size-5 shrink-0 text-muted-foreground" />
114
-                <div>
115
-                    <h3 className="font-medium">Style</h3>
116
-                    <p className="mt-0.5 text-sm text-muted-foreground">
117
-                        The feel of your whole store: buttons, cards, fonts,
118
-                        spacing and motion. Your colours stay the same.
119
-                    </p>
120
-                </div>
121
-                <ChevronDown
122
-                    className="mt-1 ml-auto size-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180"
123
-                    aria-hidden="true"
124
-                />
125
-            </summary>
108
+        <div data-test="style-picker">
109
+            <p className="text-sm text-muted-foreground">
110
+                The feel of your whole store: buttons, cards, fonts, spacing and
111
+                motion. Your colours stay the same.
112
+            </p>
126 113
 
127 114
             <div className="mt-5 space-y-5">
128 115
                 <ul className="grid grid-cols-2 gap-2 sm:grid-cols-3">
@@ -204,7 +191,7 @@ export default function StylePicker({
204 191
                     </div>
205 192
                 </details>
206 193
             </div>
207
-        </details>
194
+        </div>
208 195
     );
209 196
 }
210 197
 

+ 6
- 24
resources/js/components/stores/video-box.tsx Просмотреть файл

@@ -1,5 +1,5 @@
1 1
 import { router, useForm } from '@inertiajs/react';
2
-import { ChevronDown, Clapperboard, Trash2 } from 'lucide-react';
2
+import { Trash2 } from 'lucide-react';
3 3
 import type { FormEvent } from 'react';
4 4
 import { useState } from 'react';
5 5
 import VideoSectionController from '@/actions/App/Http/Controllers/VideoSectionController';
@@ -37,28 +37,10 @@ export default function VideoBox({
37 37
     busy: boolean;
38 38
 }) {
39 39
     return (
40
-        <details className="group rounded-xl border p-4" data-test="video-box">
41
-            <summary className="flex cursor-pointer list-none items-start gap-3 [&::-webkit-details-marker]:hidden">
42
-                <Clapperboard className="mt-0.5 size-5 shrink-0 text-muted-foreground" />
43
-                <div>
44
-                    <h3 className="font-medium">
45
-                        Video{' '}
46
-                        {videos.length > 0 && (
47
-                            <span className="text-muted-foreground">
48
-                                ({videos.length})
49
-                            </span>
50
-                        )}
51
-                    </h3>
52
-                    <p className="mt-0.5 text-sm text-muted-foreground">
53
-                        Show a YouTube or Vimeo video, such as how your product
54
-                        is made. Open to add or change one.
55
-                    </p>
56
-                </div>
57
-                <ChevronDown
58
-                    className="mt-1 ml-auto size-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180"
59
-                    aria-hidden="true"
60
-                />
61
-            </summary>
40
+        <div data-test="video-box">
41
+            <p className="text-sm text-muted-foreground">
42
+                Show a YouTube or Vimeo video, such as how your product is made.
43
+            </p>
62 44
 
63 45
             <div className="mt-4 space-y-6">
64 46
                 {videos.map((video) => (
@@ -85,7 +67,7 @@ export default function VideoBox({
85 67
                     />
86 68
                 </div>
87 69
             </div>
88
-        </details>
70
+        </div>
89 71
     );
90 72
 }
91 73
 

+ 528
- 307
resources/js/pages/stores/settings.tsx Просмотреть файл

@@ -1,4 +1,11 @@
1 1
 import { Form, Head } from '@inertiajs/react';
2
+import {
3
+    CreditCard,
4
+    Megaphone,
5
+    MessageCircle,
6
+    Package,
7
+    Truck,
8
+} from 'lucide-react';
2 9
 import { useState } from 'react';
3 10
 import StoreController from '@/actions/App/Http/Controllers/StoreController';
4 11
 import { BackButton } from '@/components/back-button';
@@ -10,6 +17,7 @@ import type { PaymentSettings } from '@/components/stores/get-paid-setup';
10 17
 import { GetPaidSetup } from '@/components/stores/get-paid-setup';
11 18
 import type { HitPaySettings } from '@/components/stores/hitpay-setup';
12 19
 import { HitPaySetup } from '@/components/stores/hitpay-setup';
20
+import SectionTabs from '@/components/stores/section-tabs';
13 21
 import StoreNav from '@/components/stores/store-nav';
14 22
 import { Button } from '@/components/ui/button';
15 23
 import { Checkbox } from '@/components/ui/checkbox';
@@ -49,6 +57,21 @@ type Settings = {
49 57
     parcel_height: string;
50 58
 };
51 59
 
60
+/** Settings cards sit flat inside a tab, split by a line, instead of as boxes inside a box. */
61
+const flatCards =
62
+    'divide-y p-0 [&>[data-slot=card]]:rounded-none [&>[data-slot=card]]:border-0 [&>[data-slot=card]]:bg-transparent [&>[data-slot=card]]:shadow-none';
63
+
64
+/** True when the save refused a field starting with one of these names (pickup_ covers every pickup field). */
65
+function hasErrorIn(errors: Record<string, string>, names: string[]): boolean {
66
+    return Object.keys(errors).some((field) =>
67
+        names.some(
68
+            (name) =>
69
+                field === name ||
70
+                (name.endsWith('_') && field.startsWith(name)),
71
+        ),
72
+    );
73
+}
74
+
52 75
 export default function StoreSettings({
53 76
     store,
54 77
     settings,
@@ -72,6 +95,8 @@ export default function StoreSettings({
72 95
     /** Loaded after the page shows. Null when EasyParcel is not connected. */
73 96
     easyparcelBalance?: { amount: number | null; error: string | null } | null;
74 97
 }) {
98
+    const [openTab, setOpenTab] = useState('');
99
+
75 100
     return (
76 101
         <>
77 102
             <Head title={`Settings - ${store.name}`} />
@@ -89,324 +114,520 @@ export default function StoreSettings({
89 114
                 <Form
90 115
                     {...StoreSettingsController.update.form(store.slug)}
91 116
                     options={{ preserveScroll: true }}
117
+                    // Fields sit in tabs, and the browser cannot show its own warning on a hidden one, so it would
118
+                    // block the save silently. The server checks the same rules, and its errors open the right tab.
119
+                    noValidate
92 120
                     className="max-w-2xl space-y-6"
93 121
                 >
94 122
                     {({ processing, errors }) => (
95 123
                         <>
96
-                            <GetPaidSetup store={store} payments={payments} />
124
+                            <SectionTabs
125
+                                name="settings"
126
+                                label="Store settings"
127
+                                onChange={setOpenTab}
128
+                                panelClassName={flatCards}
129
+                                tabs={[
130
+                                    {
131
+                                        key: 'payments',
132
+                                        label: 'Payments',
133
+                                        icon: CreditCard,
134
+                                        content: (
135
+                                            <>
136
+                                                <GetPaidSetup
137
+                                                    store={store}
138
+                                                    payments={payments}
139
+                                                />
97 140
 
98
-                            <HitPaySetup store={store} hitpay={hitpay} />
141
+                                                <HitPaySetup
142
+                                                    store={store}
143
+                                                    hitpay={hitpay}
144
+                                                />
145
+                                            </>
146
+                                        ),
147
+                                    },
148
+                                    {
149
+                                        key: 'contact',
150
+                                        label: 'Contact',
151
+                                        icon: MessageCircle,
152
+                                        hasError: hasErrorIn(errors, [
153
+                                            'whatsapp_number',
154
+                                            'contact_email',
155
+                                        ]),
156
+                                        content: (
157
+                                            <>
158
+                                                <ContactCard
159
+                                                    settings={settings}
160
+                                                    accountEmail={accountEmail}
161
+                                                    errors={errors}
162
+                                                />
163
+                                            </>
164
+                                        ),
165
+                                    },
166
+                                    {
167
+                                        key: 'shipping',
168
+                                        label: 'Shipping fees',
169
+                                        icon: Truck,
170
+                                        hasError: hasErrorIn(errors, [
171
+                                            'shipping_',
172
+                                            'free_shipping_over',
173
+                                        ]),
174
+                                        content: (
175
+                                            <>
176
+                                                <Card>
177
+                                                    <CardHeader>
178
+                                                        <CardTitle>
179
+                                                            Shipping fees
180
+                                                        </CardTitle>
181
+                                                        <CardDescription>
182
+                                                            Added at checkout,
183
+                                                            based on the
184
+                                                            shopper&rsquo;s
185
+                                                            state.
186
+                                                        </CardDescription>
187
+                                                    </CardHeader>
188
+                                                    <CardContent className="space-y-5">
189
+                                                        <div className="grid gap-5 sm:grid-cols-2">
190
+                                                            <div className="grid gap-2">
191
+                                                                <Label htmlFor="shipping_west">
192
+                                                                    Peninsular
193
+                                                                    Malaysia
194
+                                                                    (RM)
195
+                                                                </Label>
196
+                                                                <Input
197
+                                                                    id="shipping_west"
198
+                                                                    name="shipping_west"
199
+                                                                    inputMode="decimal"
200
+                                                                    required
201
+                                                                    defaultValue={
202
+                                                                        settings.shipping_west
203
+                                                                    }
204
+                                                                />
205
+                                                                <InputError
206
+                                                                    message={
207
+                                                                        errors.shipping_west
208
+                                                                    }
209
+                                                                />
210
+                                                            </div>
211
+                                                            <div className="grid gap-2">
212
+                                                                <Label htmlFor="shipping_east">
213
+                                                                    Sabah,
214
+                                                                    Sarawak and
215
+                                                                    Labuan (RM)
216
+                                                                </Label>
217
+                                                                <Input
218
+                                                                    id="shipping_east"
219
+                                                                    name="shipping_east"
220
+                                                                    inputMode="decimal"
221
+                                                                    required
222
+                                                                    defaultValue={
223
+                                                                        settings.shipping_east
224
+                                                                    }
225
+                                                                />
226
+                                                                <InputError
227
+                                                                    message={
228
+                                                                        errors.shipping_east
229
+                                                                    }
230
+                                                                />
231
+                                                            </div>
232
+                                                        </div>
99 233
 
100
-                            <ContactCard
101
-                                settings={settings}
102
-                                accountEmail={accountEmail}
103
-                                errors={errors}
104
-                            />
234
+                                                        <div className="grid gap-2 sm:max-w-[calc(50%-0.625rem)]">
235
+                                                            <Label htmlFor="free_shipping_over">
236
+                                                                Free shipping on
237
+                                                                orders over (RM,
238
+                                                                optional)
239
+                                                            </Label>
240
+                                                            <Input
241
+                                                                id="free_shipping_over"
242
+                                                                name="free_shipping_over"
243
+                                                                inputMode="decimal"
244
+                                                                defaultValue={
245
+                                                                    settings.free_shipping_over ??
246
+                                                                    ''
247
+                                                                }
248
+                                                                placeholder="100.00"
249
+                                                                aria-describedby="free-help"
250
+                                                            />
251
+                                                            <p
252
+                                                                id="free-help"
253
+                                                                className="text-xs text-muted-foreground"
254
+                                                            >
255
+                                                                Leave empty to
256
+                                                                always charge
257
+                                                                shipping. Enter
258
+                                                                0 to always ship
259
+                                                                free.
260
+                                                            </p>
261
+                                                            <InputError
262
+                                                                message={
263
+                                                                    errors.free_shipping_over
264
+                                                                }
265
+                                                            />
266
+                                                        </div>
267
+                                                    </CardContent>
268
+                                                </Card>
269
+                                            </>
270
+                                        ),
271
+                                    },
272
+                                    {
273
+                                        key: 'couriers',
274
+                                        label: 'Couriers',
275
+                                        icon: Package,
276
+                                        hasError: hasErrorIn(errors, [
277
+                                            'pickup_',
278
+                                            'parcel_',
279
+                                        ]),
280
+                                        content: (
281
+                                            <>
282
+                                                <EasyParcelSetup
283
+                                                    store={store}
284
+                                                    easyparcel={easyparcel}
285
+                                                    balance={easyparcelBalance}
286
+                                                    hasPickup={
287
+                                                        settings.pickup
288
+                                                            .line1 !== ''
289
+                                                    }
290
+                                                />
105 291
 
106
-                            <Card>
107
-                                <CardHeader>
108
-                                    <CardTitle>Shipping fees</CardTitle>
109
-                                    <CardDescription>
110
-                                        Added at checkout, based on the
111
-                                        shopper&rsquo;s state.
112
-                                    </CardDescription>
113
-                                </CardHeader>
114
-                                <CardContent className="space-y-5">
115
-                                    <div className="grid gap-5 sm:grid-cols-2">
116
-                                        <div className="grid gap-2">
117
-                                            <Label htmlFor="shipping_west">
118
-                                                Peninsular Malaysia (RM)
119
-                                            </Label>
120
-                                            <Input
121
-                                                id="shipping_west"
122
-                                                name="shipping_west"
123
-                                                inputMode="decimal"
124
-                                                required
125
-                                                defaultValue={
126
-                                                    settings.shipping_west
127
-                                                }
128
-                                            />
129
-                                            <InputError
130
-                                                message={errors.shipping_west}
131
-                                            />
132
-                                        </div>
133
-                                        <div className="grid gap-2">
134
-                                            <Label htmlFor="shipping_east">
135
-                                                Sabah, Sarawak and Labuan (RM)
136
-                                            </Label>
137
-                                            <Input
138
-                                                id="shipping_east"
139
-                                                name="shipping_east"
140
-                                                inputMode="decimal"
141
-                                                required
142
-                                                defaultValue={
143
-                                                    settings.shipping_east
144
-                                                }
145
-                                            />
146
-                                            <InputError
147
-                                                message={errors.shipping_east}
148
-                                            />
149
-                                        </div>
150
-                                    </div>
292
+                                                <Card id="pickup">
293
+                                                    <CardHeader>
294
+                                                        <CardTitle>
295
+                                                            Pickup address
296
+                                                        </CardTitle>
297
+                                                        <CardDescription>
298
+                                                            Where couriers
299
+                                                            collect your
300
+                                                            parcels, printed on
301
+                                                            every label as the
302
+                                                            sender.
303
+                                                        </CardDescription>
304
+                                                    </CardHeader>
305
+                                                    <CardContent className="space-y-5">
306
+                                                        <div className="grid gap-5 sm:grid-cols-2">
307
+                                                            <TextField
308
+                                                                name="pickup_name"
309
+                                                                label="Sender name"
310
+                                                                value={
311
+                                                                    settings
312
+                                                                        .pickup
313
+                                                                        .name
314
+                                                                }
315
+                                                                placeholder={
316
+                                                                    store.name
317
+                                                                }
318
+                                                                error={
319
+                                                                    errors.pickup_name
320
+                                                                }
321
+                                                                maxLength={60}
322
+                                                            />
323
+                                                            <TextField
324
+                                                                name="pickup_phone"
325
+                                                                label="Phone for the courier"
326
+                                                                value={
327
+                                                                    settings
328
+                                                                        .pickup
329
+                                                                        .phone
330
+                                                                }
331
+                                                                placeholder="012-345 6789"
332
+                                                                error={
333
+                                                                    errors.pickup_phone
334
+                                                                }
335
+                                                                maxLength={30}
336
+                                                                type="tel"
337
+                                                            />
338
+                                                        </div>
339
+                                                        <TextField
340
+                                                            name="pickup_line1"
341
+                                                            label="Address"
342
+                                                            value={
343
+                                                                settings.pickup
344
+                                                                    .line1
345
+                                                            }
346
+                                                            placeholder="No. 12, Jalan Mawar 3"
347
+                                                            error={
348
+                                                                errors.pickup_line1
349
+                                                            }
350
+                                                            maxLength={100}
351
+                                                        />
352
+                                                        <TextField
353
+                                                            name="pickup_line2"
354
+                                                            label="Address line 2 (optional)"
355
+                                                            value={
356
+                                                                settings.pickup
357
+                                                                    .line2
358
+                                                            }
359
+                                                            placeholder="Taman Melati"
360
+                                                            error={
361
+                                                                errors.pickup_line2
362
+                                                            }
363
+                                                            maxLength={100}
364
+                                                        />
365
+                                                        <div className="grid gap-5 sm:grid-cols-3">
366
+                                                            <TextField
367
+                                                                name="pickup_postcode"
368
+                                                                label="Postcode"
369
+                                                                value={
370
+                                                                    settings
371
+                                                                        .pickup
372
+                                                                        .postcode
373
+                                                                }
374
+                                                                placeholder="53100"
375
+                                                                error={
376
+                                                                    errors.pickup_postcode
377
+                                                                }
378
+                                                                maxLength={5}
379
+                                                                inputMode="numeric"
380
+                                                            />
381
+                                                            <TextField
382
+                                                                name="pickup_city"
383
+                                                                label="Town or city"
384
+                                                                value={
385
+                                                                    settings
386
+                                                                        .pickup
387
+                                                                        .city
388
+                                                                }
389
+                                                                placeholder="Kuala Lumpur"
390
+                                                                error={
391
+                                                                    errors.pickup_city
392
+                                                                }
393
+                                                                maxLength={60}
394
+                                                            />
395
+                                                            <div className="grid gap-2">
396
+                                                                <Label htmlFor="pickup_state">
397
+                                                                    State
398
+                                                                </Label>
399
+                                                                <select
400
+                                                                    id="pickup_state"
401
+                                                                    name="pickup_state"
402
+                                                                    defaultValue={
403
+                                                                        settings
404
+                                                                            .pickup
405
+                                                                            .state
406
+                                                                    }
407
+                                                                    className="h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 md:text-sm"
408
+                                                                >
409
+                                                                    <option value="">
410
+                                                                        Choose
411
+                                                                    </option>
412
+                                                                    {states.map(
413
+                                                                        (
414
+                                                                            state,
415
+                                                                        ) => (
416
+                                                                            <option
417
+                                                                                key={
418
+                                                                                    state
419
+                                                                                }
420
+                                                                                value={
421
+                                                                                    state
422
+                                                                                }
423
+                                                                            >
424
+                                                                                {
425
+                                                                                    state
426
+                                                                                }
427
+                                                                            </option>
428
+                                                                        ),
429
+                                                                    )}
430
+                                                                </select>
431
+                                                                <InputError
432
+                                                                    message={
433
+                                                                        errors.pickup_state
434
+                                                                    }
435
+                                                                />
436
+                                                            </div>
437
+                                                        </div>
151 438
 
152
-                                    <div className="grid gap-2 sm:max-w-[calc(50%-0.625rem)]">
153
-                                        <Label htmlFor="free_shipping_over">
154
-                                            Free shipping on orders over (RM,
155
-                                            optional)
156
-                                        </Label>
157
-                                        <Input
158
-                                            id="free_shipping_over"
159
-                                            name="free_shipping_over"
160
-                                            inputMode="decimal"
161
-                                            defaultValue={
162
-                                                settings.free_shipping_over ??
163
-                                                ''
164
-                                            }
165
-                                            placeholder="100.00"
166
-                                            aria-describedby="free-help"
167
-                                        />
168
-                                        <p
169
-                                            id="free-help"
170
-                                            className="text-xs text-muted-foreground"
171
-                                        >
172
-                                            Leave empty to always charge
173
-                                            shipping. Enter 0 to always ship
174
-                                            free.
175
-                                        </p>
176
-                                        <InputError
177
-                                            message={errors.free_shipping_over}
178
-                                        />
179
-                                    </div>
180
-                                </CardContent>
181
-                            </Card>
439
+                                                        <div className="space-y-2 border-t pt-5">
440
+                                                            <p className="text-sm font-medium">
441
+                                                                Your usual
442
+                                                                parcel
443
+                                                            </p>
444
+                                                            <p className="text-xs text-muted-foreground">
445
+                                                                Filled in for
446
+                                                                you when booking
447
+                                                                a courier. You
448
+                                                                can change it
449
+                                                                for each order.
450
+                                                            </p>
451
+                                                            <div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
452
+                                                                <TextField
453
+                                                                    name="parcel_weight"
454
+                                                                    label="Weight (kg)"
455
+                                                                    value={
456
+                                                                        settings.parcel_weight
457
+                                                                    }
458
+                                                                    error={
459
+                                                                        errors.parcel_weight
460
+                                                                    }
461
+                                                                    inputMode="decimal"
462
+                                                                />
463
+                                                                <TextField
464
+                                                                    name="parcel_length"
465
+                                                                    label="Length (cm)"
466
+                                                                    value={
467
+                                                                        settings.parcel_length
468
+                                                                    }
469
+                                                                    error={
470
+                                                                        errors.parcel_length
471
+                                                                    }
472
+                                                                    inputMode="numeric"
473
+                                                                />
474
+                                                                <TextField
475
+                                                                    name="parcel_width"
476
+                                                                    label="Width (cm)"
477
+                                                                    value={
478
+                                                                        settings.parcel_width
479
+                                                                    }
480
+                                                                    error={
481
+                                                                        errors.parcel_width
482
+                                                                    }
483
+                                                                    inputMode="numeric"
484
+                                                                />
485
+                                                                <TextField
486
+                                                                    name="parcel_height"
487
+                                                                    label="Height (cm)"
488
+                                                                    value={
489
+                                                                        settings.parcel_height
490
+                                                                    }
491
+                                                                    error={
492
+                                                                        errors.parcel_height
493
+                                                                    }
494
+                                                                    inputMode="numeric"
495
+                                                                />
496
+                                                            </div>
497
+                                                        </div>
498
+                                                    </CardContent>
499
+                                                </Card>
500
+                                            </>
501
+                                        ),
502
+                                    },
503
+                                    {
504
+                                        key: 'announcement',
505
+                                        label: 'Announcement bar',
506
+                                        icon: Megaphone,
507
+                                        hasError: hasErrorIn(errors, [
508
+                                            'announcement_',
509
+                                        ]),
510
+                                        content: (
511
+                                            <>
512
+                                                <Card>
513
+                                                    <CardHeader>
514
+                                                        <CardTitle>
515
+                                                            Announcement bar
516
+                                                        </CardTitle>
517
+                                                        <CardDescription>
518
+                                                            A slim bar above
519
+                                                            your store's header.
520
+                                                            Several messages
521
+                                                            take turns.
522
+                                                        </CardDescription>
523
+                                                    </CardHeader>
524
+                                                    <CardContent className="space-y-5">
525
+                                                        <div className="flex items-center gap-3">
526
+                                                            <input
527
+                                                                type="hidden"
528
+                                                                name="announcement_enabled"
529
+                                                                value="0"
530
+                                                            />
531
+                                                            <Checkbox
532
+                                                                id="announcement_enabled"
533
+                                                                name="announcement_enabled"
534
+                                                                value="1"
535
+                                                                defaultChecked={
536
+                                                                    settings.announcement_enabled
537
+                                                                }
538
+                                                            />
539
+                                                            <Label htmlFor="announcement_enabled">
540
+                                                                Show the
541
+                                                                announcement bar
542
+                                                            </Label>
543
+                                                        </div>
182 544
 
183
-                            <EasyParcelSetup
184
-                                store={store}
185
-                                easyparcel={easyparcel}
186
-                                balance={easyparcelBalance}
187
-                                hasPickup={settings.pickup.line1 !== ''}
188
-                            />
189
-
190
-                            <Card id="pickup">
191
-                                <CardHeader>
192
-                                    <CardTitle>Pickup address</CardTitle>
193
-                                    <CardDescription>
194
-                                        Where couriers collect your parcels,
195
-                                        printed on every label as the sender.
196
-                                    </CardDescription>
197
-                                </CardHeader>
198
-                                <CardContent className="space-y-5">
199
-                                    <div className="grid gap-5 sm:grid-cols-2">
200
-                                        <TextField
201
-                                            name="pickup_name"
202
-                                            label="Sender name"
203
-                                            value={settings.pickup.name}
204
-                                            placeholder={store.name}
205
-                                            error={errors.pickup_name}
206
-                                            maxLength={60}
207
-                                        />
208
-                                        <TextField
209
-                                            name="pickup_phone"
210
-                                            label="Phone for the courier"
211
-                                            value={settings.pickup.phone}
212
-                                            placeholder="012-345 6789"
213
-                                            error={errors.pickup_phone}
214
-                                            maxLength={30}
215
-                                            type="tel"
216
-                                        />
217
-                                    </div>
218
-                                    <TextField
219
-                                        name="pickup_line1"
220
-                                        label="Address"
221
-                                        value={settings.pickup.line1}
222
-                                        placeholder="No. 12, Jalan Mawar 3"
223
-                                        error={errors.pickup_line1}
224
-                                        maxLength={100}
225
-                                    />
226
-                                    <TextField
227
-                                        name="pickup_line2"
228
-                                        label="Address line 2 (optional)"
229
-                                        value={settings.pickup.line2}
230
-                                        placeholder="Taman Melati"
231
-                                        error={errors.pickup_line2}
232
-                                        maxLength={100}
233
-                                    />
234
-                                    <div className="grid gap-5 sm:grid-cols-3">
235
-                                        <TextField
236
-                                            name="pickup_postcode"
237
-                                            label="Postcode"
238
-                                            value={settings.pickup.postcode}
239
-                                            placeholder="53100"
240
-                                            error={errors.pickup_postcode}
241
-                                            maxLength={5}
242
-                                            inputMode="numeric"
243
-                                        />
244
-                                        <TextField
245
-                                            name="pickup_city"
246
-                                            label="Town or city"
247
-                                            value={settings.pickup.city}
248
-                                            placeholder="Kuala Lumpur"
249
-                                            error={errors.pickup_city}
250
-                                            maxLength={60}
251
-                                        />
252
-                                        <div className="grid gap-2">
253
-                                            <Label htmlFor="pickup_state">
254
-                                                State
255
-                                            </Label>
256
-                                            <select
257
-                                                id="pickup_state"
258
-                                                name="pickup_state"
259
-                                                defaultValue={
260
-                                                    settings.pickup.state
261
-                                                }
262
-                                                className="h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 md:text-sm"
263
-                                            >
264
-                                                <option value="">Choose</option>
265
-                                                {states.map((state) => (
266
-                                                    <option
267
-                                                        key={state}
268
-                                                        value={state}
269
-                                                    >
270
-                                                        {state}
271
-                                                    </option>
272
-                                                ))}
273
-                                            </select>
274
-                                            <InputError
275
-                                                message={errors.pickup_state}
276
-                                            />
277
-                                        </div>
278
-                                    </div>
279
-
280
-                                    <div className="space-y-2 border-t pt-5">
281
-                                        <p className="text-sm font-medium">
282
-                                            Your usual parcel
283
-                                        </p>
284
-                                        <p className="text-xs text-muted-foreground">
285
-                                            Filled in for you when booking a
286
-                                            courier. You can change it for each
287
-                                            order.
288
-                                        </p>
289
-                                        <div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
290
-                                            <TextField
291
-                                                name="parcel_weight"
292
-                                                label="Weight (kg)"
293
-                                                value={settings.parcel_weight}
294
-                                                error={errors.parcel_weight}
295
-                                                inputMode="decimal"
296
-                                            />
297
-                                            <TextField
298
-                                                name="parcel_length"
299
-                                                label="Length (cm)"
300
-                                                value={settings.parcel_length}
301
-                                                error={errors.parcel_length}
302
-                                                inputMode="numeric"
303
-                                            />
304
-                                            <TextField
305
-                                                name="parcel_width"
306
-                                                label="Width (cm)"
307
-                                                value={settings.parcel_width}
308
-                                                error={errors.parcel_width}
309
-                                                inputMode="numeric"
310
-                                            />
311
-                                            <TextField
312
-                                                name="parcel_height"
313
-                                                label="Height (cm)"
314
-                                                value={settings.parcel_height}
315
-                                                error={errors.parcel_height}
316
-                                                inputMode="numeric"
317
-                                            />
318
-                                        </div>
319
-                                    </div>
320
-                                </CardContent>
321
-                            </Card>
545
+                                                        <div className="grid gap-2">
546
+                                                            <Label htmlFor="announcement_messages">
547
+                                                                Your own
548
+                                                                messages
549
+                                                                (optional, one
550
+                                                                per line, up to
551
+                                                                3)
552
+                                                            </Label>
553
+                                                            <textarea
554
+                                                                id="announcement_messages"
555
+                                                                name="announcement_messages"
556
+                                                                rows={3}
557
+                                                                maxLength={400}
558
+                                                                defaultValue={
559
+                                                                    settings.announcement_messages
560
+                                                                }
561
+                                                                placeholder={
562
+                                                                    'Raya orders close 25 March\nNew: Sambal Bilis is here'
563
+                                                                }
564
+                                                                className="w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 md:text-sm"
565
+                                                            />
566
+                                                            <InputError
567
+                                                                message={
568
+                                                                    errors.announcement_messages
569
+                                                                }
570
+                                                            />
571
+                                                        </div>
322 572
 
323
-                            <Card>
324
-                                <CardHeader>
325
-                                    <CardTitle>Announcement bar</CardTitle>
326
-                                    <CardDescription>
327
-                                        A slim bar above your store's header.
328
-                                        Several messages take turns.
329
-                                    </CardDescription>
330
-                                </CardHeader>
331
-                                <CardContent className="space-y-5">
332
-                                    <div className="flex items-center gap-3">
333
-                                        <input
334
-                                            type="hidden"
335
-                                            name="announcement_enabled"
336
-                                            value="0"
337
-                                        />
338
-                                        <Checkbox
339
-                                            id="announcement_enabled"
340
-                                            name="announcement_enabled"
341
-                                            value="1"
342
-                                            defaultChecked={
343
-                                                settings.announcement_enabled
344
-                                            }
345
-                                        />
346
-                                        <Label htmlFor="announcement_enabled">
347
-                                            Show the announcement bar
348
-                                        </Label>
349
-                                    </div>
350
-
351
-                                    <div className="grid gap-2">
352
-                                        <Label htmlFor="announcement_messages">
353
-                                            Your own messages (optional, one per
354
-                                            line, up to 3)
355
-                                        </Label>
356
-                                        <textarea
357
-                                            id="announcement_messages"
358
-                                            name="announcement_messages"
359
-                                            rows={3}
360
-                                            maxLength={400}
361
-                                            defaultValue={
362
-                                                settings.announcement_messages
363
-                                            }
364
-                                            placeholder={
365
-                                                'Raya orders close 25 March\nNew: Sambal Bilis is here'
366
-                                            }
367
-                                            className="w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 md:text-sm"
368
-                                        />
369
-                                        <InputError
370
-                                            message={
371
-                                                errors.announcement_messages
372
-                                            }
373
-                                        />
374
-                                    </div>
375
-
376
-                                    <div className="space-y-1.5 rounded-md bg-muted/50 p-3 text-sm">
377
-                                        <p className="font-medium">
378
-                                            Added by themselves
379
-                                        </p>
380
-                                        {automaticAnnouncements.length > 0 ? (
381
-                                            <ul
382
-                                                className="list-disc space-y-0.5 pl-5 text-muted-foreground"
383
-                                                data-test="automatic-announcements"
384
-                                            >
385
-                                                {automaticAnnouncements.map(
386
-                                                    (line) => (
387
-                                                        <li key={line}>
388
-                                                            {line}
389
-                                                        </li>
390
-                                                    ),
391
-                                                )}
392
-                                            </ul>
393
-                                        ) : (
394
-                                            <p className="text-muted-foreground">
395
-                                                Nothing right now. Free shipping
396
-                                                and running automatic discounts
397
-                                                show here by themselves.
398
-                                            </p>
399
-                                        )}
400
-                                    </div>
401
-                                </CardContent>
402
-                            </Card>
573
+                                                        <div className="space-y-1.5 rounded-md bg-muted/50 p-3 text-sm">
574
+                                                            <p className="font-medium">
575
+                                                                Added by
576
+                                                                themselves
577
+                                                            </p>
578
+                                                            {automaticAnnouncements.length >
579
+                                                            0 ? (
580
+                                                                <ul
581
+                                                                    className="list-disc space-y-0.5 pl-5 text-muted-foreground"
582
+                                                                    data-test="automatic-announcements"
583
+                                                                >
584
+                                                                    {automaticAnnouncements.map(
585
+                                                                        (
586
+                                                                            line,
587
+                                                                        ) => (
588
+                                                                            <li
589
+                                                                                key={
590
+                                                                                    line
591
+                                                                                }
592
+                                                                            >
593
+                                                                                {
594
+                                                                                    line
595
+                                                                                }
596
+                                                                            </li>
597
+                                                                        ),
598
+                                                                    )}
599
+                                                                </ul>
600
+                                                            ) : (
601
+                                                                <p className="text-muted-foreground">
602
+                                                                    Nothing
603
+                                                                    right now.
604
+                                                                    Free
605
+                                                                    shipping and
606
+                                                                    running
607
+                                                                    automatic
608
+                                                                    discounts
609
+                                                                    show here by
610
+                                                                    themselves.
611
+                                                                </p>
612
+                                                            )}
613
+                                                        </div>
614
+                                                    </CardContent>
615
+                                                </Card>
616
+                                            </>
617
+                                        ),
618
+                                    },
619
+                                ]}
620
+                            />
403 621
 
404
-                            <Button
405
-                                disabled={processing}
406
-                                data-test="save-settings-button"
407
-                            >
408
-                                Save settings
409
-                            </Button>
622
+                            {/* Payments are saved by their own buttons; this saves the other tabs. */}
623
+                            {openTab !== 'payments' && (
624
+                                <Button
625
+                                    disabled={processing}
626
+                                    data-test="save-settings-button"
627
+                                >
628
+                                    Save settings
629
+                                </Button>
630
+                            )}
410 631
                         </>
411 632
                     )}
412 633
                 </Form>

+ 133
- 44
resources/js/pages/stores/show.tsx Просмотреть файл

@@ -1,17 +1,25 @@
1 1
 import { Form, Head, router } from '@inertiajs/react';
2 2
 import {
3 3
     CircleAlert,
4
+    Clapperboard,
4 5
     ExternalLink,
6
+    ImageIcon,
7
+    LayoutGrid,
8
+    LayoutTemplate,
9
+    Link2,
5 10
     Monitor,
11
+    Palette,
6 12
     RefreshCw,
7 13
     Smartphone,
8 14
     Sparkles,
9 15
     SquareDashedMousePointer,
16
+    Signature,
10 17
 } from 'lucide-react';
11 18
 import { useEffect, useRef, useState } from 'react';
12 19
 import StoreDesignController from '@/actions/App/Http/Controllers/StoreDesignController';
13 20
 import StoreGenerationController from '@/actions/App/Http/Controllers/StoreGenerationController';
14 21
 import DesignChat from '@/components/stores/design-chat';
22
+import SectionTabs from '@/components/stores/section-tabs';
15 23
 import FeaturedPicker from '@/components/stores/featured-picker';
16 24
 import HeroPicker from '@/components/stores/hero-picker';
17 25
 import BentoBox from '@/components/stores/bento-box';
@@ -421,50 +429,131 @@ export default function ShowStore({
421 429
                                 />
422 430
                             </div>
423 431
 
424
-                            <LogoBox store={store} logo={logo} busy={busy} />
425
-
426
-                            <StylePicker
427
-                                store={store}
428
-                                current={style}
429
-                                presets={stylePresets}
430
-                                busy={busy}
431
-                            />
432
-
433
-                            <HeroPicker
434
-                                store={store}
435
-                                sections={heroSections}
436
-                                choices={heroChoices}
437
-                                busy={busy}
438
-                            />
439
-
440
-                            <LayoutPicker
441
-                                store={store}
442
-                                sections={layoutSections}
443
-                                options={layoutOptions}
444
-                                busy={busy}
445
-                            />
446
-
447
-                            <BentoBox
448
-                                store={store}
449
-                                bentos={bentoSections}
450
-                                homeSections={homeSections}
451
-                                photos={heroChoices}
452
-                                links={linkSuggestions}
453
-                                busy={busy}
454
-                            />
455
-
456
-                            <VideoBox
457
-                                store={store}
458
-                                videos={videoSections}
459
-                                homeSections={homeSections}
460
-                                busy={busy}
461
-                            />
462
-
463
-                            <FeaturedPicker
464
-                                store={store}
465
-                                sections={featuredSections}
466
-                                products={productOptions}
467
-                                busy={busy}
432
+                            <SectionTabs
433
+                                name="design"
434
+                                label="Parts of your store"
435
+                                tabs={[
436
+                                    {
437
+                                        key: 'logo',
438
+                                        label: 'Logo',
439
+                                        icon: Signature,
440
+                                        content: (
441
+                                            <LogoBox
442
+                                                store={store}
443
+                                                logo={logo}
444
+                                                busy={busy}
445
+                                            />
446
+                                        ),
447
+                                    },
448
+                                    ...(style
449
+                                        ? [
450
+                                              {
451
+                                                  key: 'style',
452
+                                                  label: 'Style',
453
+                                                  icon: Palette,
454
+                                                  content: (
455
+                                                      <StylePicker
456
+                                                          store={store}
457
+                                                          current={style}
458
+                                                          presets={stylePresets}
459
+                                                          busy={busy}
460
+                                                      />
461
+                                                  ),
462
+                                              },
463
+                                          ]
464
+                                        : []),
465
+                                    ...(heroSections.length > 0
466
+                                        ? [
467
+                                              {
468
+                                                  key: 'hero',
469
+                                                  label: 'Hero',
470
+                                                  icon: ImageIcon,
471
+                                                  content: (
472
+                                                      <HeroPicker
473
+                                                          store={store}
474
+                                                          sections={
475
+                                                              heroSections
476
+                                                          }
477
+                                                          choices={heroChoices}
478
+                                                          busy={busy}
479
+                                                      />
480
+                                                  ),
481
+                                              },
482
+                                          ]
483
+                                        : []),
484
+                                    ...(layoutSections.length > 0
485
+                                        ? [
486
+                                              {
487
+                                                  key: 'layouts',
488
+                                                  label: 'Layouts',
489
+                                                  icon: LayoutTemplate,
490
+                                                  content: (
491
+                                                      <LayoutPicker
492
+                                                          store={store}
493
+                                                          sections={
494
+                                                              layoutSections
495
+                                                          }
496
+                                                          options={
497
+                                                              layoutOptions
498
+                                                          }
499
+                                                          busy={busy}
500
+                                                      />
501
+                                                  ),
502
+                                              },
503
+                                          ]
504
+                                        : []),
505
+                                    {
506
+                                        key: 'bento',
507
+                                        label: 'Bento tiles',
508
+                                        icon: LayoutGrid,
509
+                                        count: bentoSections.length,
510
+                                        content: (
511
+                                            <BentoBox
512
+                                                store={store}
513
+                                                bentos={bentoSections}
514
+                                                homeSections={homeSections}
515
+                                                photos={heroChoices}
516
+                                                links={linkSuggestions}
517
+                                                busy={busy}
518
+                                            />
519
+                                        ),
520
+                                    },
521
+                                    {
522
+                                        key: 'video',
523
+                                        label: 'Video',
524
+                                        icon: Clapperboard,
525
+                                        count: videoSections.length,
526
+                                        content: (
527
+                                            <VideoBox
528
+                                                store={store}
529
+                                                videos={videoSections}
530
+                                                homeSections={homeSections}
531
+                                                busy={busy}
532
+                                            />
533
+                                        ),
534
+                                    },
535
+                                    ...(featuredSections.length > 0
536
+                                        ? [
537
+                                              {
538
+                                                  key: 'featured',
539
+                                                  label: 'Featured product',
540
+                                                  icon: Link2,
541
+                                                  content: (
542
+                                                      <FeaturedPicker
543
+                                                          store={store}
544
+                                                          sections={
545
+                                                              featuredSections
546
+                                                          }
547
+                                                          products={
548
+                                                              productOptions
549
+                                                          }
550
+                                                          busy={busy}
551
+                                                      />
552
+                                                  ),
553
+                                              },
554
+                                          ]
555
+                                        : []),
556
+                                ]}
468 557
                             />
469 558
 
470 559
                             <DesignChat

Загрузка…
Отмена
Сохранить