"use client"; import Image from "next/image"; import { motion } from "framer-motion"; import { useEffect, useState } from "react"; import { useTranslations } from "next-intl"; import { getOperationalSystems, SystemFeature, } from "@/lib/api/demoapi/operationalSystems"; import { Breadcrumb } from "@/components/breadCrumb"; export default function OperationalSystemsPage() { const t = useTranslations("operationalSystems"); const [data, setData] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(false); // Demo data - fallback ma'lumotlar const demoData: SystemFeature[] = [ { id: "1", title: t("systems.sprinkler.title"), shortDesc:t("systems.sprinkler.short-desc"), description: t("systems.sprinkler.description"), features: [ t("systems.sprinkler.features.0"), t("systems.sprinkler.features.1"), t("systems.sprinkler.features.2"), t("systems.sprinkler.features.3"), ], image: "/images/services/sprinkler.jpg", }, ]; const fetchData = async () => { try { setLoading(true); setError(false); const result = await getOperationalSystems(); // Agar backend ma'lumot qaytarsa if (result && result.length > 0) { setData(result); } else { // Backend bo'sh ma'lumot qaytarsa, demo ma'lumotlarni ishlatamiz setData(demoData); } } catch (err) { setError(true); // Xatolik bo'lsa, demo ma'lumotlarni ishlatamiz setData(demoData); } finally { setLoading(false); } }; useEffect(() => { fetchData(); }, []); // Animation variants const containerVariants = { hidden: { opacity: 0 }, visible: { opacity: 1, transition: { staggerChildren: 0.15, }, }, }; const itemVariants = { hidden: { opacity: 0, y: 30 }, visible: { opacity: 1, y: 0, transition: { duration: 0.6, ease: [0.22, 1, 0.36, 1] as const, }, }, }; const cardVariants = { hidden: { opacity: 0, scale: 0.95 }, visible: { opacity: 1, scale: 1, transition: { duration: 0.5, ease: [0.22, 1, 0.36, 1] as const, }, }, }; // Loading state if (loading) { return (

{t("loading")}

); } // Error state with retry if (error && !data) { return (
⚠️

{t("error")}

{t("retry")}
); } return (
{/* Header */} {/*

{t('title')}

{t('subtitle')}

Fire hose
*/}
{/* Main Content */} {!data || data.length === 0 ? (

{t("noData")}

) : ( {data.map((system, index) => ( {/* Image Section */} {system.title}
{/* Content Section */}
{system.title} {system.shortDesc} {system.description}
    {system.features.map((feature, featureIndex) => ( {feature} ))}
))} )}
); }