-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: product details sidebar, refactor sidebar link
- Loading branch information
Showing
9 changed files
with
123 additions
and
41 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
packages/admin/dashboard/src/components/common/sidebar-link/indext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./sidebar-link" |
47 changes: 47 additions & 0 deletions
47
packages/admin/dashboard/src/components/common/sidebar-link/sidebar-link.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { ReactNode } from "react" | ||
import { Link } from "react-router-dom" | ||
|
||
import { IconAvatar } from "../icon-avatar" | ||
import { Text } from "@medusajs/ui" | ||
import { TriangleRightMini } from "@medusajs/icons" | ||
|
||
export interface SidebarLinkProps { | ||
to: string | ||
labelKey: string | ||
descriptionKey: string | ||
icon: ReactNode | ||
} | ||
|
||
export const SidebarLink = ({ | ||
to, | ||
labelKey, | ||
descriptionKey, | ||
icon, | ||
}: SidebarLinkProps) => { | ||
return ( | ||
<Link to={to} className="group outline-none"> | ||
<div className="flex flex-col gap-2 px-2 pb-2"> | ||
<div className="shadow-elevation-card-rest bg-ui-bg-component transition-fg hover:bg-ui-bg-component-hover active:bg-ui-bg-component-pressed group-focus-visible:shadow-borders-interactive-with-active rounded-md px-4 py-2"> | ||
<div className="flex items-center gap-4"> | ||
<IconAvatar>{icon}</IconAvatar> | ||
<div className="flex flex-1 flex-col"> | ||
<Text size="small" leading="compact" weight="plus"> | ||
{labelKey} | ||
</Text> | ||
<Text | ||
size="small" | ||
leading="compact" | ||
className="text-ui-fg-subtle" | ||
> | ||
{descriptionKey} | ||
</Text> | ||
</div> | ||
<div className="flex size-7 items-center justify-center"> | ||
<TriangleRightMini className="text-ui-fg-muted" /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</Link> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...d/src/routes/products/product-detail/components/product-shipping-profile-section/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./product-shipping-profile-section" |
53 changes: 53 additions & 0 deletions
53
...t-detail/components/product-shipping-profile-section/product-shipping-profile-section.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { PencilSquare, ShoppingBag } from "@medusajs/icons" | ||
import { HttpTypes } from "@medusajs/types" | ||
import { Container, Heading } from "@medusajs/ui" | ||
import { useTranslation } from "react-i18next" | ||
|
||
import { SidebarLink } from "../../../../../components/common/sidebar-link/sidebar-link" | ||
import { ActionMenu } from "../../../../../components/common/action-menu" | ||
|
||
type ProductShippingProfileSectionProps = { | ||
product: HttpTypes.AdminProduct & { | ||
shipping_profile: HttpTypes.AdminShippingProfile | ||
} | ||
} | ||
|
||
export const ProductShippingProfileSection = ({ | ||
product, | ||
}: ProductShippingProfileSectionProps) => { | ||
const { t } = useTranslation() | ||
|
||
const shippingProfile = product.shipping_profile | ||
|
||
if (!shippingProfile) { | ||
return null | ||
} | ||
|
||
return ( | ||
<Container className="p-0"> | ||
<div className="flex items-center justify-between px-6 py-4"> | ||
<Heading level="h2">{t("products.shippingProfile.header")}</Heading> | ||
<ActionMenu | ||
groups={[ | ||
{ | ||
actions: [ | ||
{ | ||
label: t("actions.edit"), | ||
to: "shipping-profile", | ||
icon: <PencilSquare />, | ||
}, | ||
], | ||
}, | ||
]} | ||
/> | ||
</div> | ||
|
||
<SidebarLink | ||
to={`/settings/locations/shipping-profiles/${shippingProfile.id}`} | ||
labelKey={shippingProfile.name} | ||
descriptionKey={shippingProfile.type} | ||
icon={<ShoppingBag />} | ||
/> | ||
</Container> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters