feat: enhance onboarding steps with loading state and button component (#20350)
- Added loading state to ConnectedCalendars and ConnectedVideoStep components. - Replaced native button elements with a custom Button component for consistency. - Updated SetupAvailability to use async mutation methods. - Integrated loading state into the onboarding view for smoother transitions between steps.
This commit is contained in:
1 parent
0772e1d168
commit
ecd85cd15a
4 files changed
+27
-18
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||||
import { trpc } from "@calcom/trpc/react";
|
import { trpc } from "@calcom/trpc/react";
|
||||||
import classNames from "@calcom/ui/classNames";
|
import classNames from "@calcom/ui/classNames";
|
||||||
import { Icon } from "@calcom/ui/components/icon";
|
import { Button } from "@calcom/ui/components/button";
|
||||||
import { List } from "@calcom/ui/components/list";
|
import { List } from "@calcom/ui/components/list";
|
||||||
|
|
||||||
import { AppConnectionItem } from "../components/AppConnectionItem";
|
import { AppConnectionItem } from "../components/AppConnectionItem";
|
||||||
@@ -11,10 +11,11 @@ import { StepConnectionLoader } from "../components/StepConnectionLoader";
|
|||||||
|
|
||||||
interface IConnectCalendarsProps {
|
interface IConnectCalendarsProps {
|
||||||
nextStep: () => void;
|
nextStep: () => void;
|
||||||
|
isPageLoading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ConnectedCalendars = (props: IConnectCalendarsProps) => {
|
const ConnectedCalendars = (props: IConnectCalendarsProps) => {
|
||||||
const { nextStep } = props;
|
const { nextStep, isPageLoading } = props;
|
||||||
const queryConnectedCalendars = trpc.viewer.connectedCalendars.useQuery({
|
const queryConnectedCalendars = trpc.viewer.connectedCalendars.useQuery({
|
||||||
onboarding: true,
|
onboarding: true,
|
||||||
eventTypeId: null,
|
eventTypeId: null,
|
||||||
@@ -81,18 +82,18 @@ const ConnectedCalendars = (props: IConnectCalendarsProps) => {
|
|||||||
|
|
||||||
{queryIntegrations.isPending && <StepConnectionLoader />}
|
{queryIntegrations.isPending && <StepConnectionLoader />}
|
||||||
|
|
||||||
<button
|
<Button
|
||||||
type="button"
|
EndIcon="arrow-right"
|
||||||
data-testid="save-calendar-button"
|
data-testid="save-calendar-button"
|
||||||
className={classNames(
|
className={classNames(
|
||||||
"text-inverted bg-inverted border-inverted mt-8 flex w-full flex-row justify-center rounded-md border p-2 text-center text-sm",
|
"text-inverted bg-inverted border-inverted mt-8 flex w-full flex-row justify-center rounded-md border p-2 text-center text-sm",
|
||||||
disabledNextButton ? "cursor-not-allowed opacity-20" : ""
|
disabledNextButton ? "cursor-not-allowed opacity-20" : ""
|
||||||
)}
|
)}
|
||||||
|
loading={isPageLoading}
|
||||||
onClick={() => nextStep()}
|
onClick={() => nextStep()}
|
||||||
disabled={disabledNextButton}>
|
disabled={disabledNextButton}>
|
||||||
{firstCalendar ? `${t("continue")}` : `${t("next_step_text")}`}
|
{firstCalendar ? `${t("continue")}` : `${t("next_step_text")}`}
|
||||||
<Icon name="arrow-right" className="ml-2 h-4 w-4 self-center" aria-hidden="true" />
|
</Button>
|
||||||
</button>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { userMetadata } from "@calcom/prisma/zod-utils";
|
|||||||
import { trpc } from "@calcom/trpc/react";
|
import { trpc } from "@calcom/trpc/react";
|
||||||
import useMeQuery from "@calcom/trpc/react/hooks/useMeQuery";
|
import useMeQuery from "@calcom/trpc/react/hooks/useMeQuery";
|
||||||
import classNames from "@calcom/ui/classNames";
|
import classNames from "@calcom/ui/classNames";
|
||||||
import { Icon } from "@calcom/ui/components/icon";
|
import { Button } from "@calcom/ui/components/button";
|
||||||
import { List } from "@calcom/ui/components/list";
|
import { List } from "@calcom/ui/components/list";
|
||||||
|
|
||||||
import { AppConnectionItem } from "../components/AppConnectionItem";
|
import { AppConnectionItem } from "../components/AppConnectionItem";
|
||||||
@@ -11,10 +11,11 @@ import { StepConnectionLoader } from "../components/StepConnectionLoader";
|
|||||||
|
|
||||||
interface ConnectedAppStepProps {
|
interface ConnectedAppStepProps {
|
||||||
nextStep: () => void;
|
nextStep: () => void;
|
||||||
|
isPageLoading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ConnectedVideoStep = (props: ConnectedAppStepProps) => {
|
const ConnectedVideoStep = (props: ConnectedAppStepProps) => {
|
||||||
const { nextStep } = props;
|
const { nextStep, isPageLoading } = props;
|
||||||
const { data: queryConnectedVideoApps, isPending } = trpc.viewer.apps.integrations.useQuery({
|
const { data: queryConnectedVideoApps, isPending } = trpc.viewer.apps.integrations.useQuery({
|
||||||
variant: "conferencing",
|
variant: "conferencing",
|
||||||
onlyInstalled: false,
|
onlyInstalled: false,
|
||||||
@@ -70,18 +71,18 @@ const ConnectedVideoStep = (props: ConnectedAppStepProps) => {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{isPending && <StepConnectionLoader />}
|
{isPending && <StepConnectionLoader />}
|
||||||
<button
|
<Button
|
||||||
type="button"
|
EndIcon="arrow-right"
|
||||||
data-testid="save-video-button"
|
data-testid="save-video-button"
|
||||||
className={classNames(
|
className={classNames(
|
||||||
"text-inverted border-inverted bg-inverted mt-8 flex w-full flex-row justify-center rounded-md border p-2 text-center text-sm",
|
"text-inverted border-inverted bg-inverted mt-8 flex w-full flex-row justify-center rounded-md border p-2 text-center text-sm",
|
||||||
!hasAnyInstalledVideoApps ? "cursor-not-allowed opacity-20" : ""
|
!hasAnyInstalledVideoApps ? "cursor-not-allowed opacity-20" : ""
|
||||||
)}
|
)}
|
||||||
disabled={!hasAnyInstalledVideoApps}
|
disabled={!hasAnyInstalledVideoApps}
|
||||||
|
loading={isPageLoading}
|
||||||
onClick={() => nextStep()}>
|
onClick={() => nextStep()}>
|
||||||
{t("next_step_text")}
|
{t("next_step_text")}
|
||||||
<Icon name="arrow-right" className="ml-2 h-4 w-4 self-center" aria-hidden="true" />
|
</Button>
|
||||||
</button>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -51,13 +51,13 @@ const SetupAvailability = (props: ISetupAvailabilityProps) => {
|
|||||||
handleSubmit={async (values) => {
|
handleSubmit={async (values) => {
|
||||||
try {
|
try {
|
||||||
if (defaultScheduleId) {
|
if (defaultScheduleId) {
|
||||||
await updateSchedule.mutate({
|
await updateSchedule.mutateAsync({
|
||||||
scheduleId: defaultScheduleId,
|
scheduleId: defaultScheduleId,
|
||||||
name: t("default_schedule_name"),
|
name: t("default_schedule_name"),
|
||||||
...values,
|
...values,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await createSchedule.mutate({
|
await createSchedule.mutateAsync({
|
||||||
name: t("default_schedule_name"),
|
name: t("default_schedule_name"),
|
||||||
...values,
|
...values,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import type { TFunction } from "i18next";
|
import type { TFunction } from "i18next";
|
||||||
import { signOut } from "next-auth/react";
|
import { signOut } from "next-auth/react";
|
||||||
import { usePathname, useRouter } from "next/navigation";
|
import { usePathname, useRouter } from "next/navigation";
|
||||||
import { Suspense } from "react";
|
import { Suspense, useTransition } from "react";
|
||||||
import { Toaster } from "sonner";
|
import { Toaster } from "sonner";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
@@ -93,6 +93,7 @@ const OnboardingPage = (props: PageProps) => {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [user] = trpc.viewer.me.get.useSuspenseQuery();
|
const [user] = trpc.viewer.me.get.useSuspenseQuery();
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
|
const [isNextStepLoading, startTransition] = useTransition();
|
||||||
|
|
||||||
const result = stepRouteSchema.safeParse({
|
const result = stepRouteSchema.safeParse({
|
||||||
...params,
|
...params,
|
||||||
@@ -126,7 +127,9 @@ const OnboardingPage = (props: PageProps) => {
|
|||||||
const goToNextStep = () => {
|
const goToNextStep = () => {
|
||||||
const nextIndex = currentStepIndex + 1;
|
const nextIndex = currentStepIndex + 1;
|
||||||
const newStep = steps[nextIndex];
|
const newStep = steps[nextIndex];
|
||||||
router.push(`/getting-started/${stepTransform(newStep)}`);
|
startTransition(() => {
|
||||||
|
router.push(`/getting-started/${stepTransform(newStep)}`);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -161,9 +164,13 @@ const OnboardingPage = (props: PageProps) => {
|
|||||||
{currentStep === "user-settings" && (
|
{currentStep === "user-settings" && (
|
||||||
<UserSettings nextStep={goToNextStep} hideUsername={from === "signup"} />
|
<UserSettings nextStep={goToNextStep} hideUsername={from === "signup"} />
|
||||||
)}
|
)}
|
||||||
{currentStep === "connected-calendar" && <ConnectedCalendars nextStep={goToNextStep} />}
|
{currentStep === "connected-calendar" && (
|
||||||
|
<ConnectedCalendars nextStep={goToNextStep} isPageLoading={isNextStepLoading} />
|
||||||
|
)}
|
||||||
|
|
||||||
{currentStep === "connected-video" && <ConnectedVideoStep nextStep={goToNextStep} />}
|
{currentStep === "connected-video" && (
|
||||||
|
<ConnectedVideoStep nextStep={goToNextStep} isPageLoading={isNextStepLoading} />
|
||||||
|
)}
|
||||||
|
|
||||||
{currentStep === "setup-availability" && (
|
{currentStep === "setup-availability" && (
|
||||||
<SetupAvailability nextStep={goToNextStep} defaultScheduleId={user.defaultScheduleId} />
|
<SetupAvailability nextStep={goToNextStep} defaultScheduleId={user.defaultScheduleId} />
|
||||||
|
|||||||
Reference in new issue
Block a user