"use client"; import { createApiClient } from "@app/lib/api"; import { Button } from "@app/components/ui/button"; import { Card, CardContent, CardFooter, CardHeader, CardTitle, } from "@app/components/ui/card"; import { useEnvContext } from "@app/hooks/useEnvContext"; import { XCircle } from "lucide-react"; import { useRouter } from "next/navigation"; import { useTranslations } from "next-intl"; type InviteStatusCardProps = { type: "rejected" | "wrong_user" | "user_does_not_exist" | "not_logged_in"; token: string; }; export default function InviteStatusCard({ type, token, }: InviteStatusCardProps) { const router = useRouter(); const api = createApiClient(useEnvContext()); const t = useTranslations(); async function goToLogin() { await api.post("/auth/logout", {}); router.push(`/auth/login?redirect=/invite?token=${token}`); } async function goToSignup() { await api.post("/auth/logout", {}); router.push(`/auth/signup?redirect=/invite?token=${token}`); } function renderBody() { if (type === "rejected") { return (

{t('inviteErrorNotValid')}

); } else if (type === "wrong_user") { return (

{t('inviteErrorUser')}

{t('inviteLoginUser')}

); } else if (type === "user_does_not_exist") { return (

{t('inviteErrorNoUser')}

{t('inviteCreateUser')}

); } } function renderFooter() { if (type === "rejected") { return ( ); } else if (type === "wrong_user") { return ( ); } else if (type === "user_does_not_exist") { return ; } } return (
{/*
*/} {t('inviteNotAccepted')}
{renderBody()} {renderFooter()}
); }