new web sayt
This commit is contained in:
30
lib/api.ts
Normal file
30
lib/api.ts
Normal 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" };
|
||||
}
|
||||
}
|
||||
64
lib/products.ts
Normal file
64
lib/products.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
export interface Product {
|
||||
id: string;
|
||||
nameKey: string;
|
||||
slug: string;
|
||||
shortDescriptionKey: string;
|
||||
longDescriptionKey?: string;
|
||||
images: string[];
|
||||
model3D?: string;
|
||||
specs: { key: string; value: string }[];
|
||||
}
|
||||
|
||||
// Sample products data
|
||||
export const products: Product[] = [
|
||||
{
|
||||
id: "1",
|
||||
nameKey: "products_list.pump_1.name",
|
||||
slug: "schotchik-pump",
|
||||
shortDescriptionKey: "products_list.pump_1.shortDescription",
|
||||
longDescriptionKey: "products_list.pump_1.description",
|
||||
images: ["/images/pump-1.jpg", "/images/pump-1-alt.jpg"],
|
||||
specs: [
|
||||
{ key: "Flow Rate", value: "100 L/min" },
|
||||
{ key: "Pressure", value: "10 bar" },
|
||||
{ key: "Power", value: "5.5 kW" },
|
||||
{ key: "Temperature Range", value: "-10°C to 60°C" },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "2",
|
||||
nameKey: "products_list.pump_2.name",
|
||||
slug: "agregat-pump",
|
||||
shortDescriptionKey: "products_list.pump_2.shortDescription",
|
||||
longDescriptionKey: "products_list.pump_2.description",
|
||||
images: ["/images/pump-2.jpg", "/images/pump-2-alt.jpg"],
|
||||
specs: [
|
||||
{ key: "Flow Rate", value: "250 L/min" },
|
||||
{ key: "Pressure", value: "15 bar" },
|
||||
{ key: "Power", value: "11 kW" },
|
||||
{ key: "Temperature Range", value: "-10°C to 70°C" },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "3",
|
||||
nameKey: "products_list.pump_3.name",
|
||||
slug: "ccl-20-24-pump",
|
||||
shortDescriptionKey: "products_list.pump_3.shortDescription",
|
||||
longDescriptionKey: "products_list.pump_3.description",
|
||||
images: ["/images/pump-3.jpg", "/images/pump-3-alt.jpg"],
|
||||
specs: [
|
||||
{ key: "Depth Rating", value: "20-24 m" },
|
||||
{ key: "Flow Rate", value: "150 L/min" },
|
||||
{ key: "Suction Lift", value: "7 m" },
|
||||
{ key: "Power", value: "7.5 kW" },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
export function getProductBySlug(slug: string): Product | undefined {
|
||||
return products.find((p) => p.slug === slug);
|
||||
}
|
||||
|
||||
export function getAllProducts(): Product[] {
|
||||
return products;
|
||||
}
|
||||
39
lib/types.ts
Normal file
39
lib/types.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
export interface ContactPayload {
|
||||
name: string;
|
||||
phone: string;
|
||||
message?: string;
|
||||
productSlug?: string;
|
||||
lang?: "uz" | "ru";
|
||||
}
|
||||
|
||||
export interface NavbarProps {
|
||||
logoSrc?: string;
|
||||
links?: { id: string; labelKey: string; href: string }[];
|
||||
}
|
||||
|
||||
export interface ShowCaseProps {
|
||||
titleKey: string;
|
||||
subtitleKey?: string;
|
||||
ctaLabelKey: string;
|
||||
images: string[];
|
||||
}
|
||||
|
||||
export interface ProductCardProps {
|
||||
product: any;
|
||||
onViewDetails: (slug: string) => void;
|
||||
}
|
||||
|
||||
export interface ProductViewerProps {
|
||||
modelUrl?: string;
|
||||
images?: string[];
|
||||
autoRotate?: boolean;
|
||||
}
|
||||
|
||||
export interface FaqItem {
|
||||
questionKey: string;
|
||||
answerKey: string;
|
||||
}
|
||||
|
||||
export interface FaqProps {
|
||||
items: FaqItem[];
|
||||
}
|
||||
6
lib/utils.ts
Normal file
6
lib/utils.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { clsx, type ClassValue } from "clsx";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs));
|
||||
}
|
||||
Reference in New Issue
Block a user