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
@@ -75,7 +75,7 @@ const CatalogueItem: FC<Props> = ({ item, refetch }) => {
<Eye size={18} color="#0047FF" />
</div>
</Link>
<Link to={Paths.editor + `/${item.slug}`}>
<Link to={Paths.editor + `/${item.id}`}>
<div className="size-6 bg-[#EAECF4] rounded-md flex justify-center items-center">
<Edit size={18} color="#0047FF" />
</div>
+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;
};
+2 -2
View File
@@ -1,6 +1,6 @@
import { usePageTitle } from "@/hooks/usePageTitle";
import type { DocumentSettings } from "@/pages/editor/store/editorStore";
import { useGetCatalogById } from "@/pages/home/hooks/useHomeData";
import { useGetCatalogBySlug } from "@/pages/home/hooks/useHomeData";
import { type FC, useEffect, useState } from "react";
import { useParams } from "react-router-dom";
import BookViewer from "./components/BookViewer";
@@ -12,7 +12,7 @@ import { transformViewerDataToPages } from "./utils/dataTransformer";
const Viewer: FC = () => {
const { id } = useParams<{ id: string }>();
const { data, isLoading, error: queryError } = useGetCatalogById(id ?? "");
const { data, isLoading, error: queryError } = useGetCatalogBySlug(id ?? "");
usePageTitle(`کاتالوگ ${data?.data?.name}`);
const [pages, setPages] = useState<PageData[]>([]);
const [documentSettings, setDocumentSettings] = useState<