chore: email invite accept validation (#2965)

* fix: empty state flickering on accepting only invitation

* fix: redirection from workspace-invitaion to onboarding

* chore: onboarding step 1 skip on accepting invite from email

* fix: dashboard redirection path
This commit is contained in:
Lakhan Baheti 2023-12-05 16:06:43 +05:30 committed by Aaryan Khandelwal
parent 023bf8a0a5
commit 6e834ada66
3 changed files with 19 additions and 2 deletions

View File

@ -63,11 +63,11 @@ export const Invitations: React.FC<Props> = (props) => {
.joinWorkspaces({ invitations: invitationsRespond })
.then(async (res) => {
postHogEventTracker("WORKSPACE_USER_INVITE_ACCEPT", { ...res, state: "SUCCESS" });
await mutateInvitations();
await workspaceStore.fetchWorkspaces();
await mutate(USER_WORKSPACES);
await updateLastWorkspace();
await handleNextStep();
await mutateInvitations();
})
.catch((error) => {
console.log(error);

View File

@ -213,7 +213,7 @@ const UserInvitationsPage: NextPageWithLayout = observer(() => {
image={emptyInvitation}
primaryButton={{
text: "Back to dashboard",
onClick: () => router.push(`/${redirectWorkspaceSlug}`),
onClick: () => router.push("/"),
}}
/>
</div>

View File

@ -52,6 +52,10 @@ const OnboardingPage: NextPageWithLayout = observer(() => {
},
});
useSWR(`USER_WORKSPACES_LIST`, () => workspaceStore.fetchWorkspaces(), {
shouldRetryOnError: false,
});
const { data: invitations } = useSWR("USER_WORKSPACE_INVITATIONS_LIST", () =>
workspaceService.userWorkspaceInvitations()
);
@ -88,6 +92,19 @@ const OnboardingPage: NextPageWithLayout = observer(() => {
const onboardingStep = user.onboarding_step;
if (!onboardingStep.workspace_join && !onboardingStep.workspace_create && workspaces && workspaces?.length > 0) {
await updateCurrentUser({
onboarding_step: {
...user.onboarding_step,
workspace_join: true,
workspace_create: true,
},
last_workspace_id: workspaces[0].id,
});
setStep(2);
return;
}
if (!onboardingStep.workspace_join && !onboardingStep.workspace_create && step !== 1) setStep(1);
if (onboardingStep.workspace_join || onboardingStep.workspace_create) {