ifixkart-storefront/app/about/page.tsx

156 lines
6.5 KiB
TypeScript

'use client';
import React, { useEffect, useState } from 'react';
import Link from 'next/link';
import { Mail, MapPin, Phone, Smartphone, Wrench } from 'lucide-react';
import { AnnouncementBar } from '@/layout/AnnouncementBar';
import { Header } from '@/layout/Header';
import { Navbar } from '@/layout/Navbar';
import { Footer } from '@/layout/Footer';
import { StickyHeaderSpacer } from '@/components/StickyHeaderSpacer';
import { FloatingButtons } from '@/components/FloatingButtons';
import {
storefrontService,
type FooterInfo,
type StorefrontSettings,
MOCK_FOOTER_INFO,
} from '@/services/api/storefrontService';
export default function AboutPage() {
const [footer, setFooter] = useState<FooterInfo>(MOCK_FOOTER_INFO);
const [settings, setSettings] = useState<StorefrontSettings>({ store_name: 'iFixKart' });
const [layoutSections, setLayoutSections] = useState<any[]>([]);
useEffect(() => {
let cancelled = false;
Promise.all([
storefrontService.getFooterInfo(),
storefrontService.getSettings(),
storefrontService.getPageLayout('about'),
]).then(([info, store, layout]) => {
if (cancelled) return;
if (info) setFooter(info);
if (store) setSettings(store);
if (layout && layout.length > 0) setLayoutSections(layout);
});
return () => {
cancelled = true;
};
}, []);
const storeName = settings.store_name || 'iFixKart';
const heroSec = layoutSections.find((s) => s.region === 'about_hero' || s.type === 'about_hero');
const featuresSec = layoutSections.find((s) => s.region === 'about_features' || s.type === 'about_features');
const contactSec = layoutSections.find((s) => s.region === 'about_contact' || s.type === 'about_contact');
const pageTitle = heroSec?.title || 'About Us';
const pageSubtitle = heroSec?.subtitle || '';
const heroMeta = heroSec?.metadata || heroSec?.metadata_json || {};
const storyParagraphs: string[] = Array.isArray(heroMeta.story_paragraphs) && heroMeta.story_paragraphs.length > 0
? heroMeta.story_paragraphs
: [
`${storeName} sells tested refurbished phones and accessories, and books device repairs. You can shop online, get a screen or battery replaced, or exchange the phone you already have.`,
`Repairs are done at our Bengaluru service center or at your doorstep. Refurbished phones are checked before listing and sold with a limited warranty.`,
];
const featureCards: any[] = Array.isArray(featuresSec?.metadata?.cards || featuresSec?.metadata_json?.cards) && (featuresSec?.metadata?.cards || featuresSec?.metadata_json?.cards).length > 0
? (featuresSec?.metadata?.cards || featuresSec?.metadata_json?.cards)
: [
{ id: '1', title: 'Shop', desc: 'Refurbished phones, spare parts, and accessories.', link: '/shop', icon: 'smartphone' },
{ id: '2', title: 'Repair', desc: 'Screens, batteries, charging ports, and other common jobs.', link: '/repair-services', icon: 'wrench' },
];
const contactMeta = contactSec?.metadata || contactSec?.metadata_json || {};
const phone = contactMeta.phone || footer.phone || settings.support_phone || '';
const email = contactMeta.email || footer.email || '';
const address = contactMeta.address || footer.address || '';
const hours = contactMeta.hours || '';
return (
<div className="min-h-screen bg-[#F8F9FB] text-[#1E293B] flex flex-col font-sans">
<AnnouncementBar />
<Header />
<StickyHeaderSpacer />
<Navbar />
<main className="flex-grow py-10 pb-20">
<div className="container mx-auto px-4 sm:px-6 lg:px-8 max-w-[860px]">
<h1 className="text-[28px] md:text-[32px] font-bold text-[#1E293B]">
{pageTitle}
</h1>
{pageSubtitle ? (
<p className="text-[16px] text-primary font-medium mt-1">
{pageSubtitle}
</p>
) : null}
{storyParagraphs.map((para, i) => (
<p key={i} className="text-[15px] text-gray-600 leading-relaxed mt-3">
{para}
</p>
))}
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4 mt-8">
{featureCards.map((card, i) => {
const isRepair = (card.icon || '').toLowerCase().includes('wrench') || (card.title || '').toLowerCase().includes('repair');
const to = card.link || (isRepair ? '/repair-services' : '/shop');
return (
<Link
key={card.id || i}
href={to}
className="bg-white border border-gray-200 rounded-xl p-5 hover:border-primary/40 hover:shadow-sm transition-all"
>
{isRepair ? (
<Wrench className="w-5 h-5 text-primary mb-3" />
) : (
<Smartphone className="w-5 h-5 text-primary mb-3" />
)}
<h2 className="text-[16px] font-bold text-[#1E293B]">{card.title}</h2>
<p className="text-[13px] text-gray-500 mt-1 leading-relaxed">
{card.desc}
</p>
</Link>
);
})}
</div>
<div className="mt-8 bg-white border border-gray-200 rounded-xl p-5 md:p-6 space-y-4">
{address ? (
<div className="flex gap-3">
<MapPin className="w-4 h-4 text-gray-400 mt-0.5 shrink-0" />
<p className="text-[14px] text-gray-600 leading-relaxed">{address}</p>
</div>
) : null}
{hours ? (
<div className="flex gap-3 text-[14px] text-gray-600">
<span className="w-4 h-4 text-gray-400 mt-0.5 shrink-0 font-bold text-center">⏱</span>
<p className="text-[14px] text-gray-600 leading-relaxed">{hours}</p>
</div>
) : null}
{phone ? (
<a
href={`tel:${phone.replace(/[^\d+]/g, '')}`}
className="flex gap-3 text-[14px] text-gray-600 hover:text-primary"
>
<Phone className="w-4 h-4 text-gray-400 mt-0.5 shrink-0" />
{phone}
</a>
) : null}
{email ? (
<a
href={`mailto:${email}`}
className="flex gap-3 text-[14px] text-gray-600 hover:text-primary"
>
<Mail className="w-4 h-4 text-gray-400 mt-0.5 shrink-0" />
{email}
</a>
) : null}
</div>
</div>
</main>
<Footer />
<FloatingButtons />
</div>
);
}