145 lines · 5.2 KB
import { createFileRoute, Link } from "@tanstack/react-router";
import { getDashboard, respondOrgInvitation } from "~/fns/account";
import { getProNudge } from "~/fns/pro";
import { ProNudge } from "~/components/billing/ProNudge";
import { useAction } from "~/hooks/use-action";
import { useEmailUnverified } from "~/hooks/use-viewer";
import { exploreRepos } from "~/fns/repos";
import { ActivityFeed } from "~/components/ActivityFeed";
import { Landing } from "~/components/marketing/Landing";
import { PageContainer } from "~/ui/PageContainer";
import { Panel } from "~/ui/Panel";
import { Button, buttonClass } from "~/ui/Button";
import { seo } from "~/utils/seo";
import { SITE_DESCRIPTION } from "~/lib/og";

export const Route = createFileRoute("/")({
  loader: async ({ context }) => {
    if (context.viewer) {
      const [dashboard, nudge] = await Promise.all([getDashboard(), getProNudge()]);
      return { kind: "dashboard" as const, ...dashboard, proNudge: nudge.show };
    }
    return { kind: "landing" as const, ...(await exploreRepos({ data: { page: 1 } })) };
  },
  head: ({ match }) => ({
    meta: seo({
      origin: match.context.publicUrl,
      path: "/",
      title: "gitfor · Open-source Git hosting, code review and CI",
      description: SITE_DESCRIPTION,
    }),
  }),
  component: HomePage,
});

function InvitationRow({ org, role, invitedBy }: { org: string; role: string; invitedBy: string | null }) {
  const action = useAction(respondOrgInvitation);
  const unverified = useEmailUnverified();
  return (
    <li className="flex items-center gap-2 px-4 py-2 text-sm">
      <span className="min-w-0 flex-1 truncate text-kumo-default">