fix(dashboard): categories add products (#9380)
**What** - fix listing/adding products in the add category products flow --- FIXES CC-523
This commit is contained in:
@@ -134,7 +134,7 @@ export const useUpdateProductCategoryProducts = (
|
||||
onSuccess: (data, variables, context) => {
|
||||
queryClient.invalidateQueries({ queryKey: categoriesQueryKeys.lists() })
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: categoriesQueryKeys.detail(id),
|
||||
queryKey: categoriesQueryKeys.details(),
|
||||
})
|
||||
/**
|
||||
* Invalidate products list query to ensure that the products collections are updated.
|
||||
|
||||
+5
-7
@@ -6,14 +6,12 @@ import { EditCategoryProductsForm } from "./components/edit-category-products-fo
|
||||
export const CategoryProducts = () => {
|
||||
const { id } = useParams()
|
||||
|
||||
const { product_category, isPending, isError, error } = useProductCategory(
|
||||
id!,
|
||||
{
|
||||
fields: "*products",
|
||||
}
|
||||
)
|
||||
const { product_category, isPending, isFetching, isError, error } =
|
||||
useProductCategory(id!, {
|
||||
fields: "products.id",
|
||||
})
|
||||
|
||||
const ready = !isPending && !!product_category
|
||||
const ready = !isPending && !isFetching && !!product_category
|
||||
|
||||
if (isError) {
|
||||
throw error
|
||||
|
||||
+3
-4
@@ -25,7 +25,7 @@ import { useDataTable } from "../../../../../hooks/use-data-table"
|
||||
|
||||
type EditCategoryProductsFormProps = {
|
||||
categoryId: string
|
||||
products?: HttpTypes.AdminProduct[]
|
||||
products?: Pick<HttpTypes.AdminProduct, "id">[]
|
||||
}
|
||||
|
||||
const EditCategoryProductsSchema = z.object({
|
||||
@@ -83,7 +83,6 @@ export const EditCategoryProductsForm = ({
|
||||
error,
|
||||
} = useProducts({
|
||||
...searchParams,
|
||||
category_id: [categoryId],
|
||||
})
|
||||
|
||||
const columns = useColumns()
|
||||
@@ -117,8 +116,8 @@ export const EditCategoryProductsForm = ({
|
||||
{
|
||||
onSuccess: () => {
|
||||
toast.success(
|
||||
t("categories.products.add.disabledTooltip", {
|
||||
count: data.product_ids.length,
|
||||
t("categories.products.add.successToast", {
|
||||
count: data.product_ids.length - products.length,
|
||||
})
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user