new web sayt

This commit is contained in:
nabijonovdavronbek619@gmail.com
2025-11-25 21:06:55 +05:00
parent bef940d9d8
commit f9d27ec11d
29 changed files with 3978 additions and 55 deletions

30
lib/api.ts Normal file
View File

@@ -0,0 +1,30 @@
import axios from "axios";
export const apiClient = axios.create({
baseURL: process.env.NEXT_PUBLIC_SITE_URL || "http://localhost:3000",
timeout: 10000,
headers: {
"Content-Type": "application/json",
},
});
export async function sendContactMessage(payload: {
name: string;
phone: string;
message?: string;
productSlug?: string;
lang?: "uz" | "ru";
}) {
try {
const response = await apiClient.post("/api/contact", payload);
return { success: true, data: response.data };
} catch (error) {
if (axios.isAxiosError(error)) {
return {
success: false,
error: error.response?.data?.error || "Failed to send message",
};
}
return { success: false, error: "Network error" };
}
}