background image

This commit is contained in:
hamid zarghami
2026-06-22 09:20:08 +03:30
parent 3bb6ffac4e
commit e8a950b0b6
10 changed files with 286 additions and 61 deletions
@@ -1,11 +1,15 @@
import { useQuery } from "@tanstack/react-query";
import { useParams } from "next/navigation";
import { useEffect } from "react";
import * as api from "../service/AboutService";
import { setPersistedAboutData } from "@/lib/helpers/themeCache";
import {
getPersistedAboutData,
setPersistedAboutData,
} from "@/lib/helpers/themeCache";
export const useGetAbout = () => {
const { name } = useParams<{ name: string }>();
return useQuery({
const query = useQuery({
queryKey: ["about", name],
queryFn: async () => {
const data = await api.getAbout(name);
@@ -16,9 +20,18 @@ export const useGetAbout = () => {
retry: false,
staleTime: 60 * 60_000,
gcTime: 24 * 60 * 60_000,
refetchOnMount: false,
refetchOnMount: "always",
refetchOnWindowFocus: false,
placeholderData: () => (name ? getPersistedAboutData(name) : undefined),
});
useEffect(() => {
if (name && query.data) {
setPersistedAboutData(name, query.data);
}
}, [name, query.data]);
return query;
};
export const useGetReviews = () => {
+2 -2
View File
@@ -23,7 +23,7 @@ export const useGetFoods = () => {
},
enabled: !!name,
staleTime: 5 * 60_000,
refetchOnMount: false,
refetchOnMount: "always",
placeholderData: () => (name ? getPersistedMenuData(name) : undefined),
});
@@ -47,7 +47,7 @@ export const useGetCategories = () => {
},
enabled: !!name,
staleTime: 5 * 60_000,
refetchOnMount: false,
refetchOnMount: "always",
placeholderData: () => (name ? getPersistedCategoriesData(name) : undefined),
});