From f3bedabf92f1e6dffea136441a299f9143efc2b8 Mon Sep 17 00:00:00 2001 From: alannnc Date: Tue, 6 Sep 2022 19:34:33 -0600 Subject: [PATCH] Fix/styles getting started v2 (#4224) * Fixes spacings style * Fix spacings * Update test * Fix router push when image upload is success, also typo * Fix styles for mobile * Sumodule sync Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: zomars --- .../components/CalendarSwitch.tsx | 13 +++-- .../components/ConnectedCalendarItem.tsx | 29 ++++++---- .../getting-started/components/StepCard.tsx | 2 +- .../getting-started/components/Steps.tsx | 6 +- .../steps-views/ConnectCalendars.tsx | 2 +- .../steps-views/SetupAvailability.tsx | 2 +- .../steps-views/UserProfile.tsx | 55 ++++++++++++------- .../steps-views/UserSettings.tsx | 6 +- apps/web/pages/event-types/[type].tsx | 2 +- .../web/pages/getting-started/[[...step]].tsx | 23 ++++---- apps/web/playwright/onboarding.e2e.ts | 10 ++-- apps/web/public/static/locales/en/common.json | 19 ++++--- .../schedules/components/Schedule.tsx | 2 +- 13 files changed, 99 insertions(+), 72 deletions(-) diff --git a/apps/web/components/getting-started/components/CalendarSwitch.tsx b/apps/web/components/getting-started/components/CalendarSwitch.tsx index 04aa303e01..f7424229ef 100644 --- a/apps/web/components/getting-started/components/CalendarSwitch.tsx +++ b/apps/web/components/getting-started/components/CalendarSwitch.tsx @@ -4,15 +4,18 @@ import showToast from "@calcom/lib/notification"; import { trpc } from "@calcom/trpc/react"; import { Switch } from "@calcom/ui/v2"; +import classNames from "@lib/classNames"; + interface ICalendarSwitchProps { title: string; externalId: string; type: string; isChecked: boolean; name: string; + isLastItemInList?: boolean; } const CalendarSwitch = (props: ICalendarSwitchProps) => { - const { title, externalId, type, isChecked, name } = props; + const { title, externalId, type, isChecked, name, isLastItemInList = false } = props; const utils = trpc.useContext(); const mutation = useMutation< unknown, @@ -21,7 +24,7 @@ const CalendarSwitch = (props: ICalendarSwitchProps) => { isOn: boolean; } >( - async ({ isOn }) => { + async ({ isOn }: { isOn: boolean }) => { const body = { integration: type, externalId: externalId, @@ -63,8 +66,8 @@ const CalendarSwitch = (props: ICalendarSwitchProps) => { } ); return ( -
-
+
+
{ }} />
-
diff --git a/apps/web/components/getting-started/components/ConnectedCalendarItem.tsx b/apps/web/components/getting-started/components/ConnectedCalendarItem.tsx index 059844e992..68ce96ca7f 100644 --- a/apps/web/components/getting-started/components/ConnectedCalendarItem.tsx +++ b/apps/web/components/getting-started/components/ConnectedCalendarItem.tsx @@ -1,6 +1,7 @@ import { DotsHorizontalIcon } from "@heroicons/react/solid"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { Button } from "@calcom/ui/v2"; import { CalendarSwitch } from "./CalendarSwitch"; @@ -27,31 +28,34 @@ const ConnectedCalendarItem = (prop: IConnectedCalendarItem) => { return ( <>
- {name} + {name}
-

{name}

+

+ {name}{" "} + + {t("default")} + +

+ className="max-w-44 mt-1 overflow-hidden text-ellipsis whitespace-nowrap font-sans text-sm text-gray-500"> {externalId}{" "} - - {t("default")} -
- + className="ml-auto flex rounded-md border border-gray-200 py-[10x] px-4 font-sans text-sm"> + {t("edit")} +
-
    - {calendars?.map((calendar) => ( +
      + {calendars?.map((calendar, i) => ( { name={calendar.name || "Nameless Calendar"} type={integrationType} isChecked={calendar.isSelected} + isLastItemInList={i === calendars.length - 1} /> ))}
    diff --git a/apps/web/components/getting-started/components/StepCard.tsx b/apps/web/components/getting-started/components/StepCard.tsx index 42fe2efc33..de5904cf17 100644 --- a/apps/web/components/getting-started/components/StepCard.tsx +++ b/apps/web/components/getting-started/components/StepCard.tsx @@ -1,6 +1,6 @@ const StepCard: React.FC<{ children: React.ReactNode }> = (props) => { return ( -
    +
    {props.children}
    ); diff --git a/apps/web/components/getting-started/components/Steps.tsx b/apps/web/components/getting-started/components/Steps.tsx index 084bc54152..fa1691b123 100644 --- a/apps/web/components/getting-started/components/Steps.tsx +++ b/apps/web/components/getting-started/components/Steps.tsx @@ -11,7 +11,7 @@ const Steps = (props: ISteps) => { const { maxSteps, currentStep, navigateToStep } = props; const { t } = useLocale(); return ( -
    +

    {t("current_step_of_total", { currentStep: currentStep + 1, maxSteps })}

    @@ -22,12 +22,12 @@ const Steps = (props: ISteps) => { key={`step-${index}`} onClick={() => navigateToStep(index)} className={classNames( - "h-1 w-1/4 bg-black dark:bg-white", + "h-1 w-1/4 rounded-[1px] bg-black dark:bg-white", index < currentStep ? "cursor-pointer" : "" )} /> ) : ( -
    +
    ); })}
    diff --git a/apps/web/components/getting-started/steps-views/ConnectCalendars.tsx b/apps/web/components/getting-started/steps-views/ConnectCalendars.tsx index 6164624959..b9d56ce548 100644 --- a/apps/web/components/getting-started/steps-views/ConnectCalendars.tsx +++ b/apps/web/components/getting-started/steps-views/ConnectCalendars.tsx @@ -58,7 +58,7 @@ const ConnectedCalendars = (props: IConnectCalendarsProps) => { {/* Connect calendars list */} {firstCalendar === undefined && queryIntegrations.data && queryIntegrations.data.items.length > 0 && ( - + {queryIntegrations.data && queryIntegrations.data.items.map((item) => (
  • diff --git a/apps/web/components/getting-started/steps-views/SetupAvailability.tsx b/apps/web/components/getting-started/steps-views/SetupAvailability.tsx index dede287c49..4d22a3e74d 100644 --- a/apps/web/components/getting-started/steps-views/SetupAvailability.tsx +++ b/apps/web/components/getting-started/steps-views/SetupAvailability.tsx @@ -81,7 +81,7 @@ const SetupAvailability = (props: ISetupAvailabilityProps) => { diff --git a/apps/web/components/getting-started/steps-views/UserProfile.tsx b/apps/web/components/getting-started/steps-views/UserProfile.tsx index adcf5fb62a..e7725e9da2 100644 --- a/apps/web/components/getting-started/steps-views/UserProfile.tsx +++ b/apps/web/components/getting-started/steps-views/UserProfile.tsx @@ -6,7 +6,7 @@ import { useForm } from "react-hook-form"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { User } from "@calcom/prisma/client"; import { trpc } from "@calcom/trpc/react"; -import { Button, Input } from "@calcom/ui/v2"; +import { Button, showToast, TextArea } from "@calcom/ui/v2"; import { AvatarSSR } from "@components/ui/AvatarSSR"; import ImageUploader from "@components/v2/settings/ImageUploader"; @@ -35,26 +35,39 @@ const UserProfile = (props: IUserProfile) => { const utils = trpc.useContext(); const router = useRouter(); const createEventType = trpc.useMutation("viewer.eventTypes.create"); - const onSuccess = async () => { - try { - if (eventTypes?.length === 0) { - await Promise.all( - DEFAULT_EVENT_TYPES.map(async (event) => { - return createEventType.mutate(event); - }) - ); - } - } catch (error) { - console.error(error); - } - await utils.refetchQueries(["viewer.me"]); - router.push("/"); + const onSuccess = async ( + _data: string | undefined, + context: Partial<{ bio: string; completedOnboarding: boolean; avatar: string }> + ) => { + if (context.avatar) { + showToast(t("your_user_profile_updated_successfully"), "success"); + await utils.refetchQueries(["viewer.me"]); + } else { + try { + if (eventTypes?.length === 0) { + await Promise.all( + DEFAULT_EVENT_TYPES.map(async (event) => { + return createEventType.mutate(event); + }) + ); + } + } catch (error) { + console.error(error); + } + + await utils.refetchQueries(["viewer.me"]); + router.push("/"); + } + }; + const onError = () => { + showToast(t("problem_saving_user_profile"), "error"); }; const mutation = trpc.useMutation("viewer.updateProfile", { - onSuccess: onSuccess, + onSuccess, + onError, }); - const onSubmit = handleSubmit((data) => { + const onSubmit = handleSubmit((data: { bio: string }) => { const { bio } = data; mutation.mutate({ @@ -91,7 +104,7 @@ const UserProfile = (props: IUserProfile) => { ]; return ( -
    +

    {t("profile_picture")}

    {user && } @@ -129,13 +142,13 @@ const UserProfile = (props: IUserProfile) => { - { setValue("bio", event.target.value); @@ -146,7 +159,7 @@ const UserProfile = (props: IUserProfile) => { {t("required")}

    )} -

    +

    {t("few_sentences_about_yourself")}

    diff --git a/apps/web/components/getting-started/steps-views/UserSettings.tsx b/apps/web/components/getting-started/steps-views/UserSettings.tsx index 1f6ec0f62d..ecdec06eb8 100644 --- a/apps/web/components/getting-started/steps-views/UserSettings.tsx +++ b/apps/web/components/getting-started/steps-views/UserSettings.tsx @@ -53,7 +53,7 @@ const UserSettings = (props: IUserSettingsProps) => { return ( -
    +
    {/* Username textfield */} { className="mt-2 w-full rounded-md text-sm" /> -

    - {t("current_time")} {dayjs().tz(selectedTimeZone).format("LT").toString()} +

    + {t("current_time")} {dayjs().tz(selectedTimeZone).format("LT").toString().toLowerCase()}

    diff --git a/apps/web/pages/event-types/[type].tsx b/apps/web/pages/event-types/[type].tsx index d00cffb574..c746896971 100644 --- a/apps/web/pages/event-types/[type].tsx +++ b/apps/web/pages/event-types/[type].tsx @@ -276,7 +276,7 @@ const EventTypePage = (props: inferSSRProps) => { if (message) { showToast(message, "error"); } - showToast("Some error occured", "error"); + showToast("Some error occurred", "error"); }, }); diff --git a/apps/web/pages/getting-started/[[...step]].tsx b/apps/web/pages/getting-started/[[...step]].tsx index f6aeff986b..08bd211b0d 100644 --- a/apps/web/pages/getting-started/[[...step]].tsx +++ b/apps/web/pages/getting-started/[[...step]].tsx @@ -6,6 +6,7 @@ import { z } from "zod"; import { getSession } from "@calcom/lib/auth"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { User } from "@calcom/prisma/client"; +import { Button } from "@calcom/ui/v2"; import prisma from "@lib/prisma"; @@ -46,14 +47,13 @@ const OnboardingPage = (props: IOnboardingPageProps) => { const headers = [ { - title: `${t("welcome_to_calcom")}!`, - subtitle: [`${t("we_just_need_basic_info")}`], - skipText: `${t("skip")}`, + title: `${t("welcome_to_cal_header")}`, + subtitle: [`${t("we_just_need_basic_info")}`, `${t("edit_form_later_subtitle")}`], }, { title: `${t("connect_your_calendar")}`, subtitle: [`${t("connect_your_calendar_instructions")}`], - skipText: `${t("do_this_later")}`, + skipText: `${t("connect_calendar_later")}`, }, { title: `${t("set_availability")}`, @@ -61,7 +61,7 @@ const OnboardingPage = (props: IOnboardingPageProps) => { `${t("set_availability_getting_started_subtitle_1")}`, `${t("set_availability_getting_started_subtitle_2")}`, ], - skipText: `${t("do_this_later")}`, + skipText: `${t("set_my_availability_later")}`, }, { title: `${t("nearly_there")}`, @@ -94,14 +94,14 @@ const OnboardingPage = (props: IOnboardingPageProps) => {
    -
    +
    -

    +

    {headers[currentStepIndex]?.title || "Undefined title"}

    {headers[currentStepIndex]?.subtitle.map((subtitle, index) => ( -

    +

    {subtitle}

    ))} @@ -121,15 +121,16 @@ const OnboardingPage = (props: IOnboardingPageProps) => { {headers[currentStepIndex]?.skipText && ( )}
    diff --git a/apps/web/playwright/onboarding.e2e.ts b/apps/web/playwright/onboarding.e2e.ts index e136a08a4f..29e5021c3e 100644 --- a/apps/web/playwright/onboarding.e2e.ts +++ b/apps/web/playwright/onboarding.e2e.ts @@ -13,7 +13,7 @@ test.describe("Onboarding", () => { await page.goto("/getting-started"); // First step - await page.waitForSelector("text=Welcome to Cal.com"); + const usernameInput = await page.locator("input[name=username]"); await usernameInput.fill("new user onboarding"); @@ -45,7 +45,7 @@ test.describe("Onboarding", () => { const isDisabled = await nextButtonCalendar.isDisabled(); await expect(isDisabled).toBe(true); - const skipStepButton = await page.locator("a[data-testid=skip-step]"); + const skipStepButton = await page.locator("button[data-testid=skip-step]"); await skipStepButton.click(); await expect(page).toHaveURL(/.*setup-availability/); // @TODO: make sure calendar UL list has at least 1 item @@ -62,7 +62,7 @@ test.describe("Onboarding", () => { const isDisabled = await nextButtonAvailability.isDisabled(); await expect(isDisabled).toBe(false); - const skipStepButton = await page.locator("a[data-testid=skip-step]"); + const skipStepButton = await page.locator("button[data-testid=skip-step]"); await skipStepButton.click(); await expect(page).toHaveURL(/.*user-profile/); }); @@ -75,7 +75,7 @@ test.describe("Onboarding", () => { // Fourth step const finishButton = await page.locator("button[type=submit]"); - const bioInput = await page.locator("input[name=bio]"); + const bioInput = await page.locator("textarea[name=bio]"); await bioInput.fill("Something about me"); const isDisabled = await finishButton.isDisabled(); await expect(isDisabled).toBe(false); @@ -118,7 +118,7 @@ test.describe("Onboarding", () => { await page.goto("/getting-started/user-profile"); // Fourth step - await page.waitForSelector("text=Nearly there!"); + const finishButton = await page.locator("button[type=submit]"); await finishButton.click(); diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json index 3e20fbaaff..52bc0f30ca 100644 --- a/apps/web/public/static/locales/en/common.json +++ b/apps/web/public/static/locales/en/common.json @@ -1153,12 +1153,12 @@ "email_subject": "Email subject", "add_dynamic_variables": "Add dynamic text variables", "event_name_info": "The event type name", - "event_date_info":"The event date", - "event_time_info":"The event start time", - "location_info":"The event location", - "organizer_name_info":"Your name", - "additional_notes_info":"The Additional notes of booking", - "attendee_name_info":"The person booking's name", + "event_date_info": "The event date", + "event_time_info": "The event start time", + "location_info": "The event location", + "organizer_name_info": "Your name", + "additional_notes_info": "The Additional notes of booking", + "attendee_name_info": "The person booking's name", "to": "To", "attendee_required_enter_number": "This will require the attendee to enter a phone number when booking", "workflow_turned_on_successfully": "{{workflowName}} workflow turned {{offOn}} successfully", @@ -1173,5 +1173,10 @@ "workflow_example_3": "Send custom email when event is cancelled to host", "workflow_example_4": "Send email reminder 24 hours before event starts to attendee", "workflow_example_5": "Send SMS reminder 1 hour before event starts to attendee", - "workflow_example_6": "Send custom SMS when event is rescheduled to attendee" + "workflow_example_6": "Send custom SMS when event is rescheduled to attendee", + "welcome_to_cal_header": "Welcome to Cal.com!", + "edit_form_later_subtitle": "You’ll be able to edit this later.", + "connect_calendar_later": "I'll connect my calendar later", + "set_my_availability_later": "I'll set my availability later", + "problem_saving_user_profile": "There was a problem saving your data. Please try again or reach out to customer support." } diff --git a/packages/features/schedules/components/Schedule.tsx b/packages/features/schedules/components/Schedule.tsx index 739aac7624..f273ca24b6 100644 --- a/packages/features/schedules/components/Schedule.tsx +++ b/packages/features/schedules/components/Schedule.tsx @@ -91,7 +91,7 @@ const DayRanges = ({ return ( <> {fields.map((field: { id: string }, index: number) => ( -
    +
    {index === 0 && (