import React, { useEffect, useState } from "react";
import { Box, Button, Container, Stack, Typography } from "@mui/material";
import { alpha } from "@mui/material/styles";
import { useLocation, useNavigate } from "react-router-dom";
import DashboardIcon from "@mui/icons-material/SpaceDashboardOutlined";
import AlarmIcon from "@mui/icons-material/NotificationsActiveOutlined";
import MatchIcon from "@mui/icons-material/FactCheckOutlined";
import MailIcon from "@mui/icons-material/MarkEmailReadOutlined";
import AttachIcon from "@mui/icons-material/DescriptionOutlined";
import InsightsIcon from "@mui/icons-material/InsightsOutlined";
import { api } from "../api";
import GradientButton from "../components/GradientButton";
import { PUBLIC_PLANS, PublicPlanId } from "../planCatalog";
import { useI18n } from "../i18n/I18nProvider";
import type { TranslationKey } from "../i18n/translations";
import { StackLanguageToggle } from "../layout/AppShell";
const BRAND_DARK = "#0b1020";
const BRAND_PANEL = "#111a33";
const FEATURES: { icon: React.ReactNode; title: TranslationKey; body: TranslationKey }[] = [
{ icon: , title: "landingFeaturePipeline", body: "landingFeaturePipelineBody" },
{ icon: , title: "landingFeatureFollowups", body: "landingFeatureFollowupsBody" },
{ icon: , title: "landingFeatureMatch", body: "landingFeatureMatchBody" },
{ icon: , title: "landingFeatureEmail", body: "landingFeatureEmailBody" },
{ icon: , title: "landingFeatureDocuments", body: "landingFeatureDocumentsBody" },
{ icon: , title: "landingFeatureInsights", body: "landingFeatureInsightsBody" },
];
const STEPS: { n: number; title: TranslationKey; body: TranslationKey }[] = [
{ n: 1, title: "landingStepImport", body: "landingStepImportBody" },
{ n: 2, title: "landingStepMatch", body: "landingStepMatchBody" },
{ n: 3, title: "landingStepTailor", body: "landingStepTailorBody" },
{ n: 4, title: "landingStepTrack", body: "landingStepTrackBody" },
{ n: 5, title: "landingStepFollowUp", body: "landingStepFollowUpBody" },
{ n: 6, title: "landingStepAnalyze", body: "landingStepAnalyzeBody" },
];
export default function LandingPage() {
const navigate = useNavigate();
const { language, setLanguage, t } = useI18n();
const location = useLocation() as { state?: { from?: string } };
const [checking, setChecking] = useState(true);
// If the visitor already has a session, send them straight into the app.
useEffect(() => {
let active = true;
api
.get("/auth/me")
.then(() => { if (active) navigate("/dashboard", { replace: true }); })
.catch(() => { if (active) setChecking(false); });
return () => { active = false; };
}, [navigate]);
// A protected route redirects unauthenticated visitors here with the page they
// wanted in location state; forward it to /login so sign-in returns them there
// instead of dropping them on /jobs.
const goToLogin = () => navigate("/login", { state: location.state });
const goToPlan = (plan: PublicPlanId) => {
if (plan === "free") {
navigate("/register");
return;
}
navigate("/login", { state: { from: "/settings" } });
};
if (checking) {
return (
{t("loading")}
);
}
const gradientText = {
background: "linear-gradient(90deg,#6366f1,#22d3ee)",
WebkitBackgroundClip: "text",
WebkitTextFillColor: "transparent",
} as const;
const plans = PUBLIC_PLANS.map((plan) => ({
...plan,
name: t(plan.id === "free" ? "landingPlanFree" : "landingPlanPro"),
summary: t(plan.id === "free" ? "landingPlanFreeSummary" : "landingPlanProSummary"),
features: plan.features.map((_, index) => t(`landingPlan${plan.id === "free" ? "Free" : "Pro"}Feature${index + 1}` as TranslationKey)),
cta: t(plan.id === "free" ? "landingPlanFreeCta" : "landingPlanProCta"),
}));
return (
{/* Top bar */}
✓
Jobbjakt
{t("landingSignIn")}
{/* Hero */}
{t("landingEyebrow")}
{t("landingHeroBefore")} {t("landingHeroAccent")}.
{t("landingHeroBody")}
{t("landingGetStarted")}
React · TypeScript · ASP.NET Core · EF Core · FastAPI AI · Gmail
{/* Product preview */}
{t("landingPreviewEyebrow")}
{t("landingPreviewTitle")}
{t("landingPreviewCaption")}
{/* Features */}
{t("landingFeaturesEyebrow")}
{t("landingFeaturesTitle")}
{t("landingFeaturesBody")}
{FEATURES.map((f) => (
{f.icon}
{t(f.title)}
{t(f.body)}
))}
{/* How it works */}
{t("landingHowEyebrow")}
{t("landingHowTitle")}
{STEPS.map((s) => (
{s.n}
{t(s.title)}
{t(s.body)}
))}
{/* Plans */}
{t("landingPlansEyebrow")}
{t("landingPlansTitle")}
{t("landingPlansBody")}
{plans.map((plan) => (
{plan.id === "pro" && (
{t("landingAiAssistance")}
)}
{plan.name}
{plan.summary}
{plan.features.map((feature) => (
✓
{feature}
))}
{plan.id === "pro" ? (
goToPlan(plan.id)} sx={{ color: "#0b1020", fontWeight: 800 }}>
{plan.cta}
) : (
)}
))}
{t("landingCommercialTerms")}
{/* CTA */}
{t("landingReadyTitle")}
{t("landingReadyBody")}
{t("landingSignInArrow")}
{/* Footer */}
{t("landingFooter", { year: new Date().getFullYear() })}
);
}