fix(dashboard): Add empty state for media section (#7614)
This commit is contained in:
committed by
GitHub
parent
d2e1e9f8c7
commit
8387c72e96
@@ -217,7 +217,11 @@
|
||||
"galleryLabel": "Gallery",
|
||||
"downloadImageLabel": "Download current image",
|
||||
"deleteImageLabel": "Delete current image",
|
||||
"noMediaLabel": "The product has no associated media."
|
||||
"emptyState": {
|
||||
"header": "No media yet",
|
||||
"description": "Add media to the product to showcase it in your storefront.",
|
||||
"action": "Add media"
|
||||
}
|
||||
},
|
||||
"discountableHint": "When unchecked discounts will not be applied to this product.",
|
||||
"noSalesChannels": "Not available in any sales channels",
|
||||
|
||||
+24
-1
@@ -1,10 +1,12 @@
|
||||
import { PencilSquare, ThumbnailBadge } from "@medusajs/icons"
|
||||
import { Product } from "@medusajs/medusa"
|
||||
import {
|
||||
Button,
|
||||
Checkbox,
|
||||
CommandBar,
|
||||
Container,
|
||||
Heading,
|
||||
Text,
|
||||
Tooltip,
|
||||
clx,
|
||||
usePrompt,
|
||||
@@ -97,7 +99,7 @@ export const ProductMediaSection = ({ product }: ProductMedisaSectionProps) => {
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
{media && (
|
||||
{media.length > 0 ? (
|
||||
<div className="grid grid-cols-[repeat(auto-fill,minmax(96px,1fr))] gap-4 px-6 py-4">
|
||||
{media.map((i, index) => {
|
||||
const isSelected = selection[i.id]
|
||||
@@ -138,6 +140,27 @@ export const ProductMediaSection = ({ product }: ProductMedisaSectionProps) => {
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex flex-col items-center gap-y-4 pb-8 pt-6">
|
||||
<div className="flex flex-col items-center">
|
||||
<Text
|
||||
size="small"
|
||||
leading="compact"
|
||||
weight="plus"
|
||||
className="text-ui-fg-subtle"
|
||||
>
|
||||
{t("products.media.emptyState.header")}
|
||||
</Text>
|
||||
<Text size="small" className="text-ui-fg-muted">
|
||||
{t("products.media.emptyState.description")}
|
||||
</Text>
|
||||
</div>
|
||||
<Button size="small" variant="secondary" asChild>
|
||||
<Link to="media?view=edit">
|
||||
{t("products.media.emptyState.action")}
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
<CommandBar open={!!Object.keys(selection).length}>
|
||||
<CommandBar.Bar>
|
||||
|
||||
+17
-4
@@ -1,6 +1,5 @@
|
||||
import {
|
||||
ArrowDownTray,
|
||||
ExclamationCircle,
|
||||
ThumbnailBadge,
|
||||
Trash,
|
||||
TriangleLeftMini,
|
||||
@@ -172,9 +171,23 @@ const Canvas = ({ media, curr }: { media: Media[]; curr: number }) => {
|
||||
|
||||
if (media.length === 0) {
|
||||
return (
|
||||
<div className="bg-ui-bg-subtle text-ui-fg-subtle flex size-full flex-col items-center justify-center gap-y-2">
|
||||
<ExclamationCircle />
|
||||
<Text size="small">{t("products.media.noMediaLabel")}</Text>
|
||||
<div className="bg-ui-bg-subtle flex size-full flex-col items-center justify-center gap-y-4 pb-8 pt-6">
|
||||
<div className="flex flex-col items-center">
|
||||
<Text
|
||||
size="small"
|
||||
leading="compact"
|
||||
weight="plus"
|
||||
className="text-ui-fg-subtle"
|
||||
>
|
||||
{t("products.media.emptyState.header")}
|
||||
</Text>
|
||||
<Text size="small" className="text-ui-fg-muted">
|
||||
{t("products.media.emptyState.description")}
|
||||
</Text>
|
||||
</div>
|
||||
<Button size="small" variant="secondary" asChild>
|
||||
<Link to="?view=edit">{t("products.media.emptyState.action")}</Link>
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user