Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

migration: onboarding & some team api

ahmedcoder016126e41f2936
diff --git a/packages/app/src/backend/routes/pages/router.ts b/packages/app/src/backend/routes/pages/router.ts
index ca5870ea..ad4de68e 100644
--- a/packages/app/src/backend/routes/pages/router.ts
+++ b/packages/app/src/backend/routes/pages/router.ts
@@ -229,8 +229,6 @@ router.get('/agent-settings/:agentId', llmModelsLoaderMiddleware, createReactRou
router.get('/agent-settings/:agentId/bulk/:componentId', createReactRoute());
-router.get('/onboard', createReactRoute({ hideTopMenu: true, includeTracking: true }));
-
router.get(
'/welcome',
checkOnboardingMW,
diff --git a/packages/app/src/react/app/routeMap.tsx b/packages/app/src/react/app/routeMap.tsx
index 694a37d8..99e6829c 100644
--- a/packages/app/src/react/app/routeMap.tsx
+++ b/packages/app/src/react/app/routeMap.tsx
@@ -11,12 +11,6 @@ import AIChatPage from '../features/ai-chat/pages/ai-chat';
import DataPage from '../features/data-space/pages/DataPage';
import DatasourceLibrary from '../features/data-space/pages/DatasourceLibrary';
import DomainsPage from '../features/domains-space/pages/DomainsPage';
-import { BookAnIntroCallPage } from '../features/onboarding/pages/BookAnIntroCallPage';
-import { OnboardPage } from '../features/onboarding/pages/OnboardPage';
-import { WelcomePage } from '../features/onboarding/pages/WelcomePage';
-import { WelcomePayment } from '../features/onboarding/pages/WelcomePayment';
-import { WelcomeTeamPage } from '../features/onboarding/pages/WelcomeTeamPage';
-import { WelcomeWorkPage } from '../features/onboarding/pages/WelcomeWorkPage';
import PartnersPage from '../features/partners/pages/PartnersPage';
import FeaturePageUpsell from '../features/subscriptions/components/paywalls/feature-page-upsell';
import {
@@ -105,66 +99,6 @@ export const routeMap: IPageRoute[] = [
UpsellContent: <FeaturePageUpsell.BulkCalls />,
},
},
- {
- path: '/onboard',
- title: 'Almost there ...',
- component: OnboardPage,
- layoutOptions: {
- sidebar: false,
- topMenu: false,
- },
- },
- {
- path: '/welcome',
- title: 'Almost there ...',
- component: WelcomePage,
- layoutOptions: {
- sidebar: false,
- topMenu: false,
- container: false,
- },
- },
- {
- path: '/welcome/jobtype',
- title: 'What do you do?',
- component: WelcomeTeamPage,
- layoutOptions: {
- sidebar: false,
- topMenu: false,
- container: false,
- },
- },
- {
- path: '/welcome/work',
- title: 'What do you want to build?',
- component: WelcomeWorkPage,
- layoutOptions: {
- sidebar: false,
- topMenu: false,
- container: false,
- },
- },
- {
- path: '/welcome/book-intro-call',
- title: 'Schedule Your Onboarding Call',
- component: BookAnIntroCallPage,
- layoutOptions: {
- sidebar: false,
- topMenu: false,
- container: false,
- },
- },
-
- {
- path: '/welcome/payment',
- title: 'Welcome to SmythOS!',
- component: WelcomePayment,
- layoutOptions: {
- sidebar: false,
- topMenu: false,
- container: false,
- },
- },
{
path: '/enterprise-t1',
@@ -217,8 +151,18 @@ export const routeMap: IPageRoute[] = [
},
},
- { path: '/', component: AgentsPage, title: 'Agents', layoutOptions: { background: 'agentsGradient' } },
- { path: '/agents', component: AgentsPage, title: 'Agents', layoutOptions: { background: 'agentsGradient' } },
+ {
+ path: '/',
+ component: AgentsPage,
+ title: 'Agents',
+ layoutOptions: { background: 'agentsGradient' },
+ },
+ {
+ path: '/agents',
+ component: AgentsPage,
+ title: 'Agents',
+ layoutOptions: { background: 'agentsGradient' },
+ },
{
title: 'My Plan',
diff --git a/packages/app/src/react/features/onboarding/components/BookAnIntroCall.tsx b/packages/app/src/react/features/onboarding/components/BookAnIntroCall.tsx
deleted file mode 100644
index fb5f4d68..00000000
--- a/packages/app/src/react/features/onboarding/components/BookAnIntroCall.tsx
+++ /dev/null
@@ -1,13 +0,0 @@
-export const BookAnIntroCall = () => {
- return (
- <div className="pb-0 md:pb-[60px] text-center md:px-[84px] px-0">
- <h1 className="w-full text-center font-medium mb-6 md:mb-6 text-2xl">
- Schedule Your Onboarding Call
- </h1>
- <p className="text-center text-sm">
- Let's get you set up for success! Schedule a personalized onboarding session with our team
- to maximize your experience and receive dedicated support for your new account.
- </p>
- </div>
- );
-};
diff --git a/packages/app/src/react/features/onboarding/components/BuildingQuestion.tsx b/packages/app/src/react/features/onboarding/components/BuildingQuestion.tsx
deleted file mode 100644
index 6d65f730..00000000
--- a/packages/app/src/react/features/onboarding/components/BuildingQuestion.tsx
+++ /dev/null
@@ -1,68 +0,0 @@
-import { Spinner } from '@src/react/shared/components/ui/spinner';
-import { MAX_CHAT_MESSAGE_LENGTH } from '@src/react/shared/constants';
-import { useQuery } from '@tanstack/react-query';
-import classNames from 'classnames';
-import { ChangeEvent, useEffect, useState } from 'react';
-
-export const BuildingQuestion = ({ setData, setIsContinueDisabled }) => {
- const [inputValue, setInputValue] = useState('');
- const MAX_CHAR_LIMIT = MAX_CHAT_MESSAGE_LENGTH;
-
- const queryData = useQuery({
- queryKey: ['onboard/get-building-data'],
- queryFn: async () => {
- const response = await fetch('/api/page/onboard/get-building-data');
- return response.json();
- },
- refetchOnMount: true,
- refetchInterval: false,
- refetchOnReconnect: false,
- refetchOnWindowFocus: false,
- });
-
- useEffect(() => {
- setInputValue(queryData.data?.value || '');
- }, [queryData.data]);
-
- const handleInputChange = (event: ChangeEvent<HTMLTextAreaElement>) => {
- if (event.target.value.length < MAX_CHAR_LIMIT) {
- setData({ value: event.target.value });
- }
- setInputValue(event.target.value);
- };
-
- useEffect(() => {
- setIsContinueDisabled(inputValue.length < 1 || inputValue.length > MAX_CHAR_LIMIT - 1);
- }, [inputValue]);
-
- // more descriptive name
- const charCount = inputValue.length;
-
- return (
- <div className="pb-0 md:pb-[60px] text-center md:px-[84px] px-0">
- {queryData.isFetching && (
- <div className="absolute inset-0 bg-white bg-opacity-90 flex items-center justify-center z-10 w-full h-full">
- <Spinner />
- </div>
- )}
- <h1 className="w-full text-center font-medium mb-6 md:mb-6 text-2xl">
- What are you building?
- </h1>
- <textarea
- value={inputValue}
- onChange={handleInputChange}
- placeholder="I'm building an agent that will ..."
- className="w-full border-1 border-solid border-gray-300 max-h-48 h-48 rounded-md p-3
- resize-none outline-0 focus:outline-0 focus:ring-0 focus:border-gray-500"
- />
- <div
- className={classNames('text-right font-medium text-xs tracking-wider', {
- 'text-red-500': charCount > MAX_CHAR_LIMIT - 1,
- 'text-gray-500': charCount <= MAX_CHAR_LIMIT - 1,
- })}
- >
- {`${charCount}/${MAX_CHAR_LIMIT}`}
- </div>
- </div>
- );
-};
diff --git a/packages/app/src/react/features/onboarding/components/PageCard.tsx b/packages/app/src/react/features/onboarding/components/PageCard.tsx
deleted file mode 100644
index b1f9543b..00000000
--- a/packages/app/src/react/features/onboarding/components/PageCard.tsx
+++ /dev/null
@@ -1,263 +0,0 @@
-import classNames from 'classnames';
-import React, { useEffect, useState } from 'react';
-import { FaAngleLeft } from 'react-icons/fa6';
-// we always use FontAwesome6 icons. https://react-icons.github.io/react-icons/icons/fa6/
-
-import HorizontalProgressBar from '@react/features/onboarding/components/horizontalProgressBar';
-import { ArrowRightIcon, TelegramIcon } from '@src/react/shared/components/svgs';
-import { Button } from '@src/react/shared/components/ui/newDesign/button';
-import { Spinner } from '@src/react/shared/components/ui/spinner';
-import { FEATURE_FLAGS } from '@src/shared/constants/featureflags';
-import { PostHog } from '@src/shared/posthog';
-import { X } from 'lucide-react';
-
-interface PageCardProps<T = any> {
- size?: 'sm' | 'md' | 'lg';
- progress: number;
- hasSkip?: boolean;
- skipText?: string;
- hasClose?: boolean;
- canGoBack?: boolean;
- hideFooter?: boolean;
- isDisabled?: boolean;
- isBuilding?: boolean;
- errorMessage?: string;
- continueText?: string;
- isShareAgent?: boolean;
- hasLogo?: boolean;
- title?: string;
- pageCardClasses?: string;
- pageCardMainBodyClasses?: string;
- BodyComponent: React.ElementType<{
- setData: React.Dispatch<React.SetStateAction<T>>;
- setIsContinueDisabled: React.Dispatch<React.SetStateAction<boolean>>;
- isShareAgent?: boolean;
- handleContinueEvent?: (event?: React.MouseEvent<HTMLButtonElement>) => Promise<void>;
- extraProps?: any;
- }>;
- ErrorCTA?: React.ElementType;
- skipEvent: (event: React.MouseEvent<HTMLButtonElement>) => void;
- backEvent: (event: React.MouseEvent<HTMLButtonElement>) => void;
- closeEvent: (event: React.MouseEvent<HTMLButtonElement>) => void;
- continueEvent: (event: React.MouseEvent<HTMLButtonElement>, data?: T | string) => Promise<void>;
- extraProps?: any;
- actionButtonHalfWidth?: boolean;
-}
-
-let startProgress: number | undefined;
-
-export const PageCard: React.FC<PageCardProps> = ({
- progress,
- skipEvent,
- backEvent,
- closeEvent,
- isBuilding,
- isDisabled,
- size = 'md',
- errorMessage,
- BodyComponent,
- continueEvent,
- hasSkip = false,
- canGoBack = true,
- hasClose = false,
- hideFooter = false,
- pageCardClasses = '',
- pageCardMainBodyClasses = '',
- isShareAgent = false,
- extraProps,
- ErrorCTA,
- skipText = 'Skip',
- continueText = 'Continue',
- actionButtonHalfWidth = false,
- hasLogo = true,
- title = '',
-}) => {
- const [data, setData] = useState<string>('');
- const [isBusy, setIsBusy] = useState(false);
- const [isContinueDisabled, setIsContinueDisabled] = useState(false);
- const [progressValue, setProgressValue] = useState(0);
- const [showGoToDashboardButton, setShowGoToDashboardButton] = useState<boolean>(false);
-
- async function handleContinueEvent(event?: React.MouseEvent<HTMLButtonElement>) {
- setIsBusy(true);
- await continueEvent(event, data);
- setIsBusy(false);
- }
-
- useEffect(() => {
- if (!startProgress || progress > startProgress) {
- startProgress = 0;
- setProgressValue(0);
- }
- setTimeout(() => {
- setProgressValue(progress);
- startProgress = progress;
- }, 500);
-
- const flagValue = PostHog.getFeatureFlagValue(FEATURE_FLAGS.GO_TO_DASHBOARD_FROM_ONBOARDING);
- setShowGoToDashboardButton(typeof flagValue === 'string' ? flagValue === 'control' : true);
- }, []);
-
- return (
- <div
- className={classNames(
- pageCardClasses,
- 'page-card bg-white shadow-sm border border-solid border-gray-100 p-4 md:p-6 md:w-4/5 rounded-lg text-black',
- {
- 'max-w-[562px]': size === 'sm',
- 'max-w-[712px]': size === 'md',
- 'max-w-[832px]': size === 'lg',
- },
- )}
- >
- {isBusy && (
- <div
- className="bg-white cover absolute top-0 left-0 w-full h-full
- flex justify-center items-center opacity-80 z-10"
- >
- <Spinner />
- </div>
- )}
- <header
- className={classNames('flex items-center justify-between', {
- ' mb-8 md:mb-[60px]': !isShareAgent,
- 'mb-4': isShareAgent,
- })}
- >
- {canGoBack && (
- <button
- onClick={backEvent}
- className="transition duration-300 px-3 py-2 -ml-3 hover:bg-gray-200 hover:text-gray-900
- dark:hover:bg-gray-600 dark:hover:text-white rounded-md flex items-center justify-start"
- >
- <FaAngleLeft />
- </button>
- )}
-
- {title && (
- <h1 className={`text-xl ${isShareAgent ? 'font-semibold text-[#1E1E1E]' : 'font-bold'}`}>
- {title}
- </h1>
- )}
- {hasLogo && (
- <div className="flex items-center justify-center flex-grow transition duration-300">
- <img src="/img/smythos-logo.png" className="h-12" alt="SmythOS" />
- </div>
- )}
- {hasClose && (
- <button
- onClick={closeEvent}
- className={`absolute right-0 flex items-center justify-end
- hover:bg-gray-200 p-3 -mr-3 hover:text-gray-900 dark:hover:bg-gray-600 dark:hover:text-white
- transition duration-300 rounded-md`}
- >
- <X className="h-5 w-5 font-bold" color="#1E1E1E" strokeWidth={2} />
- </button>
- )}
- </header>
- <main
- className={classNames(
- `page-card-body ${
- pageCardMainBodyClasses ? pageCardMainBodyClasses : 'mb-8 md:mb-[60px]'
- }`,
- )}
- >
- <BodyComponent
- setData={setData}
- setIsContinueDisabled={setIsContinueDisabled}
- isShareAgent={isShareAgent}
- handleContinueEvent={handleContinueEvent}
- extraProps={extraProps}
- />
- </main>
- {errorMessage && (
- <div className="text-center">
- <small className="text-red-500">{errorMessage}</small>
- </div>
- )}
-
- {ErrorCTA && <ErrorCTA />}
-
- {!hideFooter && isBuilding ? (
- <footer
- className={classNames('flex w-full place-items-center ', {
- 'md:px-[84px] px-0': !showGoToDashboardButton,
- 'gap-2.5': showGoToDashboardButton,
- })}
- >
- <Button
- variant="primary"
- disabled={isContinueDisabled || isDisabled}
- handleClick={handleContinueEvent}
- fullWidth={showGoToDashboardButton}
- className={classNames(
- 'py-4 text-base h-[59px] rounded-lg bg-[#3C89F9] disabled:bg-[#8AB8FB] disabled:text-white float-right',
- {
- 'w-1/2 ml-auto': !showGoToDashboardButton,
- },
- )}
- >
- <TelegramIcon className="mr-2" />
- Build with AI
- </Button>
- {showGoToDashboardButton && (
- <Button
- disabled={isContinueDisabled}
- handleClick={() => (window.location.href = '/agents')}
- fullWidth
- variant="quaternary"
- className="disabled:opacity-80 disabled:cursor-not-allowed float-right"
- >
- <div className="flex w-full flex-col items-start justify-start">
- <span className="text-[15px] font-semibold text-[#3C89F9] group-hover:text-smyth-blue">
- Go to Dashboard
- </span>
- <span className="leading-relaxed text-xs text-[#6A89B7] group-hover:text-smyth-blue">
- Explore the workspace first.
- </span>
- </div>
- <ArrowRightIcon className="stroke-[#3C89F9] group-hover:stroke-smyth-blue" />
- </Button>
- )}
- </footer>
- ) : (
- !hideFooter && (
- <footer className="flex w-full mt-4 h-12 text-base">
- <div className="footer-left w-1/2 flex items-center justify-start">
- {/* Content for footer left */}
- {!extraProps?.hideProgress && (
- <div className="progress-placeholder w-[54%] h-2 rounded">
- <HorizontalProgressBar progress={progressValue} />
- </div>
- )}
- </div>
- <div
- className={classNames('"footer-right flex items-center justify-between gap-x-2', {
- 'w-full md:w-1/2': extraProps?.hideProgress,
- 'w-1/2': !extraProps?.hideProgress,
- })}
- >
- {/* Adjust the width of Continue and Skip buttons along with their specific styles */}
- {hasSkip && (
- <div className={`${actionButtonHalfWidth ? 'w-1/2' : 'w-3/12'}`}>
- <Button handleClick={skipEvent} variant="secondary" fullWidth>
- {skipText || 'Skip'}
- </Button>
- </div>
- )}
- <div className={`${actionButtonHalfWidth ? 'w-1/2' : 'w-60'}`}>
- <Button
- disabled={isContinueDisabled || isDisabled}
- handleClick={handleContinueEvent}
- fullWidth
- >
- {continueText || 'Continue....'}
- </Button>
- </div>
- </div>
- </footer>
- )
- )}
- </div>
- );
-};
diff --git a/packages/app/src/react/features/onboarding/components/TeamPageBody.tsx b/packages/app/src/react/features/onboarding/components/TeamPageBody.tsx
deleted file mode 100644
index 45fa8cd2..00000000
--- a/packages/app/src/react/features/onboarding/components/TeamPageBody.tsx
+++ /dev/null
@@ -1,130 +0,0 @@
-import { TeamTag } from '@src/react/features/onboarding/components/TeamTag';
-import { UserTeamCard } from '@src/react/features/onboarding/components/UserCard';
-import {
- ISingleTeam,
- UserOnboardingTeams,
-} from '@src/react/features/onboarding/data/onboarding-mappings';
-import { Input as CustomInput } from '@src/react/shared/components/ui/input';
-import { Spinner } from '@src/react/shared/components/ui/spinner';
-import { useAuthCtx } from '@src/react/shared/contexts/auth.context';
-import { useQuery } from '@tanstack/react-query';
-import { useCallback, useEffect, useState } from 'react';
-
-export interface ITeamPageData {
- firstname: string;
- lastname: string;
- team: ISingleTeam | null;
-}
-
-export const TeamPageBody = ({ setData, setIsContinueDisabled }) => {
- const { userInfo } = useAuthCtx();
- const [currentTeam, setCurrentTeam] = useState<ISingleTeam | null>(null);
- const [firstname, setFirstname] = useState('');
- const [lastname, setLastname] = useState('');
-
- const queryData = useQuery({
- queryKey: ['onboard/get-data'],
- queryFn: async () => {
- const response = await fetch('/api/page/onboard/get-data');
- return response.json();
- },
- refetchOnMount: true,
- refetchInterval: false,
- refetchOnReconnect: false,
- refetchOnWindowFocus: false,
- });
-
- /**
- * Set the name and team from the query data
- * when the query data changes
- * @param queryData
- */
- useEffect(() => {
- const _currentTeam = UserOnboardingTeams.find(
- (team) => team.value === queryData.data?.jobRoleValue,
- );
- setCurrentTeam(_currentTeam || null);
-
- // Restore first name and last name from server data
- setFirstname(queryData.data?.firstname || '');
- setLastname(queryData.data?.lastname || '');
- }, [queryData.data]);
-
- const handleTeamSelection = useCallback((team: ISingleTeam) => {
- setCurrentTeam((prevTeam) => (prevTeam?.value === team.value ? null : team));
- }, []);
-
- useEffect(() => {
- setData((oldVal: ITeamPageData) => ({
- ...oldVal,
- firstname: firstname,
- lastname: lastname,
- team: currentTeam,
- }));
- setIsContinueDisabled(!currentTeam?.value || !firstname.trim() || !lastname.trim());
- }, [currentTeam, firstname, lastname]);
-
- const renderHeading = (classes: string) => {
- return (
- <div className={classes}>
- <h1 className="text-xl">Let's Personalize Your Experience</h1>
- <p className="text-sm">
- Tell us a bit about yourself so we can tailor SmythOS to your needs.
- </p>
- </div>
- );
- };
- return (
- <div className="w-full bg-white flex justify-center items-stretch rounded-md flex-col-reverse md:flex-row relative">
- {queryData.isFetching && (
- <div className="absolute inset-0 bg-white bg-opacity-90 flex items-center justify-center z-10 w-full h-full">
- <Spinner />
- </div>
- )}
- {renderHeading('order-3 md:hidden space-y-2')}
- <div className="w-full md:w-1/2 order-1 md:order-1 pr-2 pl-4">
- {renderHeading('hidden md:block space-y-2')}
- <div className="mt-4 flex gap-4">
- <CustomInput
- fullWidth
- value={firstname}
- label="First Name"
- placeholder="John"
- onChange={(e) => {
- setFirstname(e.target.value);
- }}
- />
- <CustomInput
- fullWidth
- value={lastname}
- label="Last Name"
- placeholder="Smyth"
- onChange={(e) => {
- setLastname(e.target.value);
- }}
- />
- </div>
- <div className="flex flex-wrap gap-2 mt-4">
- {UserOnboardingTeams.map((team) => (
- <TeamTag
- key={team.name}
- team={team}
- selectedTeam={currentTeam}
- onTeamSelect={handleTeamSelection}
- />
- ))}
- </div>
- </div>
- <div className="w-full md:w-1/2 order-2 md:order-2">
- <div className="rounded-md bg-white md:bg-gray-50 h-full flex flex-col justify-center p-0 md:p-4 my-4">
- <UserTeamCard
- username={`${firstname} ${lastname}`.trim()}
- selectedTeam={currentTeam}
- email={userInfo.user.email}
- avatar={userInfo.user.avatar}
- />
- </div>
- </div>
- </div>
- );
-};
diff --git a/packages/app/src/react/features/onboarding/components/TeamTag.tsx b/packages/app/src/react/features/onboarding/components/TeamTag.tsx
deleted file mode 100644
index a5d398fd..00000000
--- a/packages/app/src/react/features/onboarding/components/TeamTag.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import { ISingleTeam } from '@src/react/features/onboarding/data/onboarding-mappings';
-import classNames from 'classnames';
-import { memo } from 'react';
-
-interface ITeamTagProps {
- team: ISingleTeam;
- isReadonly?: boolean;
- selectedTeam: ISingleTeam | null;
- onTeamSelect?: (team: ISingleTeam) => void;
-}
-
-export const TeamTag = memo(
- ({ team, selectedTeam, isReadonly, onTeamSelect }: ITeamTagProps) => {
- const isSelected = selectedTeam?.value === team?.value;
- const hasSelectedTeam = selectedTeam !== null && !isSelected;
-
- return (
- <div
- onClick={() => onTeamSelect?.(team)}
- className={classNames(
- 'group flex justify-between items-center gap-2 border border-solid px-2 py-1 text-sm rounded-md',
- {
- 'text-gray-400 border-gray-400': hasSelectedTeam,
- 'text-gray-600 border-gray-400': !hasSelectedTeam,
- 'text-gray-600 border-primary-100 bg-green-100': isSelected && !isReadonly,
- 'hover:text-gray-600 hover:border-primary-100 hover:bg-green-100 cursor-pointer':
- !isReadonly,
- },
- )}
- >
- {team?.icon && (
- <team.icon
- className={classNames('inline-block text-sm', {
- 'text-primary-100': isSelected,
- 'text-gray-400': hasSelectedTeam,
- 'text-gray-600': !hasSelectedTeam,
- 'group-hover:text-primary-100': !isReadonly,
- })}
- />
- )}
- {team?.name}
- </div>
- );
- },
-);
diff --git a/packages/app/src/react/features/onboarding/components/UserCard.tsx b/packages/app/src/react/features/onboarding/components/UserCard.tsx
deleted file mode 100644
index f78be495..00000000
--- a/packages/app/src/react/features/onboarding/components/UserCard.tsx
+++ /dev/null
@@ -1,70 +0,0 @@
-import { TeamTag } from '@src/react/features/onboarding/components/TeamTag';
-import { ISingleTeam } from '@src/react/features/onboarding/data/onboarding-mappings';
-import classNames from 'classnames';
-import { Avatar } from 'flowbite-react';
-
-interface UserTeamCardBaseProps {
- selectedTeam?: ISingleTeam;
- avatar?: string;
-}
-
-interface EmailProps extends UserTeamCardBaseProps {
- email: string;
- username?: string;
-}
-
-interface UsernameProps extends UserTeamCardBaseProps {
- username: string;
- email?: string;
-}
-
-const AvatarThemeSettings = {
- root: {
- base: 'flex gap-x-4 rounded flex-wrap w-full [&>div:nth-child(2)]:max-w-[calc(100%_-_56px)]',
- color: {
- pink: 'ring-red-600 dark:ring-red-600',
- },
- initials: {
- text: 'font-medium text-white dark:text-white',
- base: 'relative inline-flex items-center justify-center overflow-hidden bg-red-600 dark:bg-red-600',
- },
- },
-};
-
-// Union type for the props, so that we can use the component with either email or username
-type UserTeamCardProps = EmailProps | UsernameProps;
-
-export const UserTeamCard = ({ selectedTeam, avatar, username, email }: UserTeamCardProps) => {
- const extractInitials = (name: string) => {
- return name
- .split(' ')
- .map((n) => n.charAt(0))
- .join('')
- .toUpperCase();
- };
-
- return (
- <div className="bg-gray-50 md:bg-white rounded-lg p-4 flex flex-col items-start gap-4 border border-solid border-gray-200">
- <Avatar
- img={avatar}
- placeholderInitials={extractInitials(username || email || '')}
- rounded
- color="pink"
- theme={AvatarThemeSettings}
- >
- {
- <div
- className={classNames('w-full red-bg-600', {
- 'font-medium': username?.length, // bold only if username is present
- })}
- >
- <div className="text-lg overflow-hidden text-ellipsis w-full leading-10">
- {username || email}
- </div>
- </div>
- }
- </Avatar>
- {selectedTeam && <TeamTag team={selectedTeam} selectedTeam={selectedTeam} isReadonly />}
- </div>
- );
-};
diff --git a/packages/app/src/react/features/onboarding/components/agent-onboarding-section/OnboardingTasks.tsx b/packages/app/src/react/features/onboarding/components/agent-onboarding-section/OnboardingTasks.tsx
index 9d736446..b07c1488 100644
--- a/packages/app/src/react/features/onboarding/components/agent-onboarding-section/OnboardingTasks.tsx
+++ b/packages/app/src/react/features/onboarding/components/agent-onboarding-section/OnboardingTasks.tsx
@@ -108,6 +108,7 @@ export const OnboardingTasks = ({ onDismiss }: { onDismiss: () => void }) => {
</div>
)}
+ {/* TODO:ENT: add this */}
{/* {isInviteMemberModalOpen &&
createPortal(
<Suspense fallback={<Spinner />}>
diff --git a/packages/app/src/react/features/onboarding/components/horizontalProgressBar.tsx b/packages/app/src/react/features/onboarding/components/horizontalProgressBar.tsx
deleted file mode 100644
index bdf248bf..00000000
--- a/packages/app/src/react/features/onboarding/components/horizontalProgressBar.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-import { FC } from 'react';
-
-interface HorizontalProgressBarProps {
- progress: number; // Progress out of 100
-}
-
-const HorizontalProgressBar: FC<HorizontalProgressBarProps> = ({ progress }) => {
- return (
- <div className="h-2 w-full bg-gray-200 rounded-full overflow-hidden">
- <div
- className="h-2 bg-green-400 rounded-full transition-all duration-1000 ease-linear"
- style={{ width: `${progress}%` }}
- />
- </div>
- );
-};
-
-export default HorizontalProgressBar;
diff --git a/packages/app/src/react/features/onboarding/constants/index.ts b/packages/app/src/react/features/onboarding/constants/index.ts
deleted file mode 100644
index 61691c7f..00000000
--- a/packages/app/src/react/features/onboarding/constants/index.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-export const PAID_PLANS = [
- 'scaleup',
- 'enterprise',
- 'startup',
- 'enterprise t1',
- 'enterprise t2',
- 'enterprise t3',
- 'enterprise t4',
-];
diff --git a/packages/app/src/react/features/onboarding/pages/BookAnIntroCallPage.tsx b/packages/app/src/react/features/onboarding/pages/BookAnIntroCallPage.tsx
deleted file mode 100644
index 08c912a0..00000000
--- a/packages/app/src/react/features/onboarding/pages/BookAnIntroCallPage.tsx
+++ /dev/null
@@ -1,205 +0,0 @@
-import { BookAnIntroCall } from '@src/react/features/onboarding/components/BookAnIntroCall';
-import { PageCard } from '@src/react/features/onboarding/components/PageCard';
-import { useGetBookAnIntroCall } from '@src/react/features/onboarding/hooks/useGetUserOnboardingSettings';
-import { useMutateBookAnIntroCall } from '@src/react/features/onboarding/hooks/useMutateOnboardingData';
-import { useAuthCtx } from '@src/react/shared/contexts/auth.context';
-import { FRONTEND_USER_SETTINGS } from '@src/react/shared/enums';
-import { sanitizeRedirectPath } from '@src/shared/utils';
-import { MouseEvent, useCallback, useEffect, useRef, useState } from 'react';
-import { useNavigate, useSearchParams } from 'react-router-dom';
-
-type IntroCallSettings = {
- email: string;
- isBooked: boolean;
- planName: string;
-};
-
-export const BookAnIntroCallPage = ({ hasBack = false }: { hasBack?: boolean }) => {
- const user = useAuthCtx();
- const navigate = useNavigate();
- const { userInfo, loading } = user;
- const [error, setError] = useState('');
- const hasStoredInitialState = useRef(false);
-
- // Single mutation with conditional redirect based on initialization context
- const { mutate: mutateBookAnIntroCall } = useMutateBookAnIntroCall({
- onError: () => {
- setError('We could not store the data. Please try again.');
- },
- onSuccess: () => {
- // Remove automatic redirect - goForward should only happen on user action
- // The initialization call should not trigger navigation
- },
- });
-
- const { data: currentSettings, refetch } = useGetBookAnIntroCall({
- options: {
- refetchOnWindowFocus: false,
- refetchOnMount: false,
- refetchOnFocus: false,
- refetchOnReconnect: false,
- },
- });
-
- const [searchParams] = useSearchParams();
- // Get the redirect path without any additional parameters
- const redirectPath = searchParams.get('redirectFromIntroCall') || '';
-
- // Collect all other query parameters to be added to the redirect URL
- const otherParams = Array.from(searchParams.entries())
- .filter(([key]) => key !== 'redirectFromIntroCall')
- .reduce((acc, [key, value]) => {
- acc[key] = value;
- return acc;
- }, {});
-
- // Build the final redirect URL with all parameters
- let urlRedirect = redirectPath;
- if (Object.keys(otherParams).length > 0) {
- const queryString = new URLSearchParams(otherParams).toString();
- urlRedirect = `${redirectPath}${redirectPath.includes('?') ? '&' : '?'}${queryString}`;
- }
-
- const handleBackEvent = useCallback(
- (event: MouseEvent<HTMLButtonElement>) => {
- navigate('/welcome/work');
- },
- [navigate],
- );
-
- useEffect(() => {
- if (urlRedirect) {
- sessionStorage.setItem(
- FRONTEND_USER_SETTINGS.REDIRECT_PATH_KEY_WELCOME_PAGE,
- sanitizeRedirectPath(urlRedirect),
- );
- // Only set to hide the back button if we don't want to allow navigation back
- // from the target destination
- const shouldHideBackButton =
- urlRedirect.includes('/builder') || urlRedirect.includes('/agents');
- if (shouldHideBackButton) {
- sessionStorage.setItem(FRONTEND_USER_SETTINGS.HIDE_BACK_BUTTON_WELCOME_PAGE, 'true');
- } else {
- // Remove the item if it exists and we don't need to hide the back button
- sessionStorage.removeItem(FRONTEND_USER_SETTINGS.HIDE_BACK_BUTTON_WELCOME_PAGE);
- }
- }
- }, [urlRedirect]);
-
- useEffect(() => {
- const storeInitialState = async () => {
- if (hasStoredInitialState.current) return;
-
- try {
- const newSettings = {
- isBooked: false,
- email: userInfo.user?.email ?? '',
- planName: userInfo.teamSubs?.subscription?.plan?.name ?? '',
- };
-
- // Handle different scenarios for storing initial state
- if (!currentSettings) {
- // No existing settings - store initial state
- await mutateBookAnIntroCall(newSettings);
- hasStoredInitialState.current = true;
- } else if (currentSettings?.planName !== newSettings?.planName) {
- // Settings exist but plan name changed - update
- await mutateBookAnIntroCall(newSettings);
- hasStoredInitialState.current = true;
- } else {
- // Settings exist and plan name matches - no need to store
- hasStoredInitialState.current = true;
- }
- } catch (err) {
- console.error('Failed to store initial intro call state:', err);
- // Even if there's an error, mark as stored to prevent infinite retries
- hasStoredInitialState.current = true;
- }
- };
-
- if (!loading && userInfo.user?.email) {
- storeInitialState();
- }
- }, [
- loading,
- userInfo.user?.email,
- userInfo.teamSubs?.subscription?.plan?.name,
- currentSettings,
- mutateBookAnIntroCall,
- ]);
-
- const goForward = useCallback(() => {
- // const teamSeats = getFeatPlanLimitByKey('teamMembers', userInfo?.teamSubs?.subscription);
- const teamSeats =
- userInfo?.teamSubs?.subscription?.plan?.properties?.limits?.['teamMembers'] ?? Infinity;
- if (teamSeats > 1 && userInfo.user?.userTeamRole?.isTeamInitiator) {
- navigate('/welcome/invite');
- } else {
- const redirectPath = sessionStorage.getItem(
- FRONTEND_USER_SETTINGS.REDIRECT_PATH_KEY_WELCOME_PAGE,
- );
- const whatAreYouBuilding = sessionStorage.getItem(
- FRONTEND_USER_SETTINGS.WHAT_ARE_YOU_BUILDING,
- );
- sessionStorage.removeItem(FRONTEND_USER_SETTINGS.REDIRECT_PATH_KEY_WELCOME_PAGE);
- sessionStorage.removeItem(FRONTEND_USER_SETTINGS.WHAT_ARE_YOU_BUILDING);
- let whatAreYouBuildingEncoded = whatAreYouBuilding?.trim?.()
- ? encodeURIComponent(whatAreYouBuilding)
- : '';
- // get redirect path from url
- const urlParams = new URLSearchParams(window.location.search);
- const redirectFromIntroCall = urlParams.get('redirectFromIntroCall');
- let urlRedirect = redirectFromIntroCall || '';
- if (redirectPath === '/' || redirectPath?.startsWith('/agents') || !redirectPath) {
- if (whatAreYouBuildingEncoded) {
- location.href = `/builder?chat=${whatAreYouBuildingEncoded}&from=onboarding`;
- } else {
- window.location.href = urlRedirect || '/agents';
- }
- } else {
- window.location.href =
- redirectPath || whatAreYouBuildingEncoded || urlRedirect || '/agents';
- }
- }
- }, [navigate, userInfo]);
-
- const handleContinueEvent = useCallback(
- async (event: MouseEvent<HTMLButtonElement>, isBooked: boolean) => {
- event.preventDefault();
- await mutateBookAnIntroCall({
- isBooked,
- email: userInfo.user?.email,
- planName: userInfo.teamSubs?.subscription?.plan?.name,
- });
- await refetch(); // Force a fresh API call after mutation
- isBooked && window.open('https://smythos.com/smythos-onboarding-call/', '_blank');
- // Explicitly call goForward after successful mutation for user actions
- goForward();
- },
- [userInfo.user, mutateBookAnIntroCall, refetch, goForward],
- );
-
- return (
- <div className="font-sans text-white w-full h-[100vh] flex gap-10 flex-col md:flex-row items-center justify-center">
- <PageCard
- progress={85}
- hasSkip={true}
- canGoBack={hasBack}
- errorMessage={error}
- closeEvent={() => {}}
- skipEvent={(event) => {
- handleContinueEvent(event, false);
- }}
- backEvent={handleBackEvent}
- BodyComponent={BookAnIntroCall}
- continueEvent={async (event) => {
- await handleContinueEvent(event, true);
- }}
- pageCardClasses="w-full"
- continueText="Schedule Call"
- skipText="Skip for now"
- actionButtonHalfWidth={true}
- />
- </div>
- );
-};
diff --git a/packages/app/src/react/features/onboarding/pages/OnboardPage.tsx b/packages/app/src/react/features/onboarding/pages/OnboardPage.tsx
deleted file mode 100644
index 2e4dfe07..00000000
--- a/packages/app/src/react/features/onboarding/pages/OnboardPage.tsx
+++ /dev/null
@@ -1,192 +0,0 @@
-// Deprecated: This file is no longer used. It was used to collect user data when they first signed up. This is now handled by /welcome flow.
-
-import { FormEvent, useCallback, useEffect, useMemo, useState } from 'react';
-
-import { useAuthCtx } from '@react/shared/contexts/auth.context';
-import { Input as CustomInput } from '@src/react/shared/components/ui/input';
-import { Button } from '@src/react/shared/components/ui/newDesign/button';
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from '@src/react/shared/components/ui/select';
-import { Spinner } from '@src/react/shared/components/ui/spinner';
-import { useMutation, useQuery } from '@tanstack/react-query';
-
-const options = [
- { label: '-- Please select --', value: 'none', disabled: true },
- { label: 'Business Owner/Executive', value: 'business' },
- { label: 'Developer/IT', value: 'dev' },
- { label: 'Marketing/Sales', value: 'sales' },
- { label: 'HR', value: 'hr' },
- { label: 'Finance', value: 'finance' },
- { label: 'Student/Other', value: 'other' },
-];
-
-type StoreDataType = {
- name: string;
- email: string;
- company?: string;
- jobtype: string;
-};
-
-export const OnboardPage = () => {
- const user = useAuthCtx();
- const { userInfo, loading } = user;
-
- const [error, setError] = useState('');
- const [companyName, setCompanyName] = useState<string>('');
- const [jobFunction, setJobFunction] = useState<string>('none');
- const [firstName, setFirstName] = useState<string>(userInfo.user?.name?.split?.(' ')?.[0] || '');
-
- const isValidJobFunction = useMemo(() => jobFunction && jobFunction !== 'none', [jobFunction]);
- // company is required if job function is not 'other'
- const isValidCompany = useMemo(
- () => isValidJobFunction && (jobFunction !== 'other' ? companyName?.length > 0 : true),
- [jobFunction, isValidJobFunction, companyName],
- );
- const hasValidValues = useMemo(
- () => firstName && isValidJobFunction && isValidCompany,
- [firstName, isValidCompany, isValidJobFunction],
- );
-
- // TODO: move this to a file
- const queryData = useQuery<any, any, StoreDataType>({
- queryKey: ['onboard/get-data'],
- queryFn: async () => {
- const response = await fetch('/api/page/onboard/get-data');
- return response.json();
- },
- refetchOnMount: false,
- refetchInterval: false,
- refetchOnReconnect: false,
- refetchOnWindowFocus: false,
- });
-
- useEffect(() => {
- setFirstName(queryData.data?.name || '');
- setCompanyName(queryData.data?.company || '');
- setJobFunction(options.find((opt) => opt.label === queryData.data?.jobtype)?.value || 'none');
- }, [queryData.data]);
-
- useEffect(() => {
- // reset error message if all fields are filled
- if (hasValidValues && error) {
- setError('');
- }
- }, [hasValidValues, setError]);
-
- // TODO: move this to a file
- const storeData = useMutation({
- mutationKey: ['onboard/store-data'],
- mutationFn: async (data: StoreDataType) => {
- const response = await fetch('/api/page/onboard/store-data', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify(data),
- });
-
- if (!response.ok) {
- throw new Error('Failed to store data');
- }
-
- return response.json();
- },
- });
-
- const onSubmit = useCallback(
- async (e: FormEvent) => {
- e.preventDefault();
-
- if (!hasValidValues) {
- setError('Please fill in all fields.');
- return;
- }
- setError('');
-
- const response = await storeData.mutateAsync({
- name: firstName,
- company: companyName,
- email: userInfo.user.email,
- jobtype: options.find((o) => o.value === jobFunction)?.label,
- });
-
- if (response.success) {
- window.location.href = '/agents';
- } else {
- setError('Something went wrong while submitting the form. Please try again.');
- }
- },
- [userInfo.user, firstName, jobFunction, companyName, setError, hasValidValues],
- );
-
- return (
- <div className="bg-gray-900 font-sans text-white fixed left-0 top-0 w-[100vw] h-[100vh] flex gap-10 flex-col md:flex-row items-center justify-center">
- <div className="px-6 space-y-8 w-full md:w-1/3">
- <img src="/img/smythos/logo-with-text-light.svg" className="h-10" alt="SmythOS logo" />
- <h1 className="text-5xl font-bold bg-gradient-to-r from-[#2feabd] to-[#33b4ff] text-transparent bg-clip-text">
- Help Us Set Up Your Account
- </h1>
- <p className="text-xl">
- Please provide us with a few more details to help tailor our services to your needs.
- </p>
- </div>
- <div className="px-6">
- {loading ? (
- <div className="flex items-center justify-center">
- <Spinner />
- </div>
- ) : (
- <form className="p-4 w-96 bg-white rounded-md space-y-4" onSubmit={onSubmit}>
- <CustomInput
- fullWidth
- value={firstName}
- label="What should we call you?"
- placeholder="Indiana Jones, Jeremy Smith"
- onChange={(event) => setFirstName(event?.target?.value)}
- />
- <div className="text-gray-700 mb-1 text-sm font-normal flex flex-col gap-1">
- <span className="text-sm">Job Function</span>
- <Select onValueChange={setJobFunction} defaultValue={jobFunction}>
- <SelectTrigger>
- <SelectValue placeholder="-- Please select --" />
- </SelectTrigger>
- <SelectContent>
- {options?.map((option) => (
- <SelectItem key={option.value} value={option.value}>
- {option.label}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- </div>
-
- {jobFunction && jobFunction !== 'other' && jobFunction !== 'none' && (
- <CustomInput
- fullWidth
- label="Company name"
- value={companyName}
- placeholder="Matrix Inc."
- onChange={(event) => setCompanyName(event?.target?.value)}
- />
- )}
- <div className="flex gap-2 flex-col justify-center items-center text-center">
- {storeData.isLoading ? (
- <Spinner />
- ) : storeData.data?.success ? (
- <p className="text-green-500">You're all set! Hold on ...</p>
- ) : (
- <Button type="submit">Continue</Button>
- )}
- <small className="text-red-500">{error}</small>
- </div>
- </form>
- )}
- </div>
- </div>
- );
-};
diff --git a/packages/app/src/react/features/onboarding/pages/WelcomePage.tsx b/packages/app/src/react/features/onboarding/pages/WelcomePage.tsx
deleted file mode 100644
index 7b83e45f..00000000
--- a/packages/app/src/react/features/onboarding/pages/WelcomePage.tsx
+++ /dev/null
@@ -1,42 +0,0 @@
-import { Spinner } from '@src/react/shared/components/ui/spinner';
-import { useAuthCtx } from '@src/react/shared/contexts/auth.context';
-import { FRONTEND_USER_SETTINGS } from '@src/react/shared/enums';
-import { sanitizeRedirectPath } from '@src/shared/utils';
-import { useEffect } from 'react';
-import { useNavigate, useSearchParams } from 'react-router-dom';
-
-export const WelcomePage = () => {
- const navigate = useNavigate();
- const [searchParams] = useSearchParams();
- const { userInfo } = useAuthCtx();
- const fiveMin = 1000 * 60 * 5; // 5 minutes
- const redirectPath = searchParams.get('redirect');
-
- useEffect(() => {
- const currentDate = new Date();
- const subsStartDate = new Date(userInfo?.subs?.startDate);
- const userCreatedDate = new Date(userInfo?.user?.createdAt);
- const isNewUser = currentDate.getTime() - userCreatedDate.getTime() < fiveMin;
- const hasRecentSubscription = currentDate.getTime() - subsStartDate.getTime() < fiveMin;
- if (redirectPath) {
- sessionStorage.setItem(
- FRONTEND_USER_SETTINGS.REDIRECT_PATH_KEY_WELCOME_PAGE,
- sanitizeRedirectPath(redirectPath),
- );
- localStorage.setItem(FRONTEND_USER_SETTINGS.SIDEBAR_COLLAPSED, 'true');
- }
- if (isNewUser && hasRecentSubscription) {
- navigate('/welcome/payment');
- } else {
- navigate('/welcome/jobtype');
- }
- }, [userInfo, navigate]);
-
- return (
- <div className="font-sans text-white w-full h-[100vh] flex gap-10 flex-col md:flex-row items-center justify-center">
- <div className="px-6 space-y-8 w-full md:w-1/3">
- <Spinner />
- </div>
- </div>
- );
-};
diff --git a/packages/app/src/react/features/onboarding/pages/WelcomePayment.tsx b/packages/app/src/react/features/onboarding/pages/WelcomePayment.tsx
deleted file mode 100644
index 6d7901e3..00000000
--- a/packages/app/src/react/features/onboarding/pages/WelcomePayment.tsx
+++ /dev/null
@@ -1,51 +0,0 @@
-import { Button } from '@src/react/shared/components/ui/newDesign/button';
-import { MouseEvent, useCallback } from 'react';
-import { useNavigate } from 'react-router-dom';
-
-export const WelcomePayment = () => {
- const navigate = useNavigate();
-
- const getQueryParams = useCallback((): URLSearchParams => {
- return new URLSearchParams(window.location.search);
- }, []);
-
- const handleGetStartedClick = useCallback(
- (event: MouseEvent<HTMLButtonElement>) => {
- const params = getQueryParams();
- const queryString = params.toString();
- navigate(`/welcome/jobtype${queryString ? `?${queryString}` : ''}`);
- },
- [navigate, getQueryParams],
- );
-
- return (
- <div className="font-sans text-white w-full h-[100vh] flex gap-10 flex-col md:flex-row items-center justify-center">
- <div className="flex flex-col gap-8 bg-white shadow-sm border border-solid border-gray-200 p-[42px] max-w-[445px] w-11/12 rounded-lg text-black">
- <header className="flex items-center justify-between">
- <div className="flex items-center justify-center flex-grow transition duration-300">
- <img src="/img/smythos/logo-with-text-dark.png" className="h-4 w-auto" alt="SmythOS" />
- </div>
- </header>
- <main className="page-card-body text-center">
- <img
- src="/img/celeb_pop.png"
- className="w-[156px] rotate-[30deg] h-auto m-auto"
- alt="SmythOS"
- />
- </main>
- <div className="flex flex-col gap-2">
- <h1 className="text-4xl font-medium text-center">Congratulations</h1>
- <p className="text-center text-sm">Thank you for joining SmythOS</p>
- </div>
- <footer className="flex w-full mt-4 h-[52px] text-base">
- <Button
- variant="primary"
- handleClick={handleGetStartedClick}
- fullWidth
- label="Get Started"
- />
- </footer>
- </div>
- </div>
- );
-};
diff --git a/packages/app/src/react/features/onboarding/pages/WelcomeTeamPage.tsx b/packages/app/src/react/features/onboarding/pages/WelcomeTeamPage.tsx
deleted file mode 100644
index 0c7f4cda..00000000
--- a/packages/app/src/react/features/onboarding/pages/WelcomeTeamPage.tsx
+++ /dev/null
@@ -1,197 +0,0 @@
-import { IUserBuildingType, IUserTeamData } from '@src/backend/types/user-data';
-import { PageCard } from '@src/react/features/onboarding/components/PageCard';
-import { ITeamPageData, TeamPageBody } from '@src/react/features/onboarding/components/TeamPageBody';
-import { useAuthCtx } from '@src/react/shared/contexts/auth.context';
-import { FRONTEND_USER_SETTINGS } from '@src/react/shared/enums';
-import { HubSpot } from '@src/shared/services/hubspot';
-import { useMutation } from '@tanstack/react-query';
-import { MouseEvent, useCallback, useEffect, useState } from 'react';
-import { useNavigate, useSearchParams } from 'react-router-dom';
-
-type TeamBuildingWorkType = {
- email: string;
- targetText: string;
-};
-
-export const WelcomeTeamPage = () => {
- const { userInfo } = useAuthCtx();
- const navigate = useNavigate();
- const [error, setError] = useState('');
- const [searchParams] = useSearchParams();
- const isChatParamPresent = searchParams.has('chat');
- const [teamBuildingData, setTeamBuildingData] = useState<IUserBuildingType | null>(null);
- const storeTeamType = useMutation({
- mutationKey: ['onboard/store-team-type'],
- mutationFn: async (data: IUserTeamData & { email: string }) => {
- const response = await fetch('/api/page/onboard/store-team-type', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify(data),
- });
-
- if (!response.ok) {
- throw new Error('Failed to store data');
- }
- return response.json();
- },
- });
-
- const storeTeamBuildingWork = useMutation({
- mutationKey: ['onboard/store-building-data'],
- mutationFn: async (data: TeamBuildingWorkType) => {
- const response = await fetch('/api/page/onboard/store-building-data', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify(data),
- });
-
- if (!response.ok) {
- throw new Error('Failed to store data');
- }
- return response.json();
- },
- });
- const getTeamBuildingData = useMutation({
- mutationKey: ['onboard/get-building-data'],
- mutationFn: async () => {
- const response = await fetch('/api/page/onboard/get-building-data', {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json',
- },
- });
-
- if (!response.ok) {
- throw new Error('Failed to get data');
- }
- return response.json();
- },
- });
-
- useEffect(() => {
- async function getBuildingData() {
- const data = await getTeamBuildingData.mutateAsync();
- setTeamBuildingData(data);
- }
- getBuildingData();
- }, []);
-
- const handleContinueEvent = useCallback(
- async (event: MouseEvent<HTMLButtonElement>, data: ITeamPageData) => {
- event.preventDefault();
-
- if (!data?.team?.value?.trim()) {
- setError('Please select a team first.');
- return;
- }
-
- setError('');
- HubSpot.identifyUser(userInfo.user?.email, {
- firstname: data.firstname,
- lastname: data.lastname,
- });
- const response = await storeTeamType.mutateAsync({
- name: `${data.firstname} ${data.lastname}`,
- firstname: data.firstname,
- lastname: data.lastname,
- email: userInfo.user?.email,
- jobtype: data.team?.category,
- jobRoleLabel: data.team?.name,
- jobRoleValue: data.team?.value,
- });
-
- if (!response.success) {
- setError('Something went wrong while saving data. Please try again.');
- return;
- }
-
- const redirectUrl = sessionStorage.getItem(
- FRONTEND_USER_SETTINGS.REDIRECT_PATH_KEY_WELCOME_PAGE,
- );
- let chatAfterRedirect = null;
-
- if (redirectUrl && decodeURIComponent(redirectUrl)?.indexOf('chat=') > -1) {
- chatAfterRedirect = decodeURIComponent(redirectUrl)?.split?.('chat=')?.[1];
- sessionStorage.removeItem(FRONTEND_USER_SETTINGS.REDIRECT_PATH_KEY_WELCOME_PAGE);
- }
-
- if (isChatParamPresent || chatAfterRedirect) {
- // if (isChatParamPresent) {
- // Analytics.track('weaver_signup', {
- // source: searchParams.get('from'),
- // page_url: '/welcome/jobtype',
- // });
- // }
-
- const response = await storeTeamBuildingWork.mutateAsync({
- targetText: isChatParamPresent ? searchParams.get('chat') : chatAfterRedirect,
- email: userInfo.user?.email,
- });
-
- if (!response.success) {
- setError('Something went wrong while saving data. Please try again.');
- return;
- }
-
- // const teamSeats = getFeatPlanLimitByKey('teamMembers', userInfo.subs);
- const teamSeats = userInfo.subs?.plan?.properties?.limits?.['teamMembers'] ?? Infinity;
- if (teamSeats > 1 && userInfo.user?.userTeamRole?.isTeamInitiator) {
- navigate('/welcome/invite');
- } else {
- window.location.href = `/builder?chat=${
- isChatParamPresent ? searchParams.get('chat') : chatAfterRedirect
- }`;
- }
- return;
- } else {
- // Analytics.track('simple_signup', {
- // page_url: '/welcome/jobtype',
- // ...(searchParams.get('source') === 'marketingSite' && searchParams.get('from')
- // ? {
- // source: searchParams.get('from'),
- // }
- // : {}),
- // });
- }
- if (teamBuildingData?.targetText) {
- // const teamSeats = getFeatPlanLimitByKey('teamMembers', userInfo.subs);
- const teamSeats = userInfo.subs?.plan?.properties?.limits?.['teamMembers'] ?? Infinity;
- if (teamSeats > 1 && userInfo.user?.userTeamRole?.isTeamInitiator) {
- navigate('/welcome/invite');
- } else {
- const redirectPath = sessionStorage.getItem(
- FRONTEND_USER_SETTINGS.REDIRECT_PATH_KEY_WELCOME_PAGE,
- );
- sessionStorage.removeItem(FRONTEND_USER_SETTINGS.REDIRECT_PATH_KEY_WELCOME_PAGE);
- window.location.href = redirectPath || '/agents';
- }
- } else {
- navigate('/welcome/work');
- }
- },
- [storeTeamType, navigate, userInfo.user],
- );
-
- return (
- <div className="font-sans text-white w-full h-[100vh] flex gap-10 flex-col md:flex-row items-center justify-center">
- <PageCard
- size="lg"
- progress={30}
- hasSkip={false}
- hasClose={false}
- canGoBack={false}
- backEvent={() => {}}
- skipEvent={() => {}}
- closeEvent={() => {}}
- errorMessage={error}
- BodyComponent={TeamPageBody}
- continueEvent={handleContinueEvent}
- extraProps={{ hideProgress: teamBuildingData?.targetText ? true : false }}
- />
- </div>
- );
-};
diff --git a/packages/app/src/react/features/onboarding/pages/WelcomeWorkPage.tsx b/packages/app/src/react/features/onboarding/pages/WelcomeWorkPage.tsx
deleted file mode 100644
index f09ad795..00000000
--- a/packages/app/src/react/features/onboarding/pages/WelcomeWorkPage.tsx
+++ /dev/null
@@ -1,133 +0,0 @@
-import { PostHog } from '@src/builder-ui/services/posthog';
-import { BuildingQuestion } from '@src/react/features/onboarding/components/BuildingQuestion';
-import { PageCard } from '@src/react/features/onboarding/components/PageCard';
-import { PAID_PLANS } from '@src/react/features/onboarding/constants';
-import { useAuthCtx } from '@src/react/shared/contexts/auth.context';
-import { FRONTEND_USER_SETTINGS, PRICING_PLANS_V4 } from '@src/react/shared/enums';
-import { FEATURE_FLAGS } from '@src/shared/constants/featureflags';
-import { useMutation } from '@tanstack/react-query';
-import { MouseEvent, useCallback, useState } from 'react';
-import { useNavigate } from 'react-router-dom';
-
-type TeamBuildingWorkType = {
- email: string;
- targetText: string;
-};
-
-export const WelcomeWorkPage = () => {
- const {
- userInfo: { subs },
- } = useAuthCtx();
- const navigate = useNavigate();
- const { userInfo } = useAuthCtx();
- const [error, setError] = useState('');
-
- const handleBackEvent = useCallback(
- (event: MouseEvent<HTMLButtonElement>) => {
- navigate('/welcome/jobtype');
- },
- [navigate],
- );
-
- const storeTeamBuildingWork = useMutation({
- mutationKey: ['onboard/store-building-data'],
- mutationFn: async (data: TeamBuildingWorkType) => {
- const response = await fetch('/api/page/onboard/store-building-data', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify(data),
- });
-
- if (!response.ok) {
- throw new Error('Failed to store data');
- }
- return response.json();
- },
- });
-
- const goForward = useCallback(() => {
- const planNameLower = subs?.plan?.name?.toLowerCase() || '';
-
- const isEnterprisePlan: boolean = PAID_PLANS.includes(planNameLower);
- const isBuilderPlan = planNameLower.indexOf(PRICING_PLANS_V4.BUILDER.toLowerCase()) !== -1;
-
- if (isEnterprisePlan) {
- navigate('/welcome/book-intro-call');
- } else if (
- isBuilderPlan &&
- PostHog.getFeatureFlag(FEATURE_FLAGS.ONBOARDING_CALLS_FOR_BUILDER_PLAN) == 'variant_1'
- ) {
- navigate('/welcome/book-intro-call');
- } else {
- // const teamSeats = getFeatPlanLimitByKey('teamMembers', userInfo.subs);
- const teamSeats = userInfo.subs?.plan?.properties?.limits?.['teamMembers'] ?? Infinity;
- if (teamSeats > 1 && userInfo.user?.userTeamRole?.isTeamInitiator) {
- navigate('/welcome/invite');
- } else {
- const redirectPath = sessionStorage.getItem(
- FRONTEND_USER_SETTINGS.REDIRECT_PATH_KEY_WELCOME_PAGE,
- );
- const whatAreYouBuilding = sessionStorage.getItem(
- FRONTEND_USER_SETTINGS.WHAT_ARE_YOU_BUILDING,
- );
- sessionStorage.removeItem(FRONTEND_USER_SETTINGS.REDIRECT_PATH_KEY_WELCOME_PAGE);
- sessionStorage.removeItem(FRONTEND_USER_SETTINGS.WHAT_ARE_YOU_BUILDING);
- let whatAreYouBuildingEncoded = whatAreYouBuilding?.trim?.()
- ? encodeURIComponent(whatAreYouBuilding)
- : '';
- if (redirectPath === '/' || redirectPath?.startsWith('/agents') || !redirectPath) {
- if (whatAreYouBuildingEncoded) {
- location.href = `/builder?chat=${whatAreYouBuildingEncoded}&from=onboarding`;
- } else {
- window.location.href = '/agents';
- }
- } else {
- window.location.href = redirectPath || whatAreYouBuildingEncoded || '/agents';
- }
- }
- }
- }, [navigate]);
-
- const handleContinueEvent = useCallback(
- async (event: MouseEvent<HTMLButtonElement>, data) => {
- event.preventDefault();
- if (data?.value?.trim()) {
- setError('');
- const dataForStore = data?.value?.trim().slice(0, 255);
- const response = await storeTeamBuildingWork.mutateAsync({
- targetText: dataForStore,
- email: userInfo.user?.email,
- });
-
- if (!response.success) {
- setError('We could not store the data. Please try again.');
- return;
- }
- sessionStorage.setItem(FRONTEND_USER_SETTINGS.WHAT_ARE_YOU_BUILDING, data?.value?.trim());
- goForward();
- } else {
- setError('Please write something');
- }
- },
- [userInfo.user, storeTeamBuildingWork, goForward],
- );
-
- return (
- <div className="font-sans text-white w-full h-[100vh] flex gap-10 flex-col md:flex-row items-center justify-center">
- <PageCard
- isBuilding
- progress={80}
- hasSkip={false}
- errorMessage={error}
- closeEvent={() => {}}
- skipEvent={() => {}}
- backEvent={handleBackEvent}
- BodyComponent={BuildingQuestion}
- continueEvent={handleContinueEvent}
- pageCardClasses="w-full"
- />
- </div>
- );
-};
diff --git a/packages/app/src/react/features/onboarding/utils/index.ts b/packages/app/src/react/features/onboarding/utils/index.ts
deleted file mode 100644
index 2011f3a2..00000000
--- a/packages/app/src/react/features/onboarding/utils/index.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export const isEmailValid = (email: string) => {
- const regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
- return regex.test(email);
-};
diff --git a/packages/app/src/react/features/teams/clients/index.ts b/packages/app/src/react/features/teams/clients/index.ts
index 711cc5ac..945c590f 100644
--- a/packages/app/src/react/features/teams/clients/index.ts
+++ b/packages/app/src/react/features/teams/clients/index.ts
@@ -1,2 +1 @@
-export * as subTeamsAPI from './subteam-api';
export * as teamAPI from './team-api';
diff --git a/packages/app/src/react/features/teams/clients/subteam-api.ts b/packages/app/src/react/features/teams/clients/subteam-api.ts
deleted file mode 100644
index 3d2987df..00000000
--- a/packages/app/src/react/features/teams/clients/subteam-api.ts
+++ /dev/null
@@ -1,95 +0,0 @@
-import { apiResultsTypes } from '@react/shared/types';
-import { authStore } from '@shared/state_stores/auth/store';
-import { TEAM_ID_HEADER } from '@src/backend/constants';
-
-export const createSubTeam = ({ name, parentTeamId }: { name: string; parentTeamId: string }) =>
- fetch('/app/page/teams/subteams', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- ...(parentTeamId && { [TEAM_ID_HEADER]: parentTeamId }),
- },
- body: JSON.stringify({ name }),
- });
-export const updateSubTeam = async (data: { id: string; name: string }) => {
- const response = await fetch(`/app/page/teams/${data.id}/name/`, {
- method: 'PUT',
- headers: { 'Content-Type': 'application/json', ...(data.id && { [TEAM_ID_HEADER]: data.id }) },
- body: JSON.stringify({ name: data.name }),
- });
-
- if (response.ok) authStore.getState().updateUserTeam(data.id, { name: data.name });
-
- return response;
-};
-export const deleteSubTeam = (data: { id: string; userId: number; parentId: string }) =>
- fetch(`/app/page/teams/subteams/${data.id}`, {
- method: 'DELETE',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify(data),
- });
-
-export const getSubTeams = async (): Promise<{ roles: apiResultsTypes.TeamRoleWithMembers[] }> => {
- const result = await fetch('/app/page/teams/me');
- return result.json();
-};
-
-interface GetTeamRolesResponse {
- roles: apiResultsTypes.TeamRoleWithMembers[];
- members: apiResultsTypes.TeamMemberWithRole[];
-}
-
-export const getTeamRoles = async (teamId: string): Promise<GetTeamRolesResponse> => {
- const result = await fetch('/app/page/teams/roles', {
- method: 'GET',
- headers: { 'Content-Type': 'application/json', ...(teamId && { [TEAM_ID_HEADER]: teamId }) },
- });
- return result.json();
-};
-
-interface GetTeamMembersResponse {
- members: apiResultsTypes.TeamMemberWithRole[];
-}
-export const getTeamMembers = async (teamId: string): Promise<GetTeamMembersResponse> => {
- const result = await fetch('/app/page/teams/members?includeRoles=true', {
- method: 'GET',
- headers: { 'Content-Type': 'application/json', ...(teamId && { [TEAM_ID_HEADER]: teamId }) },
- });
- return result.json();
-};
-
-interface DataCommon {
- teamId: string;
- memberId: string;
-}
-
-interface AssignMemberToTeamData extends DataCommon {
- roleId: string;
- notifyEmail?: boolean;
-}
-export const assignMemberToTeam = async (data: AssignMemberToTeamData) => {
- const result = await fetch(`/api/page/teams/${data.teamId}/members/assign/${data.memberId}`, {
- method: 'PUT',
- headers: {
- 'Content-Type': 'application/json',
- ...(data.teamId && { [TEAM_ID_HEADER]: data.teamId }),
- },
- body: JSON.stringify({ roleId: data.roleId, notifyEmail: data.notifyEmail || false }),
- });
- return result.json();
-};
-
-interface UnassignMemberFromTeamData extends DataCommon {
- roleId: number;
-}
-export const unassignMemberFromTeam = async (data: UnassignMemberFromTeamData) => {
- const result = await fetch(`/api/page/teams/${data.teamId}/members/unassign/${data.memberId}`, {
- method: 'DELETE',
- headers: {
- 'Content-Type': 'application/json',
- ...(data.teamId && { [TEAM_ID_HEADER]: data.teamId }),
- },
- body: JSON.stringify({ memberId: data.memberId, subteamId: data.teamId }),
- });
- return result.json();
-};
diff --git a/packages/app/src/react/features/teams/clients/team-api.ts b/packages/app/src/react/features/teams/clients/team-api.ts
index 6940f26c..4113dcbd 100644
--- a/packages/app/src/react/features/teams/clients/team-api.ts
+++ b/packages/app/src/react/features/teams/clients/team-api.ts
@@ -1,105 +1,26 @@
-import { apiPayloadTypes, apiResultsTypes } from '@react/shared/types';
+import { apiResultsTypes } from '@react/shared/types';
import { TEAM_ID_HEADER } from '@src/backend/constants';
import { TeamSubs } from '@src/react/shared/types/subscription';
-export const createTeamRole = (data: apiPayloadTypes.CreateRoleRequest) =>
- fetch('/api/page/teams/roles', {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify(data),
+export const getTeamRoles = async (
+ teamId?: string,
+): Promise<{ roles: apiResultsTypes.TeamRoleWithMembers[] }> => {
+ const result = await fetch('/app/page/teams/roles', {
+ method: 'GET',
+ headers: { 'Content-Type': 'application/json', ...(teamId && { [TEAM_ID_HEADER]: teamId }) },
});
-
-// USED
-export const getTeamRoles = async (): Promise<{ roles: apiResultsTypes.TeamRoleWithMembers[] }> => {
- const result = await fetch('/app/page/teams/roles');
- const response = await result.json();
- return { roles: response?.roles };
-};
-
-export const deleteTeamRole = (roleId: string) =>
- fetch(`/api/page/teams/roles/${roleId}`, { method: 'DELETE' });
-
-export const updateTeamRole = (data: apiPayloadTypes.UpdateRoleRequest) =>
- fetch('/api/page/teams/roles', {
- method: 'PUT',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify(data),
- });
-
-type GetTeamMembersResponse = { members: apiResultsTypes.TeamMemberWithRole[] };
-// USED
-export const getTeamMembers = async (): Promise<GetTeamMembersResponse> => {
- const result = await fetch('/app/page/teams/members?includeRoles=true');
return result.json();
};
-type GetInvitationsResponse = { members: apiResultsTypes.Invitation[] };
-export const getInvitations = async (): Promise<GetInvitationsResponse> => {
- const result = await fetch('/app/page/teams/invitations');
+type GetTeamMembersResponse = { members: apiResultsTypes.TeamMemberWithRole[] };
+export const getTeamMembers = async (teamId?: string): Promise<GetTeamMembersResponse> => {
+ const result = await fetch('/app/page/teams/members?includeRoles=true', {
+ method: 'GET',
+ headers: { 'Content-Type': 'application/json', ...(teamId && { [TEAM_ID_HEADER]: teamId }) },
+ });
return result.json();
};
-export const inviteTeamMember = (data: apiPayloadTypes.InviteTeamMemberRequest) =>
- fetch('/api/page/teams/invitations', {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify(data),
- });
-
-export const inviteTeamMemberWithSubTeam = (
- data: apiPayloadTypes.InviteTeamMemberWithSubteamRequest,
- headerTeamId?: string,
-) =>
- fetch('/app/page/teams/invitations/with-subteam', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- ...(headerTeamId && { [TEAM_ID_HEADER]: headerTeamId }),
- },
- body: JSON.stringify(data),
- });
-export const shareAgentWithTeamMember = (data: apiPayloadTypes.ShareAgentWithTeamMemberRequest) =>
- fetch('/api/page/teams/share-agent', {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify(data),
- });
-
-export const updateTeamMemberRole = (
- memberId: number,
- data: apiPayloadTypes.UpdateTeamMemberRoleRequest,
-) =>
- fetch(`/api/page/teams/members/${memberId}/role`, {
- method: 'PUT',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify(data),
- });
-
-export const leaveTeam = () =>
- fetch('/api/page/teams/me/leave', {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- });
-
-export const deleteTeamMember = (memberId: number) =>
- fetch(`/api/page/teams/members/${memberId}`, { method: 'DELETE' });
-
-export const acceptInvitation = (
- invitationId: string,
- agentId?: string,
- spaceId?: string,
- spaceRoleId?: string,
-) =>
- fetch(`/api/page/teams/invitations/${invitationId}/accept`, {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- ...(agentId && { body: JSON.stringify({ agentId }) }),
- ...(spaceId &&
- spaceRoleId && {
- body: JSON.stringify({ addToSpaceId: spaceId, addToSpaceRoleId: spaceRoleId }),
- }),
- });
-
export const getUserTeamMembers = async (teamId: string) => {
const res = await getTeamMembers();
return res.members;
diff --git a/packages/app/src/react/tsconfig.app.json b/packages/app/src/react/tsconfig.app.json
index 1860f8e8..6fb840e7 100644
--- a/packages/app/src/react/tsconfig.app.json
+++ b/packages/app/src/react/tsconfig.app.json
@@ -32,6 +32,13 @@
"noUnusedParameters": false,
"noImplicitThis": false
},
- "include": [".", "vite-env.d.ts", "index.tsx", "App.tsx", "../eslint.config.js"]
+ "include": [
+ ".",
+ "vite-env.d.ts",
+ "index.tsx",
+ "App.tsx",
+ "../eslint.config.js",
+ "../../../../../src/react/features/onboarding/constants",
+ "../../../../../src/react/features/onboarding/utils"
+ ]
}
-
\ No newline at end of file
diff --git a/packages/app/src/shared/state_stores/auth/slices/base.slice.ts b/packages/app/src/shared/state_stores/auth/slices/base.slice.ts
index 33f7e422..1195ff99 100644
--- a/packages/app/src/shared/state_stores/auth/slices/base.slice.ts
+++ b/packages/app/src/shared/state_stores/auth/slices/base.slice.ts
@@ -1,6 +1,7 @@
-import { getTeamMembers, getTeamRoles } from '@react/features/teams/clients/subteam-api';
import {
getProperTeamSubs,
+ getTeamMembers,
+ getTeamRoles,
getTeamSubs,
getUserTeamMembers,
} from '@react/features/teams/clients/team-api';
diff --git a/packages/app/tsconfig.json b/packages/app/tsconfig.json
index 77097856..92790332 100644
--- a/packages/app/tsconfig.json
+++ b/packages/app/tsconfig.json
@@ -19,6 +19,12 @@
"@shared/*": ["src/shared/*"]
}
},
- "include": ["src/**/*", "node_modules/@types", "eslint.config.js"],
+ "include": [
+ "src/**/*",
+ "node_modules/@types",
+ "eslint.config.js",
+ "../../../src/react/features/onboarding/constants",
+ "../../../src/react/features/onboarding/utils"
+ ],
"exclude": ["node_modules"]
}