fix: user infer props and remove avatarSSr from onboarding (#5549)

Co-authored-by: alannnc <alannnc@gmail.com>
pull/5850/head^2
Udit Takkar 2022-12-04 00:50:18 +05:30 committed by GitHub
parent cf077fd33c
commit a36d15894d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 13 deletions

View File

@ -4,21 +4,20 @@ import { FormEvent, useRef, useState } from "react";
import { useForm } from "react-hook-form"; import { useForm } from "react-hook-form";
import { useLocale } from "@calcom/lib/hooks/useLocale"; import { useLocale } from "@calcom/lib/hooks/useLocale";
import { User } from "@calcom/prisma/client";
import { trpc } from "@calcom/trpc/react"; import { trpc } from "@calcom/trpc/react";
import { Button, ImageUploader, showToast, TextArea } from "@calcom/ui"; import { Button, ImageUploader, showToast, TextArea } from "@calcom/ui";
import { Avatar } from "@calcom/ui";
import { AvatarSSR } from "@components/ui/AvatarSSR"; import type { IOnboardingPageProps } from "../../../pages/getting-started/[[...step]]";
interface IUserProfile {
user?: User;
}
type FormData = { type FormData = {
bio: string; bio: string;
}; };
interface IUserProfileProps {
user: IOnboardingPageProps["user"];
}
const UserProfile = (props: IUserProfile) => { const UserProfile = (props: IUserProfileProps) => {
const { user } = props; const { user } = props;
const { t } = useLocale(); const { t } = useLocale();
const avatarRef = useRef<HTMLInputElement>(null!); const avatarRef = useRef<HTMLInputElement>(null!);
@ -100,7 +99,14 @@ const UserProfile = (props: IUserProfile) => {
return ( return (
<form onSubmit={onSubmit}> <form onSubmit={onSubmit}>
<div className="flex flex-row items-center justify-start rtl:justify-end"> <div className="flex flex-row items-center justify-start rtl:justify-end">
{user && <AvatarSSR user={user} alt="Profile picture" className="h-16 w-16" />} {user && (
<Avatar
alt={user.username || "user avatar"}
gravatarFallbackMd5={user.emailMd5}
size="lg"
imageSrc={imageSrc}
/>
)}
<input <input
ref={avatarRef} ref={avatarRef}
type="hidden" type="hidden"

View File

@ -4,14 +4,15 @@ import { Controller, useForm } from "react-hook-form";
import dayjs from "@calcom/dayjs"; import dayjs from "@calcom/dayjs";
import { useLocale } from "@calcom/lib/hooks/useLocale"; import { useLocale } from "@calcom/lib/hooks/useLocale";
import { User } from "@calcom/prisma/client";
import { trpc } from "@calcom/trpc/react"; import { trpc } from "@calcom/trpc/react";
import { Button, TimezoneSelect } from "@calcom/ui"; import { Button, TimezoneSelect } from "@calcom/ui";
import { UsernameAvailability } from "@components/ui/UsernameAvailability"; import { UsernameAvailability } from "@components/ui/UsernameAvailability";
import type { IOnboardingPageProps } from "../../../pages/getting-started/[[...step]]";
interface IUserSettingsProps { interface IUserSettingsProps {
user: User; user: IOnboardingPageProps["user"];
nextStep: () => void; nextStep: () => void;
} }

View File

@ -11,15 +11,14 @@ import { User } from "@calcom/prisma/client";
import { Button, StepCard, Steps } from "@calcom/ui"; import { Button, StepCard, Steps } from "@calcom/ui";
import prisma from "@lib/prisma"; import prisma from "@lib/prisma";
import { inferSSRProps } from "@lib/types/inferSSRProps";
import { ConnectedCalendars } from "@components/getting-started/steps-views/ConnectCalendars"; import { ConnectedCalendars } from "@components/getting-started/steps-views/ConnectCalendars";
import { SetupAvailability } from "@components/getting-started/steps-views/SetupAvailability"; import { SetupAvailability } from "@components/getting-started/steps-views/SetupAvailability";
import UserProfile from "@components/getting-started/steps-views/UserProfile"; import UserProfile from "@components/getting-started/steps-views/UserProfile";
import { UserSettings } from "@components/getting-started/steps-views/UserSettings"; import { UserSettings } from "@components/getting-started/steps-views/UserSettings";
interface IOnboardingPageProps { export type IOnboardingPageProps = inferSSRProps<typeof getServerSideProps>;
user: User;
}
const INITIAL_STEP = "user-settings"; const INITIAL_STEP = "user-settings";
const steps = ["user-settings", "connected-calendar", "setup-availability", "user-profile"] as const; const steps = ["user-settings", "connected-calendar", "setup-availability", "user-profile"] as const;