This commit is contained in:
2026-10-08 16:57:16 +05:30
parent 8960fb8ebb
commit f91044e61a
2 changed files with 18 additions and 20 deletions

View File

@@ -2,8 +2,8 @@ import { useEffect, useState } from 'react';
import { useMutation, useQuery } from '@tanstack/react-query'; import { useMutation, useQuery } from '@tanstack/react-query';
import { errorMessage } from '@/api/client'; import { errorMessage } from '@/api/client';
import { DEFAULT_SLOTS, deliverySlotsApi, slotProblems, type DeliverySlot } from '@/api/deliverySlots'; import { DEFAULT_SLOTS, deliverySlotsApi, slotProblems, type DeliverySlot } from '@/api/deliverySlots';
import { Button } from '@astryxdesign/core/Button';
import { DeliverySlotsEditor } from './DeliverySlotsEditor'; import { DeliverySlotsEditor } from './DeliverySlotsEditor';
import { DrawerButton } from './drawerKit';
/** /**
* A branch's delivery windows, on the shop profile. * A branch's delivery windows, on the shop profile.
@@ -72,7 +72,6 @@ export function DeliverySlotsCard({
} }
const problems = slotProblems(draft); const problems = slotProblems(draft);
const hasNone = (query.data?.details ?? []).length === 0;
return ( return (
<div> <div>
@@ -83,21 +82,17 @@ export function DeliverySlotsCard({
setSaved(false); setSaved(false);
}} }}
isDisabled={save.isPending} isDisabled={save.isPending}
{...(hasNone
? {
// Said plainly, because the difference matters: this branch is
// taking orders right now with no window chosen, and will keep
// doing so until these are saved.
intro:
'This branch has no delivery windows yet, so customers order without choosing a time. Set them below to start offering a choice.',
}
: {})}
/> />
<div style={{ display: 'flex', alignItems: 'center', gap: 10, marginTop: 14 }}> <div style={{ display: 'flex', alignItems: 'center', gap: 10, marginTop: 14 }}>
<DrawerButton {/* The design system's Button, matching the Save on every other card on
this page. `DrawerButton` is the drawer's own styling and read as a
different product standing on a profile card. */}
<Button
label={save.isPending ? 'Saving…' : 'Save delivery windows'} label={save.isPending ? 'Saving…' : 'Save delivery windows'}
variant="primary" variant="primary"
size="sm"
isLoading={save.isPending}
isDisabled={save.isPending || problems.length > 0} isDisabled={save.isPending || problems.length > 0}
onClick={() => save.mutate(draft)} onClick={() => save.mutate(draft)}
/> />

View File

@@ -28,7 +28,14 @@ export function DeliverySlotsEditor({
slots, slots,
onChange, onChange,
isDisabled, isDisabled,
/** Shown above the rows. Onboarding and the profile screen say different things. */ /**
* Shown above the rows, and only when a caller asks for it.
*
* No default: onboarding explains what a window is because it is new to the
* person reading, while the shop profile does not, because they are editing
* something they already set. A paragraph that cannot be turned off is one
* every screen has to live with.
*/
intro, intro,
}: { }: {
slots: DeliverySlot[]; slots: DeliverySlot[];
@@ -50,12 +57,9 @@ export function DeliverySlotsEditor({
return ( return (
<div> <div>
<Note> {intro ? <Note>{intro}</Note> : null}
{intro ??
'Customers choose one of these when they order. A window takes orders right up until it ends — after that it disappears for the day and only the later windows are offered.'}
</Note>
<div style={{ display: 'grid', gap: 2, marginTop: 12 }}> <div style={{ display: 'grid', gap: 4, marginTop: 10 }}>
{ordered.map((slot) => ( {ordered.map((slot) => (
<SlotRow <SlotRow
key={slot.slotkey} key={slot.slotkey}
@@ -103,8 +107,7 @@ function SlotRow({
display: 'flex', display: 'flex',
alignItems: 'center', alignItems: 'center',
gap: 10, gap: 10,
padding: '11px 0', padding: '7px 0',
borderTop: '1px solid var(--color-line, #e0e4ea)',
// A window that is off stays legible but stops competing for attention. // A window that is off stays legible but stops competing for attention.
opacity: isOff ? 0.55 : 1, opacity: isOff ? 0.55 : 1,
}} }}