mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
9075f9441c
* style: added cta at the bottom of sidebar, added missing icons as well, showing dynamic workspace member count on workspace dropdown * refractor: running parallel request, made create/edit label function to async function * fix: sidebar dropdown content going below kanban items outside click detection in need help dropdown * refractor: making parallel api calls fix: create state input comes at bottom, create state input gets on focus automatically, form is getting submitted on enter click * refactoring file structure and signin page * style: changed text and added spinner for signing in loading * refractor: removed unused type * fix: my issue cta in profile page sending to 404 page * fix: added new s3 bucket url in next.config.js file increased image modal height * packaging UI components * eslint config * eslint fixes * refactoring changes * build fixes * minor fixes * adding todo comments for reference * refactor: cleared unused imports and re ordered imports * refactor: removed unused imports * fix: added workspace argument to useissues hook * refactor: removed api-routes file, unnecessary constants * refactor: created helpers folder, removed unnecessary constants * refactor: new context for issue view * refactoring issues page * build fixes * refactoring * refactor: create issue modal * refactor: module ui * fix: sub-issues mutation * fix: create more option in create issue modal * description form debounce issue * refactor: global component for assignees list * fix: link module interface * fix: priority icons and sub-issues count added * fix: cycle mutation in issue details page * fix: remove issue from cycle mutation * fix: create issue modal in home page * fix: removed unnecessary props * fix: updated create issue form status * fix: settings auth breaking * refactor: issue details page Co-authored-by: Dakshesh Jain <dakshesh.jain14@gmail.com> Co-authored-by: Dakshesh Jain <65905942+dakshesh14@users.noreply.github.com> Co-authored-by: venkatesh-soulpage <venkatesh.marreboyina@soulpageit.com> Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com> Co-authored-by: Anmol Singh Bhatia <anmolsinghbhatia1001@gmail.com>
129 lines
3.4 KiB
TypeScript
129 lines
3.4 KiB
TypeScript
import React, { useState } from "react";
|
|
import { useForm } from "react-hook-form";
|
|
// ui
|
|
import { CheckCircleIcon } from "@heroicons/react/20/solid";
|
|
import { Button, Input } from "components/ui";
|
|
// services
|
|
import authenticationService from "services/authentication.service";
|
|
// icons
|
|
|
|
// types
|
|
type EmailCodeFormValues = {
|
|
email: string;
|
|
key?: string;
|
|
token?: string;
|
|
};
|
|
|
|
export const EmailCodeForm = ({ onSuccess }: any) => {
|
|
const [codeSent, setCodeSent] = useState(false);
|
|
const {
|
|
register,
|
|
handleSubmit,
|
|
setError,
|
|
setValue,
|
|
formState: { errors, isSubmitting, isValid, isDirty },
|
|
} = useForm<EmailCodeFormValues>({
|
|
defaultValues: {
|
|
email: "",
|
|
key: "",
|
|
token: "",
|
|
},
|
|
mode: "onChange",
|
|
reValidateMode: "onChange",
|
|
});
|
|
|
|
const onSubmit = ({ email }: EmailCodeFormValues) => {
|
|
console.log(email);
|
|
authenticationService
|
|
.emailCode({ email })
|
|
.then((res) => {
|
|
setValue("key", res.key);
|
|
setCodeSent(true);
|
|
})
|
|
.catch((err) => {
|
|
console.log(err);
|
|
});
|
|
};
|
|
|
|
const handleSignin = (formData: EmailCodeFormValues) => {
|
|
authenticationService
|
|
.magicSignIn(formData)
|
|
.then((response) => {
|
|
onSuccess(response);
|
|
})
|
|
.catch((error) => {
|
|
console.log(error);
|
|
setError("token" as keyof EmailCodeFormValues, {
|
|
type: "manual",
|
|
message: error.error,
|
|
});
|
|
});
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<form
|
|
className="mt-5 space-y-5"
|
|
onSubmit={codeSent ? handleSubmit(handleSignin) : handleSubmit(onSubmit)}
|
|
>
|
|
{codeSent && (
|
|
<div className="rounded-md bg-green-50 p-4">
|
|
<div className="flex">
|
|
<div className="flex-shrink-0">
|
|
<CheckCircleIcon className="h-5 w-5 text-green-400" aria-hidden="true" />
|
|
</div>
|
|
<div className="ml-3">
|
|
<p className="text-sm font-medium text-green-800">
|
|
Please check your mail for code.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)}
|
|
<div>
|
|
<Input
|
|
id="email"
|
|
type="email"
|
|
name="email"
|
|
register={register}
|
|
validations={{
|
|
required: "Email ID is required",
|
|
validate: (value) =>
|
|
/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(
|
|
value
|
|
) || "Email ID is not valid",
|
|
}}
|
|
error={errors.email}
|
|
placeholder="Enter your Email ID"
|
|
/>
|
|
</div>
|
|
|
|
{codeSent && (
|
|
<div>
|
|
<Input
|
|
id="token"
|
|
type="token"
|
|
name="token"
|
|
register={register}
|
|
validations={{
|
|
required: "Code is required",
|
|
}}
|
|
error={errors.token}
|
|
placeholder="Enter code"
|
|
/>
|
|
</div>
|
|
)}
|
|
<div>
|
|
<Button
|
|
disabled={isSubmitting || (!isValid && isDirty)}
|
|
className="w-full text-center"
|
|
type="submit"
|
|
>
|
|
{isSubmitting ? "Signing in..." : codeSent ? "Sign In" : "Continue with Email ID"}
|
|
</Button>
|
|
</div>
|
|
</form>
|
|
</>
|
|
);
|
|
};
|