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