Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix admin error in products page #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 73 additions & 65 deletions src/admin/widgets/category-images-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,77 +43,85 @@ const CategoriesImagesWidget = ({

return (
<>
<Container title="Categories Images">
<Heading
level="h1"
className="flex items-center justify-between gap-x-4 text-2xl font-semibold"
>
<div>Categories Images. Found {medusaProduct.categories.length} categories</div>
</Heading>
{loading && <Spinner></Spinner>}
{!loading && medusaProduct.categories.map((category) => (
<div key={category.id} className="mt-3 w-full">
<div className="flex items-center">
<div className="inter-base-semibold flex-1">{category.name}</div>
<DropdownMenu>
<DropdownMenu.Trigger asChild>
<Button variant="secondary" format={'icon'}>
<EllipsisHorizontal />
</Button>
</DropdownMenu.Trigger>
<DropdownMenu.Content>
<DropdownMenu.Item
onClick={() => {
setOpenedCategory(category);
setOpenedDialogType('thumbnail');
}}
className="gap-x-2"
>
<PencilSquare className="text-ui-fg-subtle" />
Edit Thumbnail
</DropdownMenu.Item>
<DropdownMenu.Item
onClick={() => {
setOpenedCategory(category);
setOpenedDialogType('media');
}}
className="gap-x-2"
>
<PencilSquare className="text-ui-fg-subtle" />
Edit Media
</DropdownMenu.Item>
</DropdownMenu.Content>
</DropdownMenu>
{loading && <Spinner></Spinner>}
{!loading && !!medusaProduct.categories.length && (
<Container title="Categories Images">
<Heading
level="h1"
className="flex items-center justify-between gap-x-4 text-2xl font-semibold"
>
<div>
Categories Images. Found {medusaProduct.categories.length}{" "}
categories
</div>
<div className="flex flex-wrap items-center">
{category.thumbnail ? (
<img
src={category.thumbnail}
alt="Thumbnail"
className="mr-1 mt-1 h-20 w-20 object-cover"
/>
) : (
<div className="inter-regular mr-1 w-20 break-words">
No thumbnail
</div>
)}
</Heading>

{category.images.length ? (
category.images.map((image) => (
{medusaProduct.categories?.map((category) => (
<div key={category.id} className="mt-3 w-full">
<div className="flex items-center">
<div className="inter-base-semibold flex-1">
{category.name}
</div>
<DropdownMenu>
<DropdownMenu.Trigger asChild>
<Button variant="secondary">
<EllipsisHorizontal />
</Button>
</DropdownMenu.Trigger>
<DropdownMenu.Content>
<DropdownMenu.Item
onClick={() => {
setOpenedCategory(category);
setOpenedDialogType("thumbnail");
}}
className="gap-x-2"
>
<PencilSquare className="text-ui-fg-subtle" />
Edit Thumbnail
</DropdownMenu.Item>
<DropdownMenu.Item
onClick={() => {
setOpenedCategory(category);
setOpenedDialogType("media");
}}
className="gap-x-2"
>
<PencilSquare className="text-ui-fg-subtle" />
Edit Media
</DropdownMenu.Item>
</DropdownMenu.Content>
</DropdownMenu>
</div>
<div className="flex flex-wrap items-center">
{category.thumbnail ? (
<img
key={image.id}
src={image.url}
alt="Uploaded image"
src={category.thumbnail}
alt="Thumbnail"
className="mr-1 mt-1 h-20 w-20 object-cover"
/>
))
) : (
<span className="inter-regular">No images...</span>
)}
) : (
<div className="inter-regular mr-1 w-20 break-words">
No thumbnail
</div>
)}

{category.images.length ? (
category.images.map((image) => (
<img
key={image.id}
src={image.url}
alt="Uploaded image"
className="mr-1 mt-1 h-20 w-20 object-cover"
/>
))
) : (
<span className="inter-regular">No images...</span>
)}
</div>
</div>
</div>
))}
</Container>
))}
</Container>
)}

{openedDialogType && (
<CategoriesImagesModal
Expand Down