"use client";

import { usePathname, useRouter } from "next/navigation";
import PreFlight, { type DiagnosticBrand } from "@/components/PreFlight";

interface BrandPageWrapperProps {
  mode: "full" | "quick";
  runHref: string;
}

const fullBrand: DiagnosticBrand = {
  brandName: "Protect4Less",
  preflightTitle: "Device Diagnostics",
  preflightCopy:
    "Run the full Protect4Less test flow and produce a certificate at the end.",
  poweredByLabel: "Powered by",
  logoSrc: "/p4l-logo.png",
  logoAlt: "Protect4Less",
};

const etisalatBrand: DiagnosticBrand = {
  brandName: "Etisalat",
  preflightTitle: "Device Diagnostics",
  preflightCopy:
    "Run a few quick checks to see if your device is eligible for the device protection cover.",
  poweredByLabel: "Powered by",
  logoSrc: "/eand-logo-white.svg",
  logoAlt: "Etisalat",
  logoDark: true,
};

export default function BrandPageWrapper({
  mode,
  runHref,
}: BrandPageWrapperProps) {
  const router = useRouter();
  const pathname = usePathname() || "";
  const brand = mode === "full" || !pathname.includes("/etisalat")
    ? fullBrand
    : etisalatBrand;

  return (
    <PreFlight
      mode={mode}
      brand={brand}
      onBackHome={() => router.push("/")}
      onGranted={() => router.push(runHref)}
    />
  );
}
