Skip to content

Commit

Permalink
[WEB-1970] fix: onboarding invitation page fluctuation on refresh. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
prateekshourya29 authored Sep 19, 2024
1 parent 450bb42 commit 361ef92
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion web/app/onboarding/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const OnboardingPage = observer(() => {
/>
) : step === EOnboardingSteps.WORKSPACE_CREATE_OR_JOIN ? (
<CreateOrJoinWorkspaces
invitations={invitations ?? []}
invitations={invitations ?? []}
totalSteps={totalSteps}
stepChange={stepChange}
finishOnboarding={finishOnboarding}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const CreateOrJoinWorkspaces: React.FC<Props> = observer((props) => {
<div className="flex flex-col w-full items-center justify-center p-8 mt-6">
{currentView === ECreateOrJoinWorkspaceViews.WORKSPACE_JOIN ? (
<Invitations
invitations={invitations}
handleNextStep={handleNextStep}
handleCurrentViewChange={() => setCurrentView(ECreateOrJoinWorkspaceViews.WORKSPACE_CREATE)}
/>
Expand Down
7 changes: 2 additions & 5 deletions web/core/components/onboarding/invitations.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
"use client";

import React, { useState } from "react";
import useSWR from "swr";;
// types
import { IWorkspaceMemberInvitation } from "@plane/types";
// ui
import { Button, Checkbox, Spinner } from "@plane/ui";
// constants
import { MEMBER_ACCEPTED } from "@/constants/event-tracker";
import { USER_WORKSPACE_INVITATIONS } from "@/constants/fetch-keys";
import { ROLE } from "@/constants/workspace";
// helpers
import { truncateText } from "@/helpers/string.helper";
Expand All @@ -19,13 +17,14 @@ import { useEventTracker, useUserSettings, useWorkspace } from "@/hooks/store";
import { WorkspaceService } from "@/plane-web/services";

type Props = {
invitations: IWorkspaceMemberInvitation[];
handleNextStep: () => Promise<void>;
handleCurrentViewChange: () => void;
};
const workspaceService = new WorkspaceService();

export const Invitations: React.FC<Props> = (props) => {
const { handleNextStep, handleCurrentViewChange } = props;
const { invitations, handleNextStep, handleCurrentViewChange } = props;
// states
const [isJoiningWorkspaces, setIsJoiningWorkspaces] = useState(false);
const [invitationsRespond, setInvitationsRespond] = useState<string[]>([]);
Expand All @@ -34,8 +33,6 @@ export const Invitations: React.FC<Props> = (props) => {
const { fetchWorkspaces } = useWorkspace();
const { fetchCurrentUserSettings } = useUserSettings();

const { data: invitations } = useSWR(USER_WORKSPACE_INVITATIONS, () => workspaceService.userWorkspaceInvitations());

const handleInvitation = (workspace_invitation: IWorkspaceMemberInvitation, action: "accepted" | "withdraw") => {
if (action === "accepted") {
setInvitationsRespond((prevData) => [...prevData, workspace_invitation.id]);
Expand Down

0 comments on commit 361ef92

Please sign in to comment.