This commit adds a new function to renew team invitations and a central function for revalidating member page. It also removes redundant revalidations across different actions. The renew invitation function and UI elements are introduced including a new dialog for confirming the renewal action. Furthermore, function revalidateMemberPage() is added to abstract the revalidation path used multiple times in different functions. The code readability and maintainability have thus been improved.
51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
import Link from 'next/link';
|
|
import { redirect } from 'next/navigation';
|
|
|
|
import { Alert, AlertDescription, AlertTitle } from '@kit/ui/alert';
|
|
import { Button } from '@kit/ui/button';
|
|
import { Trans } from '@kit/ui/trans';
|
|
|
|
import pathsConfig from '~/config/paths.config';
|
|
|
|
interface Params {
|
|
searchParams: {
|
|
error: string;
|
|
invite_token: string;
|
|
};
|
|
}
|
|
|
|
function AuthCallbackErrorPage({ searchParams }: Params) {
|
|
const { error, invite_token } = searchParams;
|
|
const queryParam = invite_token ? `?invite_token=${invite_token}` : '';
|
|
const signInPath = pathsConfig.auth.signIn + queryParam;
|
|
|
|
// if there is no error, redirect the user to the sign-in page
|
|
if (!error) {
|
|
redirect(signInPath);
|
|
}
|
|
|
|
return (
|
|
<div className={'flex flex-col space-y-4 py-4'}>
|
|
<div>
|
|
<Alert variant={'destructive'}>
|
|
<AlertTitle>
|
|
<Trans i18nKey={'auth:authenticationErrorAlertHeading'} />
|
|
</AlertTitle>
|
|
|
|
<AlertDescription>
|
|
<Trans i18nKey={error} />
|
|
</AlertDescription>
|
|
</Alert>
|
|
</div>
|
|
|
|
<Button>
|
|
<Link href={signInPath}>
|
|
<Trans i18nKey={'auth:signIn'} />
|
|
</Link>
|
|
</Button>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default AuthCallbackErrorPage;
|