Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Added new styles for nested order cards and other misc UI fixes (#14557)

Damian Legawiecda9254b79610
diff --git a/packages/dashboard-core/src/components/page-header.tsx b/packages/dashboard-core/src/components/page-header.tsx
index 31ddfbde8c..7b21fb5566 100644
--- a/packages/dashboard-core/src/components/page-header.tsx
+++ b/packages/dashboard-core/src/components/page-header.tsx
@@ -51,13 +51,13 @@ export interface PageHeaderResource {
}
interface PageHeaderProps {
- /** Main title (left of any badges). */
+ /** Main title, on its own line. */
title: ReactNode
- /** Small text below or beside the title (updated_at badge, customer email, etc.). */
+ /** Small text beside the badges (updated_at badge, customer email, etc.). */
subtitle?: ReactNode
/** Back button target — passed to <BackButton fallback="..."/>. Omit for top-level pages. */
backTo?: string
- /** Status badges rendered next to the title. Use <StatusBadge /> for consistency. */
+ /** Status badges, on the line under the title. Use <StatusBadge />. */
badges?: ReactNode
/** Primary action buttons (rightmost, before the dropdown). Most pages use this for "Save". */
actions?: ReactNode
@@ -191,26 +191,29 @@ export function PageHeader({
<div className="flex min-w-0 flex-1 items-start gap-3">
{backTo && <BackButton fallback={backTo} />}
- {/* Title + badges share a line; subtitle drops underneath so
- descriptive prose doesn't get crammed alongside the heading. Short
- metadata subtitles (customer location, order status hint) read fine
- on the second line too. */}
+ {/* The heading owns its line, with everything that qualifies it on
+ the line below, so the eye reads the name first rather than
+ picking it out of a row it shares. */}
<div className="flex min-w-0 flex-1 flex-col gap-1">
- <div className="flex flex-wrap items-center gap-x-3 gap-y-1">
- {/* Smaller and clipped on a phone: sharing the row with the
- actions leaves a long product name too little width to wrap
- into anything readable. */}
- <h1 className="min-w-0 truncate font-medium text-xl leading-tight sm:text-2xl sm:whitespace-normal">
- {title}
- </h1>
- {badges}
- </div>
- {/* Clamped on a phone: a two line description beside the actions
- makes the sticky band tall enough to eat the content below it. */}
- {subtitle && (
- <span className="line-clamp-2 text-sm text-muted-foreground sm:line-clamp-none">
- {subtitle}
- </span>
+ {/* Smaller and clipped on a phone: sharing the row with the actions
+ leaves a long product name too little width to wrap into
+ anything readable. */}
+ <h1 className="min-w-0 truncate font-medium text-xl leading-tight sm:text-2xl sm:whitespace-normal">
+ {title}
+ </h1>
+ {/* Statuses and the timestamp share the second line: both answer
+ "where is this now", so splitting them costs a row and reads as
+ two separate facts. The subtitle is clamped on a phone, where a
+ long one would make the sticky band tall enough to eat the page. */}
+ {(badges || subtitle) && (
+ <div className="flex flex-wrap items-center gap-x-3 gap-y-1">
+ {badges}
+ {subtitle && (
+ <span className="line-clamp-2 text-sm text-muted-foreground sm:line-clamp-none">
+ {subtitle}
+ </span>
+ )}
+ </div>
)}
</div>
</div>
diff --git a/packages/dashboard-ui/src/ui/card.tsx b/packages/dashboard-ui/src/ui/card.tsx
index 160eb589dc..73cd2da7d5 100644
--- a/packages/dashboard-ui/src/ui/card.tsx
+++ b/packages/dashboard-ui/src/ui/card.tsx
@@ -2,17 +2,33 @@ import type * as React from 'react'
import { cn } from '../lib/utils'
-function Card({ className, ...props }: React.ComponentProps<'div'>) {
+function Card({
+ className,
+ variant = 'default',
+ ...props
+}: React.ComponentProps<'div'> & {
+ /**
+ * `nested` is one resource listed inside a card — a fulfillment on an order,
+ * a return, a rule. It sits on the muted surface so it reads as a thing
+ * *within* the card rather than another card beside it, and carries its own
+ * horizontal padding so its sections divide edge to edge.
+ */
+ variant?: 'default' | 'nested'
+}) {
return (
<div
data-slot="card"
+ data-variant={variant}
className={cn(
// `overflow-x-clip`: a wide child (a table sized to its columns) otherwise
// propagates its width up through every `overflow: visible` ancestor to
// the document, laying the whole page out wider than the viewport. `clip`
// rather than `hidden` so `overflow-y` stays `visible` and sticky
// descendants keep resolving against the page.
- 'group/card flex flex-col min-w-0 overflow-x-clip break-words bg-card text-card-foreground border border-border shadow-xs rounded-xl',
+ 'group/card flex flex-col min-w-0 overflow-x-clip break-words text-card-foreground shadow-xs',
+ variant === 'nested'
+ ? 'rounded-lg border border-border-subtle bg-muted px-3'
+ : 'rounded-xl border border-border bg-card',
className,
)}
{...props}
@@ -25,7 +41,7 @@ function CardHeader({ className, ...props }: React.ComponentProps<'div'>) {
<div
data-slot="card-header"
className={cn(
- 'group/card-header @container/card-header grid auto-rows-min items-start gap-1 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] px-3 py-2.5 border-b border-border-subtle rounded-t-[calc(var(--radius-2xl)-1px)]',
+ 'group/card-header @container/card-header grid auto-rows-min items-start gap-1 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] px-3 py-2.5 border-b border-border-subtle rounded-t-[calc(var(--radius-2xl)-1px)] group-data-[variant=nested]/card:rounded-none group-data-[variant=nested]/card:px-0 group-data-[variant=nested]/card:py-2 group-data-[variant=nested]/card:items-center',
className,
)}
{...props}
@@ -60,7 +76,13 @@ function CardAction({ className, ...props }: React.ComponentProps<'div'>) {
}
function CardContent({ className, ...props }: React.ComponentProps<'div'>) {
- return <div data-slot="card-content" className={cn('p-3', className)} {...props} />
+ return (
+ <div
+ data-slot="card-content"
+ className={cn('p-3 group-data-[variant=nested]/card:px-0', className)}
+ {...props}
+ />
+ )
}
function CardFooter({ className, ...props }: React.ComponentProps<'div'>) {
@@ -68,7 +90,7 @@ function CardFooter({ className, ...props }: React.ComponentProps<'div'>) {
<div
data-slot="card-footer"
className={cn(
- 'flex items-center p-3 bg-transparent border-t border-border-subtle rounded-b-[calc(var(--radius-xl)-1px)]',
+ 'flex items-center p-3 bg-transparent border-t border-border-subtle rounded-b-[calc(var(--radius-xl)-1px)] group-data-[variant=nested]/card:rounded-none group-data-[variant=nested]/card:px-0',
className,
)}
{...props}
diff --git a/packages/dashboard/src/components/spree/order-post-sale-cards.tsx b/packages/dashboard/src/components/spree/order-post-sale-cards.tsx
index a2182577c9..c403e53cd2 100644
--- a/packages/dashboard/src/components/spree/order-post-sale-cards.tsx
+++ b/packages/dashboard/src/components/spree/order-post-sale-cards.tsx
@@ -5,6 +5,7 @@ import {
Card,
CardAction,
CardContent,
+ CardFooter,
CardHeader,
CardTitle,
DropdownMenu,
@@ -16,6 +17,7 @@ import {
useConfirm,
} from '@spree/dashboard-ui'
import {
+ BanIcon,
BanknoteIcon,
CheckCircleIcon,
EllipsisVerticalIcon,
@@ -89,72 +91,74 @@ export function OrderExchangesCard({ order }: { order: Order }) {
</p>
)}
{exchanges.map((exchange: Exchange) => (
- <div key={exchange.id} className="rounded-lg border p-4 flex flex-col gap-3">
- <div className="flex items-center justify-between">
- <div className="flex items-center gap-2">
+ <Card key={exchange.id} variant="nested">
+ <CardHeader>
+ <CardTitle className="text-sm font-medium">
<StatusBadge status={exchange.status} />
<span className="text-sm font-medium">{exchange.number}</span>
- </div>
+ </CardTitle>
{EXCHANGE_ACTIONABLE.includes(exchange.status) && (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button variant="ghost" size="icon-xs">
- <EllipsisVerticalIcon className="size-4" />
- <span className="sr-only">{t('admin.actions.actions_menu')}</span>
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- {exchange.status === 'requested' && (
- <DropdownMenuItem onClick={() => approve.mutate(exchange.id)}>
- <CheckCircleIcon className="size-4" />
- {t('admin.pages.orders.detail.returns.actions.approve')}
- </DropdownMenuItem>
- )}
- {exchange.status === 'approved' && (
- <DropdownMenuItem
- onClick={() => receive.mutate({ exchangeId: exchange.id })}
- >
- <PackageCheckIcon className="size-4" />
- {t('admin.pages.orders.detail.returns.actions.receive')}
- </DropdownMenuItem>
- )}
- {exchange.status === 'received' && (
- <DropdownMenuItem
- onClick={() => fulfill.mutate({ exchangeId: exchange.id })}
- >
- <TruckIcon className="size-4" />
- {t('admin.pages.orders.detail.exchanges.actions.fulfill')}
- </DropdownMenuItem>
- )}
- {['requested', 'approved'].includes(exchange.status) && (
- <>
- <DropdownMenuSeparator />
+ <CardAction>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button variant="ghost" size="icon-xs">
+ <EllipsisVerticalIcon className="size-4" />
+ <span className="sr-only">{t('admin.actions.actions_menu')}</span>
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ {exchange.status === 'requested' && (
+ <DropdownMenuItem onClick={() => approve.mutate(exchange.id)}>
+ <CheckCircleIcon className="size-4" />
+ {t('admin.pages.orders.detail.returns.actions.approve')}
+ </DropdownMenuItem>
+ )}
+ {exchange.status === 'approved' && (
<DropdownMenuItem
- variant="destructive"
- onClick={async () => {
- if (
- await confirm({
- message: t('admin.pages.orders.detail.returns.confirm.cancel'),
- variant: 'destructive',
- confirmLabel: t('admin.actions.cancel'),
- })
- ) {
- cancel.mutate({ exchangeId: exchange.id })
- }
- }}
+ onClick={() => receive.mutate({ exchangeId: exchange.id })}
>
- <XCircleIcon className="size-4" />
- {t('admin.actions.cancel')}
+ <PackageCheckIcon className="size-4" />
+ {t('admin.pages.orders.detail.returns.actions.receive')}
</DropdownMenuItem>
- </>
- )}
- </DropdownMenuContent>
- </DropdownMenu>
+ )}
+ {exchange.status === 'received' && (
+ <DropdownMenuItem
+ onClick={() => fulfill.mutate({ exchangeId: exchange.id })}
+ >
+ <TruckIcon className="size-4" />
+ {t('admin.pages.orders.detail.exchanges.actions.fulfill')}
+ </DropdownMenuItem>
+ )}
+ {['requested', 'approved'].includes(exchange.status) && (
+ <>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem
+ variant="destructive"
+ onClick={async () => {
+ if (
+ await confirm({
+ message: t('admin.pages.orders.detail.returns.confirm.cancel'),
+ variant: 'destructive',
+ confirmLabel: t('admin.actions.cancel'),
+ })
+ ) {
+ cancel.mutate({ exchangeId: exchange.id })
+ }
+ }}
+ >
+ <XCircleIcon className="size-4" />
+ {t('admin.actions.cancel')}
+ </DropdownMenuItem>
+ </>
+ )}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </CardAction>
)}
- </div>
+ </CardHeader>
- <div className="flex flex-col gap-1.5">
+ <CardContent className="flex flex-col gap-1.5">
{(exchange.exchange_line_items ?? []).map((line) => (
<div key={line.id} className="flex items-center justify-between text-sm">
<span className="truncate">
@@ -167,15 +171,15 @@ export function OrderExchangesCard({ order }: { order: Order }) {
<span className="text-muted-foreground">×{line.quantity}</span>
</div>
))}
- </div>
+ </CardContent>
- <div className="flex items-center justify-between text-sm border-t pt-3">
+ <CardFooter className="justify-between text-sm">
<span className="text-muted-foreground">
{t('admin.pages.orders.detail.exchanges.price_difference')}
</span>
<span className="font-medium">{exchange.display_price_difference}</span>
- </div>
- </div>
+ </CardFooter>
+ </Card>
))}
</CardContent>
</Card>
@@ -236,79 +240,81 @@ export function OrderClaimsCard({ order }: { order: Order }) {
</p>
)}
{claims.map((claim: Claim) => (
- <div key={claim.id} className="rounded-lg border p-4 flex flex-col gap-3">
- <div className="flex items-center justify-between">
- <div className="flex items-center gap-2">
+ <Card key={claim.id} variant="nested">
+ <CardHeader>
+ <CardTitle className="text-sm font-medium">
<StatusBadge status={claim.status} />
<span className="text-sm font-medium">{claim.number}</span>
- </div>
+ </CardTitle>
{CLAIM_ACTIONABLE.includes(claim.status) && (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button variant="ghost" size="icon-xs">
- <EllipsisVerticalIcon className="size-4" />
- <span className="sr-only">{t('admin.actions.actions_menu')}</span>
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- {claim.status === 'open' && (
- <DropdownMenuItem onClick={() => approve.mutate(claim.id)}>
- <CheckCircleIcon className="size-4" />
- {t('admin.pages.orders.detail.returns.actions.approve')}
- </DropdownMenuItem>
- )}
- {claim.status === 'approved' && (
- <DropdownMenuItem onClick={() => setResolving(claim)}>
- <BanknoteIcon className="size-4" />
- {t('admin.pages.orders.detail.claims.actions.resolve')}
- </DropdownMenuItem>
- )}
- {['open', 'approved'].includes(claim.status) && <DropdownMenuSeparator />}
- {claim.status === 'open' && (
- <DropdownMenuItem
- variant="destructive"
- onClick={async () => {
- if (
- await confirm({
- message: t('admin.pages.orders.detail.claims.confirm.deny'),
- variant: 'destructive',
- confirmLabel: t('admin.pages.orders.detail.claims.actions.deny'),
- })
- ) {
- deny.mutate({ claimId: claim.id })
- }
- }}
- >
- <XCircleIcon className="size-4" />
- {t('admin.pages.orders.detail.claims.actions.deny')}
- </DropdownMenuItem>
- )}
- {['open', 'approved'].includes(claim.status) && (
- <DropdownMenuItem
- variant="destructive"
- onClick={async () => {
- if (
- await confirm({
- message: t('admin.pages.orders.detail.returns.confirm.cancel'),
- variant: 'destructive',
- confirmLabel: t('admin.actions.cancel'),
- })
- ) {
- cancel.mutate({ claimId: claim.id })
- }
- }}
- >
- <XCircleIcon className="size-4" />
- {t('admin.actions.cancel')}
- </DropdownMenuItem>
- )}
- </DropdownMenuContent>
- </DropdownMenu>
+ <CardAction>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button variant="ghost" size="icon-xs">
+ <EllipsisVerticalIcon className="size-4" />
+ <span className="sr-only">{t('admin.actions.actions_menu')}</span>
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ {claim.status === 'open' && (
+ <DropdownMenuItem onClick={() => approve.mutate(claim.id)}>
+ <CheckCircleIcon className="size-4" />
+ {t('admin.pages.orders.detail.returns.actions.approve')}
+ </DropdownMenuItem>
+ )}
+ {claim.status === 'approved' && (
+ <DropdownMenuItem onClick={() => setResolving(claim)}>
+ <BanknoteIcon className="size-4" />
+ {t('admin.pages.orders.detail.claims.actions.resolve')}
+ </DropdownMenuItem>
+ )}
+ {['open', 'approved'].includes(claim.status) && <DropdownMenuSeparator />}
+ {claim.status === 'open' && (
+ <DropdownMenuItem
+ variant="destructive"
+ onClick={async () => {
+ if (
+ await confirm({
+ message: t('admin.pages.orders.detail.claims.confirm.deny'),
+ variant: 'destructive',
+ confirmLabel: t('admin.pages.orders.detail.claims.actions.deny'),
+ })
+ ) {
+ deny.mutate({ claimId: claim.id })
+ }
+ }}
+ >
+ <BanIcon className="size-4" />
+ {t('admin.pages.orders.detail.claims.actions.deny')}
+ </DropdownMenuItem>
+ )}
+ {['open', 'approved'].includes(claim.status) && (
+ <DropdownMenuItem
+ variant="destructive"
+ onClick={async () => {
+ if (
+ await confirm({
+ message: t('admin.pages.orders.detail.returns.confirm.cancel'),
+ variant: 'destructive',
+ confirmLabel: t('admin.actions.cancel'),
+ })
+ ) {
+ cancel.mutate({ claimId: claim.id })
+ }
+ }}
+ >
+ <XCircleIcon className="size-4" />
+ {t('admin.actions.cancel')}
+ </DropdownMenuItem>
+ )}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </CardAction>
)}
- </div>
+ </CardHeader>
- <div className="flex flex-col gap-1.5">
+ <CardContent className="flex flex-col gap-1.5">
{(claim.claim_line_items ?? []).map((line) => (
<div key={line.id} className="flex items-center justify-between text-sm">
<span className="truncate">
@@ -320,15 +326,15 @@ export function OrderClaimsCard({ order }: { order: Order }) {
<span className="text-muted-foreground">×{line.quantity}</span>
</div>
))}
- </div>
+ </CardContent>
- <div className="flex items-center justify-between text-sm border-t pt-3">
+ <CardFooter className="justify-between text-sm">
<span className="text-muted-foreground">
{t('admin.pages.orders.detail.returns.refund_total')}
</span>
<span className="font-medium">{claim.display_refund_total}</span>
- </div>
- </div>
+ </CardFooter>
+ </Card>
))}
</CardContent>
</Card>
diff --git a/packages/dashboard/src/components/spree/order-returns-card.tsx b/packages/dashboard/src/components/spree/order-returns-card.tsx
index c39fef45ea..41e558d927 100644
--- a/packages/dashboard/src/components/spree/order-returns-card.tsx
+++ b/packages/dashboard/src/components/spree/order-returns-card.tsx
@@ -6,6 +6,7 @@ import {
Card,
CardAction,
CardContent,
+ CardFooter,
CardHeader,
CardTitle,
Dialog,
@@ -116,80 +117,82 @@ export function OrderReturnsCard({ order }: { order: Order }) {
</p>
)}
{returns.map((returnRecord) => (
- <div key={returnRecord.id} className="rounded-lg border p-4 flex flex-col gap-3">
- <div className="flex items-center justify-between">
- <div className="flex items-center gap-2">
+ <Card key={returnRecord.id} variant="nested">
+ <CardHeader>
+ <CardTitle className="text-sm font-medium">
<StatusBadge status={returnRecord.status} />
<span className="text-sm font-medium">{returnRecord.number}</span>
- </div>
+ </CardTitle>
{RETURN_ACTIONABLE.includes(returnRecord.status) && (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button variant="ghost" size="icon-xs">
- <EllipsisVerticalIcon className="size-4" />
- <span className="sr-only">{t('admin.actions.actions_menu')}</span>
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- {returnRecord.status === 'requested' && (
- <DropdownMenuItem onClick={() => approve.mutate(returnRecord.id)}>
- <CheckCircleIcon className="size-4" />
- {t('admin.pages.orders.detail.returns.actions.approve')}
- </DropdownMenuItem>
- )}
- {returnRecord.status === 'approved' && (
- <DropdownMenuItem onClick={() => setReceiving(returnRecord)}>
- <PackageCheckIcon className="size-4" />
- {t('admin.pages.orders.detail.returns.actions.receive')}
- </DropdownMenuItem>
- )}
- {returnRecord.status === 'received' && (
- <DropdownMenuItem onClick={() => setRefunding(returnRecord)}>
- <BanknoteIcon className="size-4" />
- {t('admin.pages.orders.detail.returns.actions.refund')}
- </DropdownMenuItem>
- )}
- {['requested', 'approved'].includes(returnRecord.status) && (
- <>
- <DropdownMenuSeparator />
- <DropdownMenuItem
- variant="destructive"
- onClick={async () => {
- if (
- await confirm({
- message: t('admin.pages.orders.detail.returns.confirm.cancel'),
- variant: 'destructive',
- confirmLabel: t('admin.actions.cancel'),
- })
- ) {
- cancel.mutate({ returnId: returnRecord.id })
- }
- }}
- >
- <XCircleIcon className="size-4" />
- {t('admin.actions.cancel')}
+ <CardAction>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button variant="ghost" size="icon-xs">
+ <EllipsisVerticalIcon className="size-4" />
+ <span className="sr-only">{t('admin.actions.actions_menu')}</span>
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ {returnRecord.status === 'requested' && (
+ <DropdownMenuItem onClick={() => approve.mutate(returnRecord.id)}>
+ <CheckCircleIcon className="size-4" />
+ {t('admin.pages.orders.detail.returns.actions.approve')}
</DropdownMenuItem>
- </>
- )}
- </DropdownMenuContent>
- </DropdownMenu>
+ )}
+ {returnRecord.status === 'approved' && (
+ <DropdownMenuItem onClick={() => setReceiving(returnRecord)}>
+ <PackageCheckIcon className="size-4" />
+ {t('admin.pages.orders.detail.returns.actions.receive')}
+ </DropdownMenuItem>
+ )}
+ {returnRecord.status === 'received' && (
+ <DropdownMenuItem onClick={() => setRefunding(returnRecord)}>
+ <BanknoteIcon className="size-4" />
+ {t('admin.pages.orders.detail.returns.actions.refund')}
+ </DropdownMenuItem>
+ )}
+ {['requested', 'approved'].includes(returnRecord.status) && (
+ <>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem
+ variant="destructive"
+ onClick={async () => {
+ if (
+ await confirm({
+ message: t('admin.pages.orders.detail.returns.confirm.cancel'),
+ variant: 'destructive',
+ confirmLabel: t('admin.actions.cancel'),
+ })
+ ) {
+ cancel.mutate({ returnId: returnRecord.id })
+ }
+ }}
+ >
+ <XCircleIcon className="size-4" />
+ {t('admin.actions.cancel')}
+ </DropdownMenuItem>
+ </>
+ )}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </CardAction>
)}
- </div>
+ </CardHeader>
- <div className="flex flex-col gap-1.5">
+ <CardContent className="flex flex-col gap-1.5">
{(returnRecord.return_line_items ?? []).map((line) => (
<ReturnLineRow key={line.id} line={line} status={returnRecord.status} />
))}
- </div>
+ </CardContent>
- <div className="flex items-center justify-between text-sm border-t pt-3">
+ <CardFooter className="justify-between text-sm">
<span className="text-muted-foreground">
{t('admin.pages.orders.detail.returns.refund_total')}
</span>
<span className="font-medium">{returnRecord.display_refund_total}</span>
- </div>
- </div>
+ </CardFooter>
+ </Card>
))}
</CardContent>
</Card>
@@ -286,10 +289,10 @@ function ReceiveDialog({
</DialogHeader>
<DialogBody className="flex flex-col gap-4">
{lines.map((line) => (
- <div key={line.id} className="flex flex-col gap-2 rounded-lg border p-3">
+ <div key={line.id} className="flex flex-col gap-3">
<span className="text-sm font-medium">{variantLabel(line)}</span>
- <div className="flex items-center gap-4">
- <Field className="flex-1">
+ <div className="flex flex-col gap-3">
+ <Field>
<FieldLabel htmlFor={`qty-${line.id}`}>
{t('admin.pages.orders.detail.returns.received_quantity')}
</FieldLabel>
diff --git a/packages/dashboard/src/components/spree/orders/fulfillment-fulfill-form.tsx b/packages/dashboard/src/components/spree/orders/fulfillment-fulfill-form.tsx
index a07b3dd271..aa6f5fa1e6 100644
--- a/packages/dashboard/src/components/spree/orders/fulfillment-fulfill-form.tsx
+++ b/packages/dashboard/src/components/spree/orders/fulfillment-fulfill-form.tsx
@@ -59,7 +59,9 @@ function ItemQuantityRow({
const checkboxId = `${idPrefix}-item-${index}`
return (
- <div className={cn('flex items-center gap-3 p-3', selected && 'bg-accent')}>
+ <div
+ className={cn('flex items-center gap-3 py-2 my-2 pl-2 rounded-lg', selected && 'bg-accent')}
+ >
<Controller
control={form.control}
name={`items.${index}.selected`}
@@ -246,7 +248,7 @@ export function FulfillmentFulfillForm({
</div>
)}
- <div className="grid grid-cols-1 gap-4 p-3 border-t sm:grid-cols-2">
+ <div className="grid grid-cols-1 gap-4 py-3 border-t border-border-subtle sm:grid-cols-2">
<Field>
<FieldLabel htmlFor={`${idPrefix}-tracking`}>
{t('admin.orders.fulfill.tracking_label')}
@@ -293,7 +295,7 @@ export function FulfillmentFulfillForm({
render={({ field }) => (
<label
htmlFor={`${idPrefix}-notify`}
- className="flex cursor-pointer items-center gap-2 text-sm p-3"
+ className="flex cursor-pointer items-center gap-2 text-sm py-3"
>
<Checkbox
id={`${idPrefix}-notify`}
@@ -314,7 +316,7 @@ export function FulfillmentFulfillForm({
</div>
)}
- <div className="flex items-center justify-end gap-2 p-3 border-t">
+ <div className="flex items-center justify-end gap-2 py-3 border-t border-border-subtle">
<span className="mr-auto text-sm text-muted-foreground">
{t('admin.orders.fulfill.units_selected')}: {totalSelected} / {totalAvailable}
</span>
diff --git a/packages/dashboard/src/components/spree/orders/fulfillments-card.tsx b/packages/dashboard/src/components/spree/orders/fulfillments-card.tsx
index f948ab5660..deb8b6f16e 100644
--- a/packages/dashboard/src/components/spree/orders/fulfillments-card.tsx
+++ b/packages/dashboard/src/components/spree/orders/fulfillments-card.tsx
@@ -6,6 +6,7 @@ import {
Card,
CardAction,
CardContent,
+ CardFooter,
CardHeader,
CardTitle,
Dialog,
@@ -38,7 +39,6 @@ import {
EllipsisVerticalIcon,
MapPinIcon,
PackageCheckIcon,
- PackageIcon,
PencilIcon,
PlusIcon,
PrinterIcon,
@@ -48,7 +48,7 @@ import {
TruckIcon,
XCircleIcon,
} from '@spree/dashboard-ui/icons'
-import { useState } from 'react'
+import { type ReactNode, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { useFulfillmentActions } from '../../../hooks/use-fulfillments'
import {
@@ -425,27 +425,21 @@ function FulfillmentRow({ order, fulfillment }: { order: Order; fulfillment: Ful
const trackable = deliverable && !fulfillment.tracking
return (
- <div className="rounded-lg border flex flex-col">
- <div className="flex items-center justify-between border-b p-3">
- <div className="flex items-center gap-2">
- <StatusBadge status={fulfillment.status} />
- {fulfillment.stock_location && (
- <div className="flex items-center gap-1.5 text-xs text-muted-foreground">
- <MapPinIcon className="size-3" />
- {fulfillment.stock_location.name}
- </div>
- )}
-
- {fulfillment.fulfilled_at && (
- <span className="text-xs text-muted-foreground">
- <RelativeTime
- iso={fulfillment.fulfilled_at}
- prefix={t('admin.orders.detail.tracking.shipped_prefix')}
- fallback=""
- />
- </span>
- )}
- </div>
+ <FulfillmentPanel
+ status={fulfillment.status}
+ location={fulfillment.stock_location?.name}
+ meta={
+ fulfillment.fulfilled_at && (
+ <span className="text-muted-foreground text-xs">
+ <RelativeTime
+ iso={fulfillment.fulfilled_at}
+ prefix={t('admin.orders.detail.tracking.shipped_prefix')}
+ fallback=""
+ />
+ </span>
+ )
+ }
+ actions={
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" size="icon-xs">
@@ -511,10 +505,10 @@ function FulfillmentRow({ order, fulfillment }: { order: Order; fulfillment: Ful
)}
</DropdownMenuContent>
</DropdownMenu>
- </div>
-
+ }
+ >
{(fulfillment.delivery_method || Number.parseFloat(fulfillment.cost) > 0) && (
- <div className="flex items-center justify-between text-sm p-3 border-b">
+ <CardContent className="flex items-center justify-between border-b border-border-subtle py-3 text-sm">
<span className="text-muted-foreground">
{/* The selected rate names the carrier service that actually
carries this parcel ("USPS GroundAdvantage"); the method is
@@ -525,11 +519,11 @@ function FulfillmentRow({ order, fulfillment }: { order: Order; fulfillment: Ful
t('admin.pages.orders.detail.no_delivery_method')}
</span>
<span>{fulfillment.display_cost}</span>
- </div>
+ </CardContent>
)}
{fulfillment.tracking && !fulfilling && (
- <div className="text-sm p-3 border-b">
+ <CardContent className="border-b border-border-subtle py-3 text-sm">
<span className="text-muted-foreground">
{fulfillment.tracking_carrier_name ?? t('admin.orders.detail.tracking.prefix')}:{' '}
</span>
@@ -545,7 +539,7 @@ function FulfillmentRow({ order, fulfillment }: { order: Order; fulfillment: Ful
) : (
<span>{fulfillment.tracking}</span>
)}
- </div>
+ </CardContent>
)}
{fulfilling ? (
@@ -559,7 +553,7 @@ function FulfillmentRow({ order, fulfillment }: { order: Order; fulfillment: Ful
<FulfillmentItemList rows={fulfillmentItemRows(fulfillment, order.items ?? [])} />
{shippable && (
- <div className="flex justify-end gap-2 p-3 border-t">
+ <CardFooter className="justify-end gap-2 py-3">
{canBuyLabel && (
<Button
type="button"
@@ -604,22 +598,22 @@ function FulfillmentRow({ order, fulfillment }: { order: Order; fulfillment: Ful
<TruckIcon data-icon="inline-start" />
{t('admin.orders.fulfill.action')}
</Button>
- </div>
+ </CardFooter>
)}
{!shippable && labelDocument && (
- <div className="flex justify-end p-3 border-t">
+ <CardFooter className="justify-end py-3">
<Button type="button" size="sm" variant="outline" asChild>
<a href={labelDocument.url} target="_blank" rel="noopener noreferrer">
<PrinterIcon data-icon="inline-start" />
{t('admin.orders.detail.fulfillments.print_label')}
</a>
</Button>
- </div>
+ </CardFooter>
)}
{deliverable && (
- <div className="flex justify-end gap-2 p-3 border-t">
+ <CardFooter className="justify-end gap-2 py-3">
<Button
type="button"
size="sm"
@@ -637,7 +631,7 @@ function FulfillmentRow({ order, fulfillment }: { order: Order; fulfillment: Ful
{t('admin.orders.detail.fulfillments.add_tracking')}
</Button>
)}
- </div>
+ </CardFooter>
)}
</>
)}
@@ -668,7 +662,53 @@ function FulfillmentRow({ order, fulfillment }: { order: Order; fulfillment: Ful
onOpenChange={setTrackingOpen}
/>
)}
- </div>
+ </FulfillmentPanel>
+ )
+}
+
+/**
+ * The chrome every fulfillment panel shares: a status badge, where it ships
+ * from, and the items in it.
+ *
+ * A draft order has no `Fulfillment` record yet — no id, no location, nothing
+ * to act on — so the two callers pass what they have rather than one of them
+ * inventing a record. What they do share is how it looks.
+ */
+function FulfillmentPanel({
+ status,
+ location,
+ meta,
+ actions,
+ children,
+}: {
+ status: string
+ /** Where it ships from. Absent until a fulfillment exists. */
+ location?: string | null
+ /** Trailing header detail, e.g. when it shipped. */
+ meta?: ReactNode
+ /** The panel's own menu. Absent when there is nothing to act on. */
+ actions?: ReactNode
+ children: ReactNode
+}) {
+ return (
+ <Card variant="nested">
+ <CardHeader>
+ <CardTitle className="min-w-0 text-sm font-normal">
+ <StatusBadge status={status} />
+ {location && (
+ <div className="flex min-w-0 items-center gap-1.5 text-muted-foreground text-xs">
+ <MapPinIcon className="size-3 shrink-0" />
+ {/* The card clips its overflow, so a long warehouse name has to
+ truncate here or it is simply cut off. */}
+ <span className="truncate">{location}</span>
+ </div>
+ )}
+ {meta}
+ </CardTitle>
+ {actions && <CardAction>{actions}</CardAction>}
+ </CardHeader>
+ {children}
+ </Card>
)
}
@@ -679,20 +719,23 @@ function FulfillmentRow({ order, fulfillment }: { order: Order; fulfillment: Ful
*/
function UnfulfilledGroup({ rows }: { rows: FulfillmentItemRow[] }) {
const { t } = useTranslation()
-
const totalUnits = rows.reduce((sum, row) => sum + row.quantity, 0)
return (
- <div className="rounded-lg border p-4 flex flex-col gap-3">
- <div className="flex items-center gap-2">
- <PackageIcon className="size-4 text-muted-foreground" />
- <span className="text-sm font-medium">
+ <FulfillmentPanel
+ status="unfulfilled"
+ // The badge names the state; the count says how much is in it, which a
+ // real fulfillment carries in its own rows instead.
+ meta={
+ <span className="text-muted-foreground text-xs">
{t('admin.orders.detail.fulfillments.unfulfilled', { count: totalUnits })}
</span>
- </div>
-
- <FulfillmentItemList rows={rows} />
- </div>
+ }
+ >
+ <CardContent className="px-0 py-3">
+ <FulfillmentItemList rows={rows} />
+ </CardContent>
+ </FulfillmentPanel>
)
}
diff --git a/packages/dashboard/src/components/spree/orders/order-skeleton.tsx b/packages/dashboard/src/components/spree/orders/order-skeleton.tsx
index e89f28d133..0fa9526195 100644
--- a/packages/dashboard/src/components/spree/orders/order-skeleton.tsx
+++ b/packages/dashboard/src/components/spree/orders/order-skeleton.tsx
@@ -3,11 +3,21 @@ import { Skeleton } from '@spree/dashboard-ui'
export function OrderSkeleton() {
return (
<div className="flex flex-col gap-6">
- <div className="flex items-center gap-3">
- <Skeleton className="size-8 rounded-lg" />
- <Skeleton className="h-8 w-40" />
- <Skeleton className="h-5 w-16 rounded-md" />
- <Skeleton className="h-5 w-16 rounded-md" />
+ {/* Mirrors PageHeader: the number on its own line, statuses and the
+ timestamp on the one below, so the page does not reflow when the
+ order lands. */}
+ <div className="flex items-start gap-3">
+ <Skeleton className="size-8 shrink-0 rounded-lg" />
+ <div className="flex flex-col gap-1">
+ <Skeleton className="h-8 w-40" />
+ {/* Wraps like the real header's badge row, so a narrow viewport
+ does not reflow the moment the order lands. */}
+ <div className="flex flex-wrap items-center gap-3">
+ <Skeleton className="h-5 w-20 shrink-0 rounded-md" />
+ <Skeleton className="h-5 w-20 shrink-0 rounded-md" />
+ <Skeleton className="h-4 w-32" />
+ </div>
+ </div>
</div>
<div className="grid grid-cols-12 gap-6">
<div className="col-span-12 lg:col-span-8 flex flex-col gap-6">
diff --git a/packages/dashboard/src/components/spree/post-sale-create-dialogs.tsx b/packages/dashboard/src/components/spree/post-sale-create-dialogs.tsx
index 9de8513a1b..ef4752bcc5 100644
--- a/packages/dashboard/src/components/spree/post-sale-create-dialogs.tsx
+++ b/packages/dashboard/src/components/spree/post-sale-create-dialogs.tsx
@@ -1,5 +1,5 @@
-import type { Claim, Order } from '@spree/admin-sdk'
-import { currencyParts, useStore } from '@spree/dashboard-core'
+import type { Claim, Order, Variant } from '@spree/admin-sdk'
+import { adminClient, currencyParts, ResourceCombobox, useStore } from '@spree/dashboard-core'
import {
Button,
Dialog,
@@ -42,6 +42,9 @@ export type FulfilledUnit = {
* order is complete and not canceled, and a merchant may well open a return
* on something still in the warehouse.
*/
+/** `id` always comes back, so it need not be listed. */
+const VARIANT_PICKER_FIELDS = ['product_name', 'sku', 'options_text']
+
export function fulfilledUnits(order: Order): FulfilledUnit[] {
return (order.fulfillments ?? []).flatMap((fulfillment) =>
(fulfillment.fulfillment_items ?? []).map((item) => ({
@@ -267,13 +270,38 @@ export function CreateExchangeDialog({
<FieldLabel htmlFor={`replacement-${unit.id}`}>
{t('admin.pages.orders.detail.exchanges.replacement_variant')}
</FieldLabel>
- <Input
- id={`replacement-${unit.id}`}
- placeholder="variant_..."
+ <ResourceCombobox<Variant>
+ queryKey={`exchange-replacement-${unit.id}`}
value={replacements[unit.id] ?? ''}
- onChange={(event) =>
- setReplacements({ ...replacements, [unit.id]: event.target.value })
+ onChange={(id) => setReplacements({ ...replacements, [unit.id]: id ?? '' })}
+ // Only what the option renders. This trims the response;
+ // the server still computes the rest.
+ search={(query) =>
+ adminClient.variants.list({
+ search: query,
+ limit: 8,
+ fields: VARIANT_PICKER_FIELDS,
+ })
+ }
+ hydrate={(ids) =>
+ adminClient.variants.list({
+ id_in: ids,
+ limit: ids.length,
+ fields: VARIANT_PICKER_FIELDS,
+ })
}
+ getOptionLabel={(variant) => variant.product_name ?? variant.sku ?? variant.id}
+ renderOption={(variant) => (
+ <div className="flex flex-col">
+ <span className="font-medium">
+ {variant.product_name ?? variant.sku ?? variant.id}
+ </span>
+ <span className="text-xs text-muted-foreground">
+ {variant.options_text && <span>{variant.options_text} · </span>}
+ {t('admin.orders.detail.variant_search.sku_prefix')}: {variant.sku || '—'}
+ </span>
+ </div>
+ )}
/>
</Field>
)}
diff --git a/packages/dashboard/src/components/spree/route-pending.tsx b/packages/dashboard/src/components/spree/route-pending.tsx
index 0286c8c059..789b51ffd0 100644
--- a/packages/dashboard/src/components/spree/route-pending.tsx
+++ b/packages/dashboard/src/components/spree/route-pending.tsx
@@ -39,9 +39,14 @@ export function ResourceDetailSkeleton({ sidebar = true }: { sidebar?: boolean }
<span role="status" className="sr-only">
{t('admin.common.loading')}
</span>
- <div className="flex flex-col gap-2">
+ {/* Mirrors PageHeader: the title on its own line, statuses and the
+ timestamp sharing the one below. */}
+ <div className="flex flex-col gap-1">
<Skeleton className="h-8 w-64" />
- <Skeleton className="h-4 w-40" />
+ <div className="flex items-center gap-3">
+ <Skeleton className="h-5 w-20 rounded-md" />
+ <Skeleton className="h-4 w-32" />
+ </div>
</div>
{sidebar ? (
<div className="grid grid-cols-12 gap-6">
diff --git a/packages/dashboard/src/locales/ar.json b/packages/dashboard/src/locales/ar.json
index ff25229014..d41deff2b8 100644
--- a/packages/dashboard/src/locales/ar.json
+++ b/packages/dashboard/src/locales/ar.json
@@ -3077,7 +3077,7 @@
"create_title": "استبدال جديد",
"empty": "لا توجد استبدالات لهذا الطلب.",
"price_difference": "فرق السعر",
- "replacement_variant": "معرّف النسخة البديلة"
+ "replacement_variant": "النسخة البديلة"
},
"no_delivery_method": "لم يتم اختيار طريقة توصيل.",
"returns": {
diff --git a/packages/dashboard/src/locales/de.json b/packages/dashboard/src/locales/de.json
index f0ab1b9928..0024fc87df 100644
--- a/packages/dashboard/src/locales/de.json
+++ b/packages/dashboard/src/locales/de.json
@@ -3060,7 +3060,7 @@
"create_title": "Neuer Umtausch",
"empty": "Kein Umtausch für diese Bestellung.",
"price_difference": "Preisdifferenz",
- "replacement_variant": "Varianten-ID des Ersatzes"
+ "replacement_variant": "Ersatzvariante"
},
"no_delivery_method": "Keine Versandmethode ausgewählt.",
"returns": {
diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.json
index 33188792a4..d7c935123c 100644
--- a/packages/dashboard/src/locales/en.json
+++ b/packages/dashboard/src/locales/en.json
@@ -3060,7 +3060,7 @@
"create_title": "New exchange",
"empty": "No exchanges for this order.",
"price_difference": "Price difference",
- "replacement_variant": "Replacement variant ID"
+ "replacement_variant": "Replacement variant"
},
"no_delivery_method": "No delivery method selected.",
"returns": {
diff --git a/packages/dashboard/src/locales/fr.json b/packages/dashboard/src/locales/fr.json
index b3470e7273..881a25e92b 100644
--- a/packages/dashboard/src/locales/fr.json
+++ b/packages/dashboard/src/locales/fr.json
@@ -3060,7 +3060,7 @@
"create_title": "Nouvel échange",
"empty": "Aucun échange pour cette commande.",
"price_difference": "Différence de prix",
- "replacement_variant": "ID de la variante de remplacement"
+ "replacement_variant": "Variante de remplacement"
},
"no_delivery_method": "Aucune méthode de livraison sélectionnée.",
"returns": {
diff --git a/packages/dashboard/src/locales/pl.json b/packages/dashboard/src/locales/pl.json
index 67e292427f..0b2a640b75 100644
--- a/packages/dashboard/src/locales/pl.json
+++ b/packages/dashboard/src/locales/pl.json
@@ -3088,7 +3088,7 @@
"create_title": "Nowa wymiana",
"empty": "Brak wymian dla tego zamówienia.",
"price_difference": "Różnica w cenie",
- "replacement_variant": "ID wariantu zamiennego"
+ "replacement_variant": "Wariant zamienny"
},
"no_delivery_method": "Nie wybrano metody dostawy.",
"returns": {
diff --git a/packages/dashboard/src/locales/zh-CN.json b/packages/dashboard/src/locales/zh-CN.json
index d0ffd01eba..e2005119dd 100644
--- a/packages/dashboard/src/locales/zh-CN.json
+++ b/packages/dashboard/src/locales/zh-CN.json
@@ -3052,7 +3052,7 @@
"create_title": "新建换货",
"empty": "此订单暂无换货。",
"price_difference": "差价",
- "replacement_variant": "替换变体 ID"
+ "replacement_variant": "替换变体"
},
"no_delivery_method": "未选择配送方式。",
"returns": {
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx
index 8eb4f95e2d..0640333fdb 100644
--- a/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx
+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx
@@ -336,11 +336,16 @@ function ProductForm({ product }: { product: Product }) {
function ProductSkeleton() {
return (
<div className="flex flex-col gap-6">
- <div className="flex items-center gap-3">
- <Skeleton className="size-8 rounded-lg" />
- <Skeleton className="h-8 w-48" />
- <Skeleton className="h-5 w-16 rounded-md" />
- <div className="ml-auto flex items-center gap-2">
+ {/* Mirrors PageHeader: the name on its own line, the status below it. */}
+ <div className="flex items-start gap-3">
+ <Skeleton className="size-8 shrink-0 rounded-lg" />
+ {/* Yields width to the actions rather than pushing them off a narrow
+ viewport, which is what the real header does. */}
+ <div className="flex min-w-0 flex-1 flex-col gap-1">
+ <Skeleton className="h-8 w-full max-w-48" />
+ <Skeleton className="h-5 w-20 rounded-md" />
+ </div>
+ <div className="flex shrink-0 items-center gap-2">
<Skeleton className="h-8 w-20 rounded-lg" />
<Skeleton className="h-8 w-16 rounded-lg" />
</div>
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/catalogs/$catalogId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/catalogs/$catalogId.tsx
index 7261c23474..c6712e6a38 100644
--- a/packages/dashboard/src/routes/_authenticated/$storeId/products/catalogs/$catalogId.tsx
+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/catalogs/$catalogId.tsx
@@ -8,7 +8,7 @@ import {
usePermissions,
} from '@spree/dashboard-core'
import {
- Badge,
+ ActiveBadge,
Button,
Card,
CardContent,
@@ -224,9 +224,11 @@ function CatalogBody({ catalog }: { catalog: Catalog }) {
<PageHeader
title={catalog.name}
badges={
- catalog.active ? undefined : (
- <Badge variant="secondary">{t('admin.common.inactive')}</Badge>
- )
+ <ActiveBadge
+ active={catalog.active}
+ activeLabel={t('admin.common.active')}
+ inactiveLabel={t('admin.common.inactive')}
+ />
}
backTo="products/catalogs"
resource={{ id: catalog.id }}
diff --git a/spree/core/config/locales/en.yml b/spree/core/config/locales/en.yml
index ee65c21d71..912bb05119 100644
--- a/spree/core/config/locales/en.yml
+++ b/spree/core/config/locales/en.yml
@@ -1259,6 +1259,7 @@ en:
next: Next
no_cc_type: N/A
no_payment_found: No payment found
+ no_refundable_payments: There is no payment left on this order to refund.
no_report_data: No report data
none: None
normal_amount: Normal Amount
@@ -1266,7 +1267,9 @@ en:
not_available: N/A
not_enough_stock: There is not enough inventory at the source location to complete this transfer.
not_found: "%{resource} is not found"
+ not_received: This return cannot be refunded until its items are marked received.
note: Note
+ nothing_to_refund: There is nothing left to refund on this return.
number: Number
ok: OK
on_hand: On Hand
@@ -1533,6 +1536,7 @@ en:
reference: Reference
refund: Refund
refund_amount: Refund Amount
+ refund_exceeds_balance: That is more than the amount still refundable.
refunds: Refunds
register: Register
registration: Registration