2023-02-16 22:39:57 +00:00
|
|
|
import type { GetServerSidePropsContext } from "next";
|
2022-09-13 19:07:10 +00:00
|
|
|
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
|
2022-09-06 22:58:16 +00:00
|
|
|
import Head from "next/head";
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
import { z } from "zod";
|
|
|
|
|
|
|
|
import { getSession } from "@calcom/lib/auth";
|
2022-11-30 21:52:56 +00:00
|
|
|
import { APP_NAME } from "@calcom/lib/constants";
|
2022-09-06 22:58:16 +00:00
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2023-01-26 22:51:03 +00:00
|
|
|
import prisma from "@calcom/prisma";
|
2022-11-23 02:55:25 +00:00
|
|
|
import { Button, StepCard, Steps } from "@calcom/ui";
|
2022-09-06 22:58:16 +00:00
|
|
|
|
2023-02-16 22:39:57 +00:00
|
|
|
import type { inferSSRProps } from "@lib/types/inferSSRProps";
|
2022-09-06 22:58:16 +00:00
|
|
|
|
|
|
|
import { ConnectedCalendars } from "@components/getting-started/steps-views/ConnectCalendars";
|
|
|
|
import { SetupAvailability } from "@components/getting-started/steps-views/SetupAvailability";
|
|
|
|
import UserProfile from "@components/getting-started/steps-views/UserProfile";
|
|
|
|
import { UserSettings } from "@components/getting-started/steps-views/UserSettings";
|
|
|
|
|
2022-12-03 19:20:18 +00:00
|
|
|
export type IOnboardingPageProps = inferSSRProps<typeof getServerSideProps>;
|
2022-09-06 22:58:16 +00:00
|
|
|
|
|
|
|
const INITIAL_STEP = "user-settings";
|
|
|
|
const steps = ["user-settings", "connected-calendar", "setup-availability", "user-profile"] as const;
|
|
|
|
|
2023-02-16 22:39:57 +00:00
|
|
|
const stepTransform = (step: (typeof steps)[number]) => {
|
2022-09-06 22:58:16 +00:00
|
|
|
const stepIndex = steps.indexOf(step);
|
|
|
|
if (stepIndex > -1) {
|
|
|
|
return steps[stepIndex];
|
|
|
|
}
|
|
|
|
return INITIAL_STEP;
|
|
|
|
};
|
|
|
|
|
|
|
|
const stepRouteSchema = z.object({
|
|
|
|
step: z.array(z.enum(steps)).default([INITIAL_STEP]),
|
|
|
|
});
|
|
|
|
|
|
|
|
const OnboardingPage = (props: IOnboardingPageProps) => {
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
const { user } = props;
|
|
|
|
const { t } = useLocale();
|
|
|
|
|
|
|
|
const result = stepRouteSchema.safeParse(router.query);
|
|
|
|
const currentStep = result.success ? result.data.step[0] : INITIAL_STEP;
|
|
|
|
|
|
|
|
const headers = [
|
|
|
|
{
|
2022-11-30 21:52:56 +00:00
|
|
|
title: `${t("welcome_to_cal_header", { appName: APP_NAME })}`,
|
2022-09-07 01:34:33 +00:00
|
|
|
subtitle: [`${t("we_just_need_basic_info")}`, `${t("edit_form_later_subtitle")}`],
|
2022-09-06 22:58:16 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: `${t("connect_your_calendar")}`,
|
|
|
|
subtitle: [`${t("connect_your_calendar_instructions")}`],
|
2022-09-07 01:34:33 +00:00
|
|
|
skipText: `${t("connect_calendar_later")}`,
|
2022-09-06 22:58:16 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: `${t("set_availability")}`,
|
|
|
|
subtitle: [
|
|
|
|
`${t("set_availability_getting_started_subtitle_1")}`,
|
|
|
|
`${t("set_availability_getting_started_subtitle_2")}`,
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: `${t("nearly_there")}`,
|
|
|
|
subtitle: [`${t("nearly_there_instructions")}`],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const goToIndex = (index: number) => {
|
|
|
|
const newStep = steps[index];
|
|
|
|
router.push(
|
|
|
|
{
|
|
|
|
pathname: `/getting-started/${stepTransform(newStep)}`,
|
|
|
|
},
|
|
|
|
undefined
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
const currentStepIndex = steps.indexOf(currentStep);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className="dark:bg-brand dark:text-brand-contrast min-h-screen text-black"
|
|
|
|
data-testid="onboarding"
|
|
|
|
key={router.asPath}>
|
|
|
|
<Head>
|
2022-11-30 21:52:56 +00:00
|
|
|
<title>
|
|
|
|
{APP_NAME} - {t("getting_started")}
|
|
|
|
</title>
|
2022-09-06 22:58:16 +00:00
|
|
|
<link rel="icon" href="/favicon.ico" />
|
|
|
|
</Head>
|
|
|
|
|
2022-10-05 18:46:20 +00:00
|
|
|
<div className="mx-auto px-4 py-6 md:py-24">
|
2022-09-06 22:58:16 +00:00
|
|
|
<div className="relative">
|
|
|
|
<div className="sm:mx-auto sm:w-full sm:max-w-[600px]">
|
2022-09-07 01:34:33 +00:00
|
|
|
<div className="mx-auto sm:max-w-[520px]">
|
2022-09-06 22:58:16 +00:00
|
|
|
<header>
|
2022-09-07 01:34:33 +00:00
|
|
|
<p className="font-cal mb-3 text-[28px] font-medium leading-7">
|
2022-09-06 22:58:16 +00:00
|
|
|
{headers[currentStepIndex]?.title || "Undefined title"}
|
|
|
|
</p>
|
|
|
|
|
|
|
|
{headers[currentStepIndex]?.subtitle.map((subtitle, index) => (
|
2022-09-07 01:34:33 +00:00
|
|
|
<p className="font-sans text-sm font-normal text-gray-500" key={index}>
|
2022-09-06 22:58:16 +00:00
|
|
|
{subtitle}
|
|
|
|
</p>
|
|
|
|
))}
|
|
|
|
</header>
|
Admin Wizard Choose License (#6574)
* Implementation
* i18n
* More i18n
* extracted i18n, needs api to get most recent price, added hint: update later
* Fixing i18n var
* Fix booking filters not working for admin (#6576)
* fix: react-select overflow issue in some modals. (#6587)
* feat: add a disable overflow prop
* feat: use the disable overflow prop
* Tailwind Merge (#6596)
* Tailwind Merge
* Fix merge classNames
* [CAL-808] /availability/single - UI issue on buttons beside time inputs (#6561)
* [CAL-808] /availability/single - UI issue on buttons beside time inputs
* Update apps/web/public/static/locales/en/common.json
* Update packages/features/schedules/components/Schedule.tsx
* create new translation for tooltip
Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
* Bye bye submodules (#6585)
* WIP
* Uses ssh instead
* Update .gitignore
* Update .gitignore
* Update Makefile
* Update git-setup.sh
* Update git-setup.sh
* Replaced Makefile with bash script
* Update package.json
* fix: show button on empty string (#6601)
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: add delete in dropdown (#6599)
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Update README.md
* Update README.md
* Changed a neutral- classes to gray (#6603)
* Changed a neutral- classes to gray
* Changed all border-1 to border
* Update package.json
* Test fixes
* Yarn lock fixes
* Fix string equality check in git-setup.sh
* [CAL-811] Avatar icon not redirecting user back to the main page (#6586)
* Remove cursor-pointer, remove old Avatar* files
* Fixed styling for checkedSelect + some cleanup
Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
* Harsh/add member invite (#6598)
Co-authored-by: Guest <guest@pop-os.localdomain>
Co-authored-by: root <harsh.singh@gocomet.com>
* Regenerated lockfile without upgrade (#6610)
* fix: remove annoying outline when <Button /> clicked (#6537)
* fix: remove annoying outline when <Button /> clicked
* Delete yarn.lock
* remove 1 on 1 icon (#6609)
* removed 1-on-1 badge
* changed user to users for group events
* fix: case-sensitivity in apps path (#6552)
* fix: lowercase slug
* fix: make fallback blocking
* Fix FAB (#6611)
* feat: add LocationSelect component (#6571)
* feat: add LocationSelect component
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: type error
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* chore: type error
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Update booking filters design (#6543)
* Update booking filters
* Add filter on YOUR bookings
* Fix pending members showing up in list
* Reduce the avatar size to 'sm' for now
* Bugfix/dropdown menu trigger as child remove class names (#6614)
* Fix UsernameTextfield to take right height
* Remove className side-effect
* Incorrect resolution version fixed
* Converted mobile DropdownMenuTrigger styles into Button
* v2.5.3
* fix: use items-center (#6618)
* fix tooltip and modal stacking issues (#6491)
* fix tooltip and modal stacking issues
* use z-index in larger screens and less
Co-authored-by: Alex van Andel <me@alexvanandel.com>
* Temporary fix (#6626)
* Fix Ga4 tracking (#6630)
* generic <UpgradeScreen> component (#6594)
* first attempt of <UpgradeScreen>
* changes to icons
* reverted changes back to initial state, needs fix: teams not showing
* WIP
* Fix weird reactnode error
* Fix loading text
* added upgradeTip to routing forms
* icon colors
* create and use hook to check if user has team plan
* use useTeamPlan for upgradeTeamsBadge
* replace huge svg with compressed jpeg
* responsive fixes
* Update packages/ui/components/badge/UpgradeTeamsBadge.tsx
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Give team plan features to E2E tests
* Allow option to make a user part of team int ests
* Remove flash of paywall for team user
* Add team user for typeform tests as well
Co-authored-by: Peer Richelsen <peer@cal.com>
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
* Removing env var to rely on db
* Restoring i18n keys, set loading moved
* Fixing tailwind-preset glob
* Wizard width fix for md+ screens
* Converting licenses options to radix radio
* Applying feedback + other tweaks
* Reverting this, not this PR related
* Unneeded code removal
* Reverting unneeded style change
* Applying feedback
* Removing licenseType
* Upgrades typescript
* Update yarn lock
* Typings
* Hotfix: ping,riverside,whereby and around not showing up in list (#6712)
* Hotfix: ping,riverside,whereby and around not showing up in list (#6712) (#6713)
* Adds deployment settings to DB (#6706)
* WIP
* Adds DeploymentTheme
* Add missing migrations
* Adds client extensions for deployment
* Cleanup
* Delete migration.sql
* Relying on both, env var and new model
* Restoring env example doc for backward compat
* Maximum call stack size exceeded fix?
* Revert upgrade
* Update index.ts
* Delete index.ts
* Not exposing license key, fixed radio behavior
* Covering undefined env var
* Self contained checkLicense
* Feedback
* Moar feedback
* Feedback
* Feedback
* Feedback
* Cleanup
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Peer Richelsen <peer@cal.com>
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
Co-authored-by: Nafees Nazik <84864519+G3root@users.noreply.github.com>
Co-authored-by: GitStart-Cal.com <121884634+gitstart-calcom@users.noreply.github.com>
Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Omar López <zomars@me.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
Co-authored-by: Harsh Singh <51085015+harshsinghatz@users.noreply.github.com>
Co-authored-by: Guest <guest@pop-os.localdomain>
Co-authored-by: root <harsh.singh@gocomet.com>
Co-authored-by: Luis Cadillo <luiscaf3r@gmail.com>
Co-authored-by: Mohammed Cherfaoui <hi@cherfaoui.dev>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
2023-02-08 00:23:42 +00:00
|
|
|
<Steps maxSteps={steps.length} currentStep={currentStepIndex + 1} navigateToStep={goToIndex} />
|
2022-09-06 22:58:16 +00:00
|
|
|
</div>
|
|
|
|
<StepCard>
|
|
|
|
{currentStep === "user-settings" && <UserSettings user={user} nextStep={() => goToIndex(1)} />}
|
|
|
|
|
|
|
|
{currentStep === "connected-calendar" && <ConnectedCalendars nextStep={() => goToIndex(2)} />}
|
|
|
|
|
|
|
|
{currentStep === "setup-availability" && (
|
|
|
|
<SetupAvailability nextStep={() => goToIndex(3)} defaultScheduleId={user.defaultScheduleId} />
|
|
|
|
)}
|
|
|
|
|
|
|
|
{currentStep === "user-profile" && <UserProfile user={user} />}
|
|
|
|
</StepCard>
|
|
|
|
{headers[currentStepIndex]?.skipText && (
|
|
|
|
<div className="flex w-full flex-row justify-center">
|
2022-09-07 01:34:33 +00:00
|
|
|
<Button
|
2022-11-22 17:07:55 +00:00
|
|
|
color="minimal"
|
2022-09-06 22:58:16 +00:00
|
|
|
data-testid="skip-step"
|
|
|
|
onClick={(event) => {
|
|
|
|
event.preventDefault();
|
|
|
|
goToIndex(currentStepIndex + 1);
|
|
|
|
}}
|
2022-10-05 18:46:20 +00:00
|
|
|
className="mt-8 cursor-pointer px-4 py-2 font-sans text-sm font-medium">
|
2022-09-06 22:58:16 +00:00
|
|
|
{headers[currentStepIndex]?.skipText}
|
2022-09-07 01:34:33 +00:00
|
|
|
</Button>
|
2022-09-06 22:58:16 +00:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
|
|
|
const crypto = await import("crypto");
|
|
|
|
const session = await getSession(context);
|
|
|
|
|
|
|
|
if (!session?.user?.id) {
|
|
|
|
return { redirect: { permanent: false, destination: "/auth/login" } };
|
|
|
|
}
|
|
|
|
|
|
|
|
const user = await prisma.user.findUnique({
|
|
|
|
where: {
|
|
|
|
id: session.user.id,
|
|
|
|
},
|
|
|
|
select: {
|
|
|
|
id: true,
|
|
|
|
username: true,
|
|
|
|
name: true,
|
|
|
|
email: true,
|
|
|
|
bio: true,
|
|
|
|
avatar: true,
|
|
|
|
timeZone: true,
|
|
|
|
weekStart: true,
|
|
|
|
hideBranding: true,
|
|
|
|
theme: true,
|
|
|
|
brandColor: true,
|
|
|
|
darkBrandColor: true,
|
|
|
|
metadata: true,
|
|
|
|
timeFormat: true,
|
|
|
|
allowDynamicBooking: true,
|
|
|
|
defaultScheduleId: true,
|
|
|
|
completedOnboarding: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!user) {
|
|
|
|
throw new Error("User from session not found");
|
|
|
|
}
|
|
|
|
|
2023-01-12 16:17:57 +00:00
|
|
|
if (user.completedOnboarding) {
|
|
|
|
return { redirect: { permanent: false, destination: "/event-types" } };
|
|
|
|
}
|
|
|
|
|
2022-09-06 22:58:16 +00:00
|
|
|
return {
|
|
|
|
props: {
|
2022-09-13 19:07:10 +00:00
|
|
|
...(await serverSideTranslations(context.locale ?? "", ["common"])),
|
2022-09-06 22:58:16 +00:00
|
|
|
user: {
|
|
|
|
...user,
|
|
|
|
emailMd5: crypto.createHash("md5").update(user.email).digest("hex"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default OnboardingPage;
|