explit/app/routes/index.tsx

70 lines
2 KiB
TypeScript
Raw Permalink Normal View History

2022-02-13 21:25:00 +01:00
import type { User } from "@prisma/client";
2022-02-14 21:23:52 +01:00
import { LinksFunction, MetaFunction, LoaderFunction, redirect } from "remix";
import { Link, useLoaderData } from "remix";
2022-02-13 21:25:00 +01:00
import Header from "~/components/Header";
2022-02-21 15:21:44 +01:00
import ExplitLogo from "~/ExplitLogo";
2022-02-13 21:25:00 +01:00
import { getUser } from "~/utils/session.server";
2022-02-13 21:25:00 +01:00
type LoaderData = { user: User | null };
export const links: LinksFunction = () => {
return [];
};
export const meta: MetaFunction = () => {
return {
title: "Explit: track and split shared expenses",
description:
"Explit: track and split shared expenses with friends and family",
};
};
export const loader: LoaderFunction = async ({ request }) => {
2022-02-13 21:25:00 +01:00
const user = await getUser(request);
2022-02-14 21:23:52 +01:00
if (user) {
return redirect("/expenses");
}
2022-02-13 21:25:00 +01:00
const data: LoaderData = { user };
return data;
};
export default function Index() {
const data = useLoaderData<LoaderData>();
return (
2022-02-13 21:25:00 +01:00
<>
<Header user={data.user} />
2022-02-14 21:17:31 +01:00
<div
className="hero fixed top-0 left-0 h-screen w-screen"
style={{
backgroundImage: 'url("/explit.png")',
}}
>
<div className="hero-overlay bg-opacity-60"></div>
<div className="text-center hero-content glass rounded-box w-[80%] py-16 text-neutral-content">
<div className="max-w-md">
2022-02-21 15:21:44 +01:00
<figure className="max-w-xs max-h-xs flex mx-auto justify-center items-center mb-6">
<ExplitLogo className="w-[70%] h-auto max-h-20 md:max-h-none object-contain" />
</figure>
2022-02-14 21:17:31 +01:00
<h1 className="mb-5 text-5xl font-bold">Explit</h1>
<p className="mb-5">
Track and split shared expenses with friends and family.
</p>
2022-02-14 21:23:52 +01:00
{data.user ? (
<Link to="/expenses" className="btn btn-primary">
Go to expenses
</Link>
) : (
<Link to="/signin" className="btn btn-primary">
Get Started
</Link>
)}
2022-02-14 21:17:31 +01:00
</div>
2022-02-13 21:25:00 +01:00
</div>
</div>
2022-02-13 21:25:00 +01:00
</>
);
}