diff --git a/src/actions/wholesale.ts b/src/actions/wholesale.ts index f8d8beb..d2996f5 100644 --- a/src/actions/wholesale.ts +++ b/src/actions/wholesale.ts @@ -528,6 +528,18 @@ export async function getWholesaleSettings(brandId?: string): Promise { + try { + const { rows } = await pool.query<{ invoice_business_address: string | null }>( + "SELECT invoice_business_address FROM get_wholesale_settings($1)", + [brandId] + ); + return rows[0] ?? null; + } catch { + return null; + } +} + export async function saveWholesaleSettings(params: { brandId: string; requireApproval?: boolean; diff --git a/src/app/tuxedo/about/AboutClient.tsx b/src/app/tuxedo/about/AboutClient.tsx new file mode 100644 index 0000000..10af5e7 --- /dev/null +++ b/src/app/tuxedo/about/AboutClient.tsx @@ -0,0 +1,164 @@ +"use client"; + +import { Suspense, lazy, useState } from "react"; +import { motion } from "framer-motion"; +import StorefrontHeader from "@/components/storefront/StorefrontHeader"; +import StorefrontFooter from "@/components/storefront/StorefrontFooter"; + +const MissionSection = lazy(() => import("@/components/about/MissionSection")); +const FamilyTimelineSection = lazy(() => import("@/components/about/FamilyTimelineSection")); +const ContactSection = lazy(() => import("@/components/about/ContactSection")); +const CTASection = lazy(() => import("@/components/about/CTASection")); + +interface AboutClientProps { + logoUrl: string | null; + logoUrlDark: string | null; + olatheSweetLogoUrlDark: string | null; + aboutHeadline: string | null; + aboutSubheadline: string | null; + showWholesaleLink: boolean; + customFooterText: string | null; + contactEmail: string | null; + contactPhone: string | null; + address: string; + isAdmin: boolean; +} + +export default function AboutClient({ + logoUrl, + logoUrlDark, + olatheSweetLogoUrlDark, + aboutHeadline, + aboutSubheadline, + showWholesaleLink, + customFooterText, + contactEmail, + contactPhone, + address, + isAdmin, +}: AboutClientProps) { + return ( +
+ + +
+ {/* Hero Section */} +
+ {/* Decorative elements */} +
+
+
+
+ + {/* Pattern overlay */} +
+ +
+
+ {/* Text content */} +
+ + Our Heritage + + + + {aboutHeadline ?? "Three Generations of Sweet Corn Excellence"} + + + + {aboutSubheadline ?? "Over 40 years of growing and shipping Olathe Sweet Sweet Corn from our family to yours."} + + + +
+ + {/* Logo */} + +
+
+ Olathe Sweet +
+ +
+
+ + {/* Bottom transition */} +
+
+ + {/* Mission Section */} + }> + + + + {/* Family Timeline */} + }> + + + + {/* Contact Section */} + }> + + + + {/* CTA Section */} + }> + + +
+ + +
+ ); +} + +function LoadingFallback({ bg }: { bg: string }) { + return
; +} diff --git a/src/app/tuxedo/about/page.tsx b/src/app/tuxedo/about/page.tsx index 82ccc7b..0ce7e48 100644 --- a/src/app/tuxedo/about/page.tsx +++ b/src/app/tuxedo/about/page.tsx @@ -1,186 +1,32 @@ -"use client"; - -import { useEffect, useState, Suspense, lazy } from "react"; -import { motion } from "framer-motion"; -import StorefrontHeader from "@/components/storefront/StorefrontHeader"; -import StorefrontFooter from "@/components/storefront/StorefrontFooter"; import { getBrandSettingsPublic } from "@/actions/brand-settings"; +import { getWholesaleSettingsPublic } from "@/actions/wholesale"; +import AboutClient from "./AboutClient"; -// Lazy load heavy sections -const MissionSection = lazy(() => import("@/components/about/MissionSection")); -const FamilyTimelineSection = lazy(() => import("@/components/about/FamilyTimelineSection")); -const ContactSection = lazy(() => import("@/components/about/ContactSection")); -const CTASection = lazy(() => import("@/components/about/CTASection")); +export default async function TuxedoAboutPage() { + const settingsResult = await getBrandSettingsPublic("tuxedo"); + const settings = settingsResult.success ? settingsResult.settings : null; -export default function TuxedoAboutPage() { - const [logoUrl, setLogoUrl] = useState(null); - const [logoUrlDark, setLogoUrlDark] = useState(null); - const [olatheSweetLogoUrlDark, setOlatheSweetLogoUrlDark] = useState(null); - const [aboutHeadline, setAboutHeadline] = useState(null); - const [aboutSubheadline, setAboutSubheadline] = useState(null); - const [showWholesaleLink, setShowWholesaleLink] = useState(true); - const [isAdmin, setIsAdmin] = useState(false); - const [customFooterText, setCustomFooterText] = useState(null); - const [contactEmail, setContactEmail] = useState(null); - const [contactPhone, setContactPhone] = useState(null); - const [address, setAddress] = useState("59751 David Road, Olathe, CO 81425"); - - useEffect(() => { - async function load() { - const settingsResult = await getBrandSettingsPublic("tuxedo"); - if (settingsResult.success && settingsResult.settings) { - const s = settingsResult.settings; - setLogoUrl(s.logo_url ?? null); - setLogoUrlDark(s.logo_url_dark ?? null); - setOlatheSweetLogoUrlDark(s.olathe_sweet_logo_url_dark ?? null); - setAboutHeadline(s.about_headline ?? null); - setAboutSubheadline(s.about_subheadline ?? null); - setCustomFooterText(s.custom_footer_text ?? null); - setContactEmail(s.email ?? null); - setContactPhone(s.phone ?? null); - setShowWholesaleLink(s.show_wholesale_link ?? true); - if (s.brand_id) { - try { - const { pool } = await import("@/lib/db"); - const { rows } = await pool.query<{ invoice_business_address: string }>( - "SELECT invoice_business_address FROM wholesale_settings WHERE brand_id = $1", - [s.brand_id] - ); - if (rows[0]?.invoice_business_address) setAddress(rows[0].invoice_business_address); - } catch { /* ignore */ } - } - } - try { - const { getCurrentAdminUser } = await import("@/actions/admin-user"); - setIsAdmin(!!await getCurrentAdminUser()); - } catch { /* not logged in */ } + let address = "59751 David Road, Olathe, CO 81425"; + if (settings?.brand_id) { + const wholesale = await getWholesaleSettingsPublic(settings.brand_id); + if (wholesale?.invoice_business_address) { + address = wholesale.invoice_business_address; } - load(); - }, []); + } return ( -
- - -
- {/* Hero Section */} -
- {/* Decorative elements */} -
-
-
-
- - {/* Pattern overlay */} -
- -
-
- {/* Text content */} -
- - Our Heritage - - - - {aboutHeadline ?? "Three Generations of Sweet Corn Excellence"} - - - - {aboutSubheadline ?? "Over 40 years of growing and shipping Olathe Sweet Sweet Corn from our family to yours."} - - - -
- - {/* Logo */} - -
-
- Olathe Sweet -
- -
-
- - {/* Bottom transition */} -
-
- - {/* Mission Section */} - }> - - - - {/* Family Timeline */} - }> - - - - {/* Contact Section */} - }> - - - - {/* CTA Section */} - }> - - -
- - -
+ ); } - -// Simple loading fallback - no more skeleton spinners -function LoadingFallback({ bg }: { bg: string }) { - return
; -} \ No newline at end of file