From ce5fce4d632f30dcd4a55504b9f72787ef04986c Mon Sep 17 00:00:00 2001 From: Antoine Dewez <44063631+Zewed@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:00:08 +0200 Subject: [PATCH] feat(frontend): remove create brain step in onboarding when share brain (#2791) # Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate): --- frontend/app/invitation/[brainId]/hooks/useInvitation.ts | 3 +++ .../lib/components/OnboardingModal/OnboardingModal.tsx | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/frontend/app/invitation/[brainId]/hooks/useInvitation.ts b/frontend/app/invitation/[brainId]/hooks/useInvitation.ts index d483f5a4a..f2d1559b5 100644 --- a/frontend/app/invitation/[brainId]/hooks/useInvitation.ts +++ b/frontend/app/invitation/[brainId]/hooks/useInvitation.ts @@ -9,6 +9,7 @@ import { useTranslation } from "react-i18next"; import { BrainRoleType } from "@/app/studio/[brainId]/BrainManagementTabs/components/PeopleTab/BrainUsers/types"; import { useSubscriptionApi } from "@/lib/api/subscription/useSubscriptionApi"; import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext"; +import { useOnboardingContext } from "@/lib/context/OnboardingProvider/hooks/useOnboardingContext"; import { useToast } from "@/lib/hooks"; import { useEventTracking } from "@/services/analytics/june/useEventTracking"; @@ -21,6 +22,7 @@ export const useInvitation = () => { const [brainName, setBrainName] = useState(""); const [role, setRole] = useState(); const [isProcessingRequest, setIsProcessingRequest] = useState(false); + const { setIsBrainCreated } = useOnboardingContext(); const { publish } = useToast(); const { track } = useEventTracking(); @@ -63,6 +65,7 @@ export const useInvitation = () => { }, [brainId]); const handleAccept = async () => { + setIsBrainCreated(true); setIsProcessingRequest(true); try { await acceptInvitation(brainId); diff --git a/frontend/lib/components/OnboardingModal/OnboardingModal.tsx b/frontend/lib/components/OnboardingModal/OnboardingModal.tsx index bd829f7bc..f335bea50 100644 --- a/frontend/lib/components/OnboardingModal/OnboardingModal.tsx +++ b/frontend/lib/components/OnboardingModal/OnboardingModal.tsx @@ -14,8 +14,11 @@ import { SingleSelector } from "../ui/SingleSelector/SingleSelector"; import { TextInput } from "../ui/TextInput/TextInput"; export const OnboardingModal = (): JSX.Element => { - const { isOnboardingModalOpened, setIsOnboardingModalOpened } = - useOnboardingContext(); + const { + isOnboardingModalOpened, + setIsOnboardingModalOpened, + isBrainCreated, + } = useOnboardingContext(); const methods = useForm({ defaultValues: { @@ -46,7 +49,7 @@ export const OnboardingModal = (): JSX.Element => { await updateUserIdentity({ username: methods.getValues("username"), company: methods.getValues("companyName"), - onboarded: false, + onboarded: isBrainCreated, company_size: methods.getValues("companySize"), usage_purpose: methods.getValues("usagePurpose") as | UsagePurpose