/* eslint-disable qwik/jsx-img */
import { component$ } from "@builder.io/qwik";
import { DocumentHead, routeLoader$ } from "@builder.io/qwik-city";
import CallToAction from "~/components/landing/CallToAction";
import Footer from "~/components/landing/Footer";
import Hero from "~/components/landing/Hero";
import Navbar from "~/components/landing/Navbar";
import Stats from "~/components/landing/Stats";
import Testimonials from "~/components/landing/Testimonials";

export const useAuthCheck = routeLoader$(({ cookie, redirect: r, query }) => {
    const jwt = cookie.get("jwt");
    const set = Boolean(query.get("jwt_set"));

    if (jwt && set) {
        throw r(302, "/dashboard");
    }
    return {};
});

export default component$(() => {
    return (
        <>
            <Navbar />
            <div class="flex flex-col flex-grow w-screen items-center mb-24 gap-56">
                <Hero />
                <Stats />
                <Testimonials />
                <CallToAction />
            </div>
            <Footer />
        </>
    );
});

export const head: DocumentHead = {
    title: "Welcome to Qwik",
    meta: [
        {
            name: "description",
            content: "Qwik site description",
        },
    ],
};