diff --git a/web/components/account/email-password-form.tsx b/web/components/account/email-password-form.tsx index fe8d2d51c..f7861f553 100644 --- a/web/components/account/email-password-form.tsx +++ b/web/components/account/email-password-form.tsx @@ -12,10 +12,20 @@ export interface EmailPasswordFormValues { export interface IEmailPasswordForm { onSubmit: (formData: EmailPasswordFormValues) => Promise; + buttonText?: string; + submittingButtonText?: string; + withForgetPassword?: boolean; + withSignUpLink?: boolean; } export const EmailPasswordForm: React.FC = (props) => { - const { onSubmit } = props; + const { + onSubmit, + buttonText = "Sign in", + submittingButtonText = "Signing in...", + withForgetPassword = false, + withSignUpLink = false, + } = props; // router const router = useRouter(); // form info @@ -82,15 +92,17 @@ export const EmailPasswordForm: React.FC = (props) => { )} /> -
- -
+ {withForgetPassword && ( +
+ +
+ )}
-
- -
+ {withSignUpLink && ( +
+ +
+ )} ); diff --git a/web/components/account/email-signup-form.tsx b/web/components/account/email-signup-form.tsx index a60a83230..b60d72156 100644 --- a/web/components/account/email-signup-form.tsx +++ b/web/components/account/email-signup-form.tsx @@ -4,7 +4,7 @@ import { Controller, useForm } from "react-hook-form"; // ui import { Button, Input } from "@plane/ui"; // types -type EmailPasswordFormValues = { +export type EmailPasswordSignUpFormValues = { email: string; password?: string; confirm_password: string; @@ -12,7 +12,7 @@ type EmailPasswordFormValues = { }; type Props = { - onSubmit: (formData: EmailPasswordFormValues) => Promise; + onSubmit: (formData: EmailPasswordSignUpFormValues) => Promise; }; export const EmailSignUpForm: React.FC = (props) => { @@ -23,7 +23,7 @@ export const EmailSignUpForm: React.FC = (props) => { control, watch, formState: { errors, isSubmitting, isValid, isDirty }, - } = useForm({ + } = useForm({ defaultValues: { email: "", password: "", diff --git a/web/components/page-views/signin.tsx b/web/components/page-views/signin.tsx index 23a1ea634..c7b19e268 100644 --- a/web/components/page-views/signin.tsx +++ b/web/components/page-views/signin.tsx @@ -210,7 +210,9 @@ export const SignInView = observer(() => { ) : ( <> <> - {enableEmailPassword && } + {enableEmailPassword && ( + + )} {data?.magic_login && (
diff --git a/web/components/views/signin.tsx b/web/components/views/signin.tsx index b83dc32d1..d163525d0 100644 --- a/web/components/views/signin.tsx +++ b/web/components/views/signin.tsx @@ -149,7 +149,9 @@ export const SignInView = observer(() => { Sign in to Plane <> - {enableEmailPassword && } + {enableEmailPassword && ( + + )} {data?.magic_login && (
diff --git a/web/pages/activate/index.tsx b/web/pages/activate/index.tsx new file mode 100644 index 000000000..e0ffafafc --- /dev/null +++ b/web/pages/activate/index.tsx @@ -0,0 +1,58 @@ +import Image from "next/image"; +// layouts +import DefaultLayout from "layouts/default-layout"; +// components +import { EmailPasswordForm, EmailPasswordFormValues } from "components/account"; +// images +import BluePlaneLogoWithoutText from "public/plane-logos/blue-without-text.png"; +// services +import { InstanceService } from "services/instance.service"; +import { useRouter } from "next/router"; +import { useEffect } from "react"; + +const instanceService = new InstanceService(); + +const ActivateInstancePage = () => { + const router = useRouter(); + + useEffect(() => { + instanceService.checkForInstanceStatus().then((response) => { + console.log(response); + }); + }, []); + + const handleSignUp = (values: EmailPasswordFormValues) => + instanceService + .createInstance(values) + .then((response) => { + router.push("/"); + }) + .catch((error) => {}); + + return ( + + <> +
+
+
+
+ Plane Logo +
+
+
+ +
+
+

Activate Your Instance

+ +
+
+ + ); +}; + +export default ActivateInstancePage; diff --git a/web/services/instance.service.ts b/web/services/instance.service.ts new file mode 100644 index 000000000..06d88f2b6 --- /dev/null +++ b/web/services/instance.service.ts @@ -0,0 +1,30 @@ +import { APIService } from "services/api.service"; +// helpers +import { API_BASE_URL } from "helpers/common.helper"; +import Cookies from "js-cookie"; + +export class InstanceService extends APIService { + constructor() { + super(API_BASE_URL); + } + + async checkForInstanceStatus() { + return this.get("/api/licenses/instances/") + .then((response) => response?.data) + .catch((error) => { + throw error?.response?.data; + }); + } + + async createInstance(values: any) { + return this.post("/api/licenses/instances/", values) + .then((response) => { + console.log(response); + Cookies.set("instance_id", response?.data?.instance_id); + return response?.data; + }) + .catch((error) => { + throw error?.response?.data; + }); + } +}