fast navigate + cache
Build and Deploy Docker Images / build_and_deploy (push) Has been cancelled

This commit is contained in:
hamid zarghami
2026-06-03 15:08:09 +03:30
parent b9608cd486
commit 194533ec5f
27 changed files with 218 additions and 194 deletions
+4 -7
View File
@@ -1,20 +1,17 @@
import { cache } from "react";
import { API_BASE_URL } from "@/config/const";
import { AboutResponse, Restaurant } from "../(Main)/about/types/Types";
import axios from "axios";
export async function getRestaurant(slug: string): Promise<Restaurant> {
async function fetchRestaurant(slug: string): Promise<Restaurant> {
try {
const response = await axios(`${API_BASE_URL}/public/restaurants/${slug}`, {
// cache: "no-store",
headers: {
"Content-Type": "application/json",
"X-SLUG": slug,
},
});
console.log("response", response);
if (!response.data) {
if (response.status === 404) {
throw new Error("RESTAURANT_NOT_FOUND");
@@ -30,11 +27,11 @@ export async function getRestaurant(slug: string): Promise<Restaurant> {
return data.data;
} catch (error) {
console.log("error", error);
if (error instanceof Error && error.message === "RESTAURANT_NOT_FOUND") {
throw error;
}
throw new Error(`Failed to fetch restaurant data: ${error}`);
}
}
export const getRestaurant = cache(fetchRestaurant);