background image
This commit is contained in:
@@ -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 = () => {
|
||||
|
||||
@@ -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),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user