import { useRouter } from 'next/router' import AlertError from 'components/ui/AlertError' import { OrganizationInviteByToken } from 'data/organization-members/organization-invitation-token-query' import { useSignOut } from 'lib/auth' import { useProfile } from 'lib/profile' import { ResponseError } from 'types' import { cn } from 'ui' interface OrganizationInviteError { data?: OrganizationInviteByToken error?: ResponseError isError: boolean } export const OrganizationInviteError = ({ data, error, isError }: OrganizationInviteError) => { const router = useRouter() const signOut = useSignOut() const { profile } = useProfile() return (
{isError ? ( ) : data?.token_does_not_exist ? (

The invite token is invalid.

Try copying and pasting the link from the invite email, or ask the organization owner to invite you again.

) : !data?.email_match ? (

Your email address {profile?.primary_email} does not match the email address this invitation was sent to.

To accept this invitation, you will need to{' '} { await signOut() router.reload() }} > sign out {' '} and then sign in or create a new account using the same email address used in the invitation.

) : data.expired_token ? (

The invite token has expired.

Please request a new one from the organization owner.

) : null}
) }