fix: assignee dropdown, sign in button, and onboarding flicker fix (#1242)

This commit is contained in:
Anmol Singh Bhatia 2023-06-07 17:45:57 +05:30 committed by GitHub
parent 3d5fcbd4ce
commit 78c1a64690
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 116 additions and 112 deletions

View File

@ -21,6 +21,7 @@ export const EmailCodeForm = ({ onSuccess }: any) => {
const [codeResent, setCodeResent] = useState(false); const [codeResent, setCodeResent] = useState(false);
const [isCodeResending, setIsCodeResending] = useState(false); const [isCodeResending, setIsCodeResending] = useState(false);
const [errorResendingCode, setErrorResendingCode] = useState(false); const [errorResendingCode, setErrorResendingCode] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const { setToastAlert } = useToast(); const { setToastAlert } = useToast();
const { timer: resendCodeTimer, setTimer: setResendCodeTimer } = useTimer(); const { timer: resendCodeTimer, setTimer: setResendCodeTimer } = useTimer();
@ -64,16 +65,9 @@ export const EmailCodeForm = ({ onSuccess }: any) => {
}; };
const handleSignin = async (formData: EmailCodeFormValues) => { const handleSignin = async (formData: EmailCodeFormValues) => {
await authenticationService setIsLoading(true);
.magicSignIn(formData) await authenticationService.magicSignIn(formData).catch((error) => {
.then(() => { setIsLoading(false);
setToastAlert({
title: "Success",
type: "success",
message: "Successfully logged in!",
});
})
.catch((error) => {
setToastAlert({ setToastAlert({
title: "Oops!", title: "Oops!",
type: "error", type: "error",
@ -200,9 +194,9 @@ export const EmailCodeForm = ({ onSuccess }: any) => {
size="md" size="md"
onClick={handleSubmit(handleSignin)} onClick={handleSubmit(handleSignin)}
disabled={!isValid && isDirty} disabled={!isValid && isDirty}
loading={isSubmitting} loading={isLoading}
> >
{isSubmitting ? "Signing in..." : "Sign in"} {isLoading ? "Signing in..." : "Sign in"}
</PrimaryButton> </PrimaryButton>
) : ( ) : (
<PrimaryButton <PrimaryButton

View File

@ -126,7 +126,7 @@ export const ViewAssigneeSelect: React.FC<Props> = ({
position={position} position={position}
disabled={isNotAllowed} disabled={isNotAllowed}
selfPositioned={selfPositioned} selfPositioned={selfPositioned}
dropdownWidth="w-full min-w-[8rem]" dropdownWidth="w-full min-w-[12rem]"
/> />
); );
}; };

View File

@ -22,7 +22,7 @@ import {
Workspace, Workspace,
} from "components/onboarding"; } from "components/onboarding";
// ui // ui
import { PrimaryButton } from "components/ui"; import { PrimaryButton, Spinner } from "components/ui";
// constant // constant
import { ONBOARDING_CARDS } from "constants/workspace"; import { ONBOARDING_CARDS } from "constants/workspace";
// types // types
@ -34,6 +34,7 @@ import { CURRENT_USER } from "constants/fetch-keys";
const Onboarding: NextPage = () => { const Onboarding: NextPage = () => {
const [step, setStep] = useState(1); const [step, setStep] = useState(1);
const [userRole, setUserRole] = useState<string | null>(null); const [userRole, setUserRole] = useState<string | null>(null);
const [isLoading, setIsLoading] = useState(false);
const [workspace, setWorkspace] = useState(); const [workspace, setWorkspace] = useState();
@ -44,6 +45,11 @@ const Onboarding: NextPage = () => {
return ( return (
<UserAuthorizationLayout> <UserAuthorizationLayout>
<DefaultLayout> <DefaultLayout>
{isLoading ? (
<div className="grid h-screen place-items-center">
<Spinner />
</div>
) : (
<div className="relative grid h-full place-items-center p-5"> <div className="relative grid h-full place-items-center p-5">
{step <= 3 ? ( {step <= 3 ? (
<div className="h-full flex flex-col justify-center w-full py-4"> <div className="h-full flex flex-col justify-center w-full py-4">
@ -79,6 +85,7 @@ const Onboarding: NextPage = () => {
size="md" size="md"
onClick={() => { onClick={() => {
if (step === 8) { if (step === 8) {
setIsLoading(true);
userService userService
.updateUserOnBoard({ userRole }, user) .updateUserOnBoard({ userRole }, user)
.then(async () => { .then(async () => {
@ -118,7 +125,8 @@ const Onboarding: NextPage = () => {
Router.push(`/${lastActiveWorkspace.slug}`); Router.push(`/${lastActiveWorkspace.slug}`);
return; return;
} else { } else {
const invitations = await workspaceService.userWorkspaceInvitations(); const invitations =
await workspaceService.userWorkspaceInvitations();
if (invitations.length > 0) { if (invitations.length > 0) {
Router.push(`/invitations`); Router.push(`/invitations`);
return; return;
@ -129,6 +137,7 @@ const Onboarding: NextPage = () => {
} }
}) })
.catch((err) => { .catch((err) => {
setIsLoading(false);
console.log(err); console.log(err);
}); });
} else setStep((prevData) => prevData + 1); } else setStep((prevData) => prevData + 1);
@ -145,6 +154,7 @@ const Onboarding: NextPage = () => {
<span className="text-sm text-brand-base">{user?.email}</span> <span className="text-sm text-brand-base">{user?.email}</span>
</div> </div>
</div> </div>
)}
</DefaultLayout> </DefaultLayout>
</UserAuthorizationLayout> </UserAuthorizationLayout>
); );