## What does this PR do? - Redesigns and streamlines the onboarding flow for personal, team, and organization accounts - Consolidates shared components and improves code organization - Adds browser preview for better user experience during onboarding - Simplifies the personal onboarding flow by removing the video integration step - Enhances team onboarding with CSV upload functionality ## Visual Demo (For contributors especially) #### Image Demo: - The PR adds a new browser preview component that shows users how their profile/team will look during onboarding - Redesigned UI with a more consistent layout across all onboarding steps - Improved mobile responsiveness with better component organization ## Mandatory Tasks (DO NOT REMOVE) - [x] I have self-reviewed the code. - [x] I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox. - [x] I confirm automated tests are in place that prove my fix is effective or that my feature works. ## How should this be tested? 1. Test the complete onboarding flow for personal accounts: - Start at `/onboarding/getting-started` - Proceed through personal details and calendar setup - Verify the flow completes successfully 2. Test the team onboarding flow: - Start at `/onboarding/getting-started` and select team - Complete team details - Test the invite options including CSV upload - Verify team creation works correctly 3. Test the organization onboarding flow: - Start at `/onboarding/getting-started` and select organization - Complete organization details and branding - Test member invitations - Verify organization creation works correctly 4. Verify browser preview functionality: - Check that the preview updates in real-time as you enter information - Confirm it displays correctly on different screen sizes ## Checklist - I have read the [contributing guide](https://github.com/calcom/cal.com/blob/main/CONTRIBUTING.md) - My code follows the style guidelines of this project - I have commented my code, particularly in hard-to-understand areas - I have checked if my changes generate no new warnings
81 lines
2.2 KiB
TypeScript
81 lines
2.2 KiB
TypeScript
import { useRouter } from "next/navigation";
|
|
|
|
import { setShowWelcomeToCalcomModalFlag } from "@calcom/features/shell/hooks/useWelcomeToCalcomModal";
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import { useTelemetry } from "@calcom/lib/hooks/useTelemetry";
|
|
import { telemetryEventTypes } from "@calcom/lib/telemetry";
|
|
import { trpc } from "@calcom/trpc/react";
|
|
import { showToast } from "@calcom/ui/components/toast";
|
|
|
|
const DEFAULT_EVENT_TYPES = [
|
|
{
|
|
title: "15min_meeting",
|
|
slug: "15min",
|
|
length: 15,
|
|
},
|
|
{
|
|
title: "30min_meeting",
|
|
slug: "30min",
|
|
length: 30,
|
|
},
|
|
{
|
|
title: "secret_meeting",
|
|
slug: "secret",
|
|
length: 15,
|
|
hidden: true,
|
|
},
|
|
];
|
|
|
|
export const useSubmitPersonalOnboarding = () => {
|
|
const router = useRouter();
|
|
const { t } = useLocale();
|
|
const telemetry = useTelemetry();
|
|
const utils = trpc.useUtils();
|
|
|
|
const { data: eventTypes } = trpc.viewer.eventTypes.list.useQuery();
|
|
const createEventType = trpc.viewer.eventTypesHeavy.create.useMutation();
|
|
|
|
const mutation = trpc.viewer.me.updateProfile.useMutation({
|
|
onSuccess: async () => {
|
|
try {
|
|
// Create default event types if user has none
|
|
if (eventTypes?.length === 0) {
|
|
await Promise.all(
|
|
DEFAULT_EVENT_TYPES.map(async (event) => {
|
|
return createEventType.mutateAsync({
|
|
title: t(event.title),
|
|
slug: event.slug,
|
|
length: event.length,
|
|
hidden: event.hidden,
|
|
});
|
|
})
|
|
);
|
|
}
|
|
} catch (error) {
|
|
console.error(error);
|
|
}
|
|
|
|
await utils.viewer.me.get.refetch();
|
|
// Set flag to show welcome modal after redirect
|
|
setShowWelcomeToCalcomModalFlag();
|
|
router.push("/event-types?welcomeToCalcomModal=true");
|
|
},
|
|
onError: (error) => {
|
|
showToast(t("something_went_wrong"), "error");
|
|
console.error(error);
|
|
},
|
|
});
|
|
|
|
const submitPersonalOnboarding = () => {
|
|
telemetry.event(telemetryEventTypes.onboardingFinished);
|
|
mutation.mutate({
|
|
completedOnboarding: true,
|
|
});
|
|
};
|
|
|
|
return {
|
|
submitPersonalOnboarding,
|
|
isSubmitting: mutation.isPending,
|
|
};
|
|
};
|