fix update
deploy to danak / build_and_deploy (push) Has been cancelled

This commit is contained in:
hamid zarghami
2026-06-01 14:09:51 +03:30
parent da0069f2bc
commit 04da87b7d7
4 changed files with 25 additions and 6 deletions
+14 -2
View File
@@ -1,6 +1,6 @@
import * as api from "../service/HomeService";
import { useMutation, useQuery } from "@tanstack/react-query";
import { useCallback, useEffect, useRef, useState } from "react";
import * as api from "../service/HomeService";
export const useCreateCatalog = () => {
return useMutation({
@@ -31,6 +31,16 @@ export const useGetCatalogById = (id: string) => {
staleTime: 5 * 60 * 1000,
});
};
export const useGetCatalogBySlug = (slug: string) => {
return useQuery({
queryKey: ["catalog", slug],
queryFn: () => api.getCatalogBySlug(slug),
enabled: !!slug,
// جلوگیری از بازنویسی state محلی با refetch هنگام فوکوس پنجره (مثلاً دو کاربر همزمان)
refetchOnWindowFocus: false,
staleTime: 5 * 60 * 1000,
});
};
export const useUpdateCatalog = () => {
const mutation = useMutation({
@@ -38,7 +48,9 @@ export const useUpdateCatalog = () => {
});
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const pendingParamsRef = useRef<Parameters<typeof api.updateCatalog>[0] | null>(null);
const pendingParamsRef = useRef<
Parameters<typeof api.updateCatalog>[0] | null
>(null);
const [isScheduledSaving, setIsScheduledSaving] = useState(false);
const cancelPendingUpdate = useCallback(() => {
+8 -1
View File
@@ -20,7 +20,14 @@ export const getCatalogs = async () => {
export const getCatalogById = async (id: string) => {
const { data } = await axios.get<CatalogByIdResponseType>(
`/public/catalogue/slug/${id}`,
`/admin/catalogue/${id}`,
);
return data;
};
export const getCatalogBySlug = async (slug: string) => {
const { data } = await axios.get<CatalogByIdResponseType>(
`/public/catalogue/slug/${slug}`,
);
return data;
};