⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.
TypeScript agenticagileai-agentsbug-reportingbug-trackerganttissue-trackerjirajira-alternativekanbanlinearlinear-alternativeopen-sourceproduct-managementproject-managementroadmapself-hostedsprint-planningteam-collaborationtrello-alternative
'use client';
import Link from 'next/link';
import { useTranslations } from 'next-intl';
import type { InviteView } from '@/lib/api/endpoints/invites';
import { signOut, useSession } from '@/lib/auth-client';
import { projectRefOf } from '@/utils/paths';
import { Button } from '@/components/ui/button';
import InviteActions from './InviteActions';
import InviteAuthForm from './InviteAuthForm';
import InviteNotice from './InviteNotice';
// Picks what the invitee has to do next based on the invite status and the
// current session: sign in / register, accept or reject, or sign out of the
// account the invite was not sent to.
export default function InviteStep({ token, invite }: { token: string; invite: InviteView }) {
const t = useTranslations('invite');
const tCommon = useTranslations('common');
const { data: session, isPending: sessionPending } = useSession();
function switchAccount() {
void signOut('here');
}
if (invite.status !== 'pending' || invite.expired) {
return (
<InviteNotice>
<Button asChild variant="outline">
<Link href="/">{t('goToApp')}</Link>
</Button>
</InviteNotice>
);
}
if (sessionPending) {
return <p className="text-sm text-muted-foreground">{tCommon('loading')}</p>;
}
if (!session) {
return <InviteAuthForm token={token} email={invite.email} hasAccount={invite.hasAccount} />;
}
const sessionEmail = session.user.email;
if (sessionEmail.toLowerCase() === invite.email.toLowerCase()) {
return (
<InviteActions
token={token}
projectKey={invite.projectKey && projectRefOf(invite.teamRef, invite.projectKey)}
/>
);
}
return (
<InviteNotice
message={t.rich('wrongAccount', {
email: invite.email,
sessionEmail,
invited: (chunks) => <span className="font-medium text-foreground">{chunks}</span>,
current: (chunks) => <span className="font-medium text-foreground">{chunks}</span>,
})}
>
<Button variant="outline" onClick={switchAccount}>
{tCommon('signOut')}
</Button>
</InviteNotice>
);
}