Implement invitation renewal and optimize revalidation function

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.
This commit is contained in:
giancarlo
2024-03-29 11:14:55 +08:00
parent 7495dae062
commit 778cfde625
11 changed files with 326 additions and 40 deletions

View File

@@ -10,15 +10,18 @@ import pathsConfig from '~/config/paths.config';
interface Params {
searchParams: {
error: string;
invite_token: string;
};
}
function AuthCallbackErrorPage({ searchParams }: Params) {
const { error } = searchParams;
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(pathsConfig.auth.signIn);
redirect(signInPath);
}
return (
@@ -36,7 +39,7 @@ function AuthCallbackErrorPage({ searchParams }: Params) {
</div>
<Button>
<Link href={pathsConfig.auth.signIn}>
<Link href={signInPath}>
<Trans i18nKey={'auth:signIn'} />
</Link>
</Button>