fix(admin-ui): Edit prices requires at least one product (#5710)

This commit is contained in:
Kasper Fabricius Kristensen authored and GitHub committed 2023-11-24 13:54:07 +00:00
1 parent f4c489fb85
commit 07934cdaac
5 files changed
+32 -30

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@medusajs/admin-ui": patch
---
fix(admin-ui): Ensure that the prices step is disabled until at least one product is selected in PriceList forms
@@ -571,7 +571,7 @@ const AddProductsModal = ({
</span> </span>
</ProgressTabs.Trigger> </ProgressTabs.Trigger>
<ProgressTabs.Trigger <ProgressTabs.Trigger
disabled={selectedIds.length === 0} disabled={status[Tab.PRODUCTS] !== "completed"}
value={Tab.PRICES} value={Tab.PRICES}
className="w-full max-w-[200px]" className="w-full max-w-[200px]"
status={status[Tab.PRICES]} status={status[Tab.PRICES]}
@@ -97,19 +97,17 @@ const PriceListPricesForm = ({
<Heading> <Heading>
{t("price-list-prices-form-heading", "Edit prices")} {t("price-list-prices-form-heading", "Edit prices")}
</Heading> </Heading>
{isDirty && ( <Form.Field
<Form.Field control={control}
control={control} name={path("products")}
name={path("products")} render={() => {
render={() => { return (
return ( <Form.Item>
<Form.Item> <Form.ErrorMessage />
<Form.ErrorMessage /> </Form.Item>
</Form.Item> )
) }}
}} />
/>
)}
</div> </div>
<div className="flex items-center gap-x-2"> <div className="flex items-center gap-x-2">
<ProductFilterMenu <ProductFilterMenu
@@ -129,7 +127,7 @@ const PriceListPricesForm = ({
<div className="border-ui-border-base border-b"> <div className="border-ui-border-base border-b">
<table className="w-full text-left"> <table className="w-full text-left">
<thead> <thead>
<tr className="[&_th]:text-ui-fg-subtle [&_th]:txt-compact-small-plus border-ui-border-base [&_th]:w-1/3 [&_th]:border-r [&_th]:px-4 [&_th]:py-2.5 [&_th:last-of-type]:border-r-0"> <tr className="[&_th]:text-ui-fg-subtle [&_th]:txt-compact-small-plus border-ui-border-base [&_th:last-of-type]:border-r-0 [&_th]:w-1/3 [&_th]:border-r [&_th]:px-4 [&_th]:py-2.5">
<th>{t("price-list-prices-form-variant", "Variant")}</th> <th>{t("price-list-prices-form-variant", "Variant")}</th>
<th>{t("price-list-prices-form-sku", "SKU")}</th> <th>{t("price-list-prices-form-sku", "SKU")}</th>
<th className="text-right"> <th className="text-right">
@@ -376,24 +376,23 @@ const PriceListProductsForm = ({
return ( return (
<div className="flex h-full flex-col"> <div className="flex h-full flex-col">
<div className="border-ui-border-base flex items-center justify-between border-b px-8 pt-6 pb-4"> <div className="border-ui-border-base flex items-center justify-between border-b px-8 pb-4 pt-6">
<div className="flex items-center gap-x-3"> <div className="flex items-center gap-x-3">
<Heading> <Heading>
{t("price-list-products-form-heading", "Choose products")} {t("price-list-products-form-heading", "Choose products")}
</Heading> </Heading>
{isDirty && (
<Form.Field <Form.Field
control={control} control={control}
name={path("ids")} name={path("ids")}
render={() => { render={() => {
return ( return (
<Form.Item> <Form.Item>
<Form.ErrorMessage /> <Form.ErrorMessage />
</Form.Item> </Form.Item>
) )
}} }}
/> />
)}
</div> </div>
<div className={clx("flex items-center gap-x-2")}> <div className={clx("flex items-center gap-x-2")}>
<ProductFilterMenu <ProductFilterMenu
@@ -631,7 +631,7 @@ const PriceListNew = () => {
<ProgressTabs.Trigger <ProgressTabs.Trigger
value={Tab.PRICES} value={Tab.PRICES}
disabled={ disabled={
status[Tab.DETAILS] !== "completed" && status[Tab.DETAILS] !== "completed" ||
status[Tab.PRODUCTS] !== "completed" status[Tab.PRODUCTS] !== "completed"
} }
className="w-full min-w-0 max-w-[200px]" className="w-full min-w-0 max-w-[200px]"