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:
1 parent
cab629556f
commit
7a08224b0c
3 files changed
+9
-12
No files matched your search
@@ -134,7 +134,7 @@ export const useUpdateProductCategoryProducts = (
|
|||||||
onSuccess: (data, variables, context) => {
|
onSuccess: (data, variables, context) => {
|
||||||
queryClient.invalidateQueries({ queryKey: categoriesQueryKeys.lists() })
|
queryClient.invalidateQueries({ queryKey: categoriesQueryKeys.lists() })
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: categoriesQueryKeys.detail(id),
|
queryKey: categoriesQueryKeys.details(),
|
||||||
})
|
})
|
||||||
/**
|
/**
|
||||||
* Invalidate products list query to ensure that the products collections are updated.
|
* 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 = () => {
|
export const CategoryProducts = () => {
|
||||||
const { id } = useParams()
|
const { id } = useParams()
|
||||||
|
|
||||||
const { product_category, isPending, isError, error } = useProductCategory(
|
const { product_category, isPending, isFetching, isError, error } =
|
||||||
id!,
|
useProductCategory(id!, {
|
||||||
{
|
fields: "products.id",
|
||||||
fields: "*products",
|
})
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const ready = !isPending && !!product_category
|
const ready = !isPending && !isFetching && !!product_category
|
||||||
|
|
||||||
if (isError) {
|
if (isError) {
|
||||||
throw error
|
throw error
|
||||||
|
|||||||
+3
-4
@@ -25,7 +25,7 @@ import { useDataTable } from "../../../../../hooks/use-data-table"
|
|||||||
|
|
||||||
type EditCategoryProductsFormProps = {
|
type EditCategoryProductsFormProps = {
|
||||||
categoryId: string
|
categoryId: string
|
||||||
products?: HttpTypes.AdminProduct[]
|
products?: Pick<HttpTypes.AdminProduct, "id">[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const EditCategoryProductsSchema = z.object({
|
const EditCategoryProductsSchema = z.object({
|
||||||
@@ -83,7 +83,6 @@ export const EditCategoryProductsForm = ({
|
|||||||
error,
|
error,
|
||||||
} = useProducts({
|
} = useProducts({
|
||||||
...searchParams,
|
...searchParams,
|
||||||
category_id: [categoryId],
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const columns = useColumns()
|
const columns = useColumns()
|
||||||
@@ -117,8 +116,8 @@ export const EditCategoryProductsForm = ({
|
|||||||
{
|
{
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
toast.success(
|
toast.success(
|
||||||
t("categories.products.add.disabledTooltip", {
|
t("categories.products.add.successToast", {
|
||||||
count: data.product_ids.length,
|
count: data.product_ids.length - products.length,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user