diff --git a/app/about/page.tsx b/app/about/page.tsx index bd23756..356bf33 100644 --- a/app/about/page.tsx +++ b/app/about/page.tsx @@ -19,16 +19,19 @@ import { export default function AboutPage() { const [footer, setFooter] = useState(MOCK_FOOTER_INFO); const [settings, setSettings] = useState({ store_name: 'iFixKart' }); + const [layoutSections, setLayoutSections] = useState([]); useEffect(() => { let cancelled = false; Promise.all([ storefrontService.getFooterInfo(), storefrontService.getSettings(), - ]).then(([info, store]) => { + 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; @@ -36,9 +39,32 @@ export default function AboutPage() { }, []); const storeName = settings.store_name || 'iFixKart'; - const phone = footer.phone || settings.support_phone || ''; - const email = footer.email || ''; - const address = footer.address || ''; + 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 (
@@ -50,39 +76,42 @@ export default function AboutPage() {

- About Us + {pageTitle}

-

- {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. -

+ {pageSubtitle ? ( +

+ {pageSubtitle} +

+ ) : null} -
- - -

Shop

-

- Refurbished phones, spare parts, and accessories. -

- - - -

Repair

-

- Screens, batteries, charging ports, and other common jobs. -

- + {storyParagraphs.map((para, i) => ( +

+ {para} +

+ ))} + +
+ {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 ( + + {isRepair ? ( + + ) : ( + + )} +

{card.title}

+

+ {card.desc} +

+ + ); + })}
@@ -92,6 +121,12 @@ export default function AboutPage() {

{address}

) : null} + {hours ? ( +
+ ⏱ +

{hours}

+
+ ) : null} {phone ? ( { let cancelled = false; - storefrontService.getFaqLayout().then((raw) => { - if (!cancelled) setData(parseFaqPageData(raw)); + Promise.all([ + storefrontService.getPageLayout('faqs'), + storefrontService.getFaqLayout(), + ]).then(([faqsData, legacyData]) => { + if (cancelled) return; + const raw = Array.isArray(faqsData) && faqsData.length > 0 ? faqsData : legacyData; + setData(parseFaqPageData(raw)); }); return () => { cancelled = true; diff --git a/app/feedback/page.tsx b/app/feedback/page.tsx index 54c2c46..59f8239 100644 --- a/app/feedback/page.tsx +++ b/app/feedback/page.tsx @@ -31,6 +31,7 @@ const labelClass = 'block text-[12px] font-bold text-[#1E293B] mb-1.5'; export default function FeedbackPage() { const [footer, setFooter] = useState(MOCK_FOOTER_INFO); const [settings, setSettings] = useState({ store_name: 'iFixKart' }); + const [layoutSections, setLayoutSections] = useState([]); const [name, setName] = useState(''); const [email, setEmail] = useState(''); const [topic, setTopic] = useState('suggestion'); @@ -38,16 +39,19 @@ export default function FeedbackPage() { const [rating, setRating] = useState(0); const [message, setMessage] = useState(''); const [submitted, setSubmitted] = useState(false); + const [submitting, setSubmitting] = useState(false); useEffect(() => { let cancelled = false; Promise.all([ storefrontService.getFooterInfo(), storefrontService.getSettings(), - ]).then(([info, store]) => { + storefrontService.getPageLayout('feedback'), + ]).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; @@ -58,26 +62,34 @@ export default function FeedbackPage() { const supportEmail = footer.email || 'support@ifixkart.com'; const doc = useMemo(() => buildFeedbackPage(storeName), [storeName]); - const handleSubmit = (e: FormEvent) => { - e.preventDefault(); - const topicLabel = doc.topics.find((t) => t.id === topic)?.label || topic; - const body = [ - `Name: ${name}`, - `Email: ${email}`, - `Topic: ${topicLabel}`, - orderNo ? `Order / job: ${orderNo}` : '', - rating ? `Rating: ${rating} / 5` : '', - '', - message, - ] - .filter((line) => line !== '') - .join('\n'); + const heroSec = layoutSections.find((s) => s.region === 'feedback_hero' || s.type === 'feedback_hero'); + const heading = heroSec?.title || doc.heading; + const intro = heroSec?.subtitle || doc.intro; - const href = `mailto:${supportEmail}?subject=${encodeURIComponent( - `${storeName} feedback — ${topicLabel}` - )}&body=${encodeURIComponent(body)}`; - window.location.href = href; - setSubmitted(true); + const handleSubmit = async (e: FormEvent) => { + e.preventDefault(); + if (!message.trim() || !email.trim()) return; + setSubmitting(true); + try { + await storefrontService.submitFeedback({ + name: name.trim() || 'Valued Customer', + email: email.trim(), + topic, + order_no: orderNo.trim() || undefined, + rating: rating || 5, + message: message.trim(), + }); + setSubmitted(true); + } catch { + const topicLabel = doc.topics.find((t) => t.id === topic)?.label || topic; + const body = `Name: ${name}\nEmail: ${email}\nTopic: ${topicLabel}\nRating: ${rating}\n\n${message}`; + window.location.href = `mailto:${supportEmail}?subject=${encodeURIComponent( + `${storeName} feedback — ${topicLabel}` + )}&body=${encodeURIComponent(body)}`; + setSubmitted(true); + } finally { + setSubmitting(false); + } }; return ( @@ -90,9 +102,9 @@ export default function FeedbackPage() {

- {doc.heading} + {heading}

-

{doc.intro}

+

{intro}

{doc.highlights.map((item) => { @@ -247,9 +259,10 @@ export default function FeedbackPage() { )} diff --git a/app/help/page.tsx b/app/help/page.tsx index b351b88..46e67cc 100644 --- a/app/help/page.tsx +++ b/app/help/page.tsx @@ -43,16 +43,19 @@ function telHref(phone: string): string { export default function HelpCenterPage() { const [footer, setFooter] = useState(MOCK_FOOTER_INFO); const [settings, setSettings] = useState({ store_name: 'iFixKart' }); + const [layoutSections, setLayoutSections] = useState([]); useEffect(() => { let cancelled = false; Promise.all([ storefrontService.getFooterInfo(), storefrontService.getSettings(), - ]).then(([info, store]) => { + storefrontService.getPageLayout('help'), + ]).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; @@ -64,6 +67,21 @@ export default function HelpCenterPage() { const email = footer.email || ''; const doc = useMemo(() => buildHelpDoc(storeName), [storeName]); + const heroSec = layoutSections.find((s) => s.region === 'help_hero' || s.type === 'help_hero'); + const topicsSec = layoutSections.find((s) => s.region === 'help_topics' || s.type === 'help_topics'); + + const heading = heroSec?.title || doc.heading; + const intro = heroSec?.subtitle || doc.intro; + const topicsMeta = topicsSec?.metadata || topicsSec?.metadata_json || {}; + const topics = Array.isArray(topicsMeta.topics) && topicsMeta.topics.length > 0 + ? topicsMeta.topics.map((t: any) => ({ + id: t.id || 'general', + title: t.title || t.name, + desc: t.desc || t.description, + href: t.href || t.link || '/help', + })) + : doc.topics; + return (
@@ -74,12 +92,12 @@ export default function HelpCenterPage() {

- {doc.heading} + {heading}

-

{doc.intro}

+

{intro}

- {doc.topics.map((item) => { + {topics.map((item: any) => { const Icon = TOPIC_ICONS[item.id as keyof typeof TOPIC_ICONS] || CircleHelp; return ( + + + diff --git a/app/payments/page.tsx b/app/payments/page.tsx index 18d5b4f..47a4bc1 100644 --- a/app/payments/page.tsx +++ b/app/payments/page.tsx @@ -32,16 +32,19 @@ function telHref(phone: string): string { export default function PaymentsPage() { const [footer, setFooter] = useState(MOCK_FOOTER_INFO); const [settings, setSettings] = useState({ store_name: 'iFixKart' }); + const [layoutSections, setLayoutSections] = useState([]); useEffect(() => { let cancelled = false; Promise.all([ storefrontService.getFooterInfo(), storefrontService.getSettings(), - ]).then(([info, store]) => { + storefrontService.getPageLayout('payments'), + ]).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; @@ -54,6 +57,10 @@ export default function PaymentsPage() { const doc = useMemo(() => buildPaymentsDoc(storeName), [storeName]); const methods = (footer.payment_methods || []).filter((p) => p?.name || p?.icon_url); + const heroSec = layoutSections.find((s) => s.region === 'payments_hero' || s.type === 'payments_hero'); + const heading = heroSec?.title || doc.heading; + const intro = heroSec?.subtitle || doc.intro; + return (
@@ -64,9 +71,9 @@ export default function PaymentsPage() {

- {doc.heading} + {heading}

-

{doc.intro}

+

{intro}

{doc.highlights.map((item) => { diff --git a/app/products/[slug]/page.tsx b/app/products/[slug]/page.tsx index c3471e9..56cbea9 100644 --- a/app/products/[slug]/page.tsx +++ b/app/products/[slug]/page.tsx @@ -30,6 +30,8 @@ const HIDDEN_SPEC_KEYS = [ 'sku', 'barcode', 'compare_price', + 'is_active', + 'is_parent_feature', ]; function normalizeSpecKey(code: string): string { @@ -388,8 +390,52 @@ export default async function ProductDetailPage({ params }: ProductDetailPagePro ); + const primaryVariant = product.variants?.[0]; + const primaryImage = product.images?.[0]?.image_url || '/images/placeholder-product.webp'; + const resolvedImageUrl = primaryImage.startsWith('http') + ? primaryImage + : `https://ifixkartbe.trionixsolution.com/uploads/${primaryImage.replace(/^\//, '')}`; + + const jsonLd = { + '@context': 'https://schema.org/', + '@type': 'Product', + name: product.name, + image: [resolvedImageUrl], + description: product.seo_description || product.description || `${product.name} with certified warranty at iFixKart.`, + sku: primaryVariant?.sku || String(product.product_id), + mpn: primaryVariant?.barcode || primaryVariant?.sku || String(product.product_id), + brand: { + '@type': 'Brand', + name: product.brand?.name || 'iFixKart', + }, + offers: { + '@type': 'Offer', + url: `https://ifixkart.trionixsolution.com/products/${product.slug}`, + priceCurrency: 'INR', + price: primaryVariant?.price || 0, + priceValidUntil: '2027-12-31', + itemCondition: 'https://schema.org/NewCondition', + availability: (primaryVariant?.price && Number(primaryVariant?.price) > 0) + ? 'https://schema.org/InStock' + : 'https://schema.org/OutOfStock', + seller: { + '@type': 'Organization', + name: 'iFixKart TechShop', + }, + }, + aggregateRating: reviews.length > 0 ? { + '@type': 'AggregateRating', + ratingValue: '4.8', + reviewCount: String(reviews.length), + } : undefined, + }; + return (
+