feat: Add signUp page and Sign out button

This commit is contained in:
igorrCarvalho 2023-08-09 20:06:22 -03:00
commit 468f6ec573
6 changed files with 243 additions and 96 deletions

View file

@ -34,6 +34,9 @@ export default function Header() {
<Link to="/"> <Link to="/">
<span className="ml-4 text-2xl">⛓️</span> <span className="ml-4 text-2xl">⛓️</span>
</Link> </Link>
<Button variant="outline" className="">
Sign out
</Button>
{flows.findIndex((f) => tabId === f.id) !== -1 && tabId !== "" && ( {flows.findIndex((f) => tabId === f.id) !== -1 && tabId !== "" && (
<MenuBar flows={flows} tabId={tabId} /> <MenuBar flows={flows} tabId={tabId} />
)} )}

View file

@ -9,6 +9,7 @@ export default function InputComponent({
disabled, disabled,
password, password,
editNode = false, editNode = false,
placeholder = "Type something...",
}: InputComponentType) { }: InputComponentType) {
const [pwdVisible, setPwdVisible] = useState(false); const [pwdVisible, setPwdVisible] = useState(false);
@ -30,7 +31,7 @@ export default function InputComponent({
password && editNode ? "pr-8" : "", password && editNode ? "pr-8" : "",
password && !editNode ? "pr-10" : "" password && !editNode ? "pr-10" : ""
)} )}
placeholder={password && editNode ? "Key" : "Type something..."} placeholder={password && editNode ? "Key" : placeholder}
onChange={(e) => { onChange={(e) => {
onChange(e.target.value); onChange(e.target.value);
}} }}

View file

@ -508,3 +508,10 @@ export const URL_EXCLUDED_FROM_ERROR_RETRIES = [
"/api/v1/custom_component", "/api/v1/custom_component",
"/api/v1/validate/prompt", "/api/v1/validate/prompt",
]; ];
export const CONTROL_INPUT_STATE = {
email: '',
password: '',
cnfPassword: '',
username: '',
};

View file

@ -0,0 +1,119 @@
import _ from "lodash";
import { FaApple, FaGithub } from "react-icons/fa";
import { Button } from "../../components/ui/button";
import { Input } from "../../components/ui/input";
import { GoogleIcon } from "../../icons/Google";
import { useContext, useState } from "react";
import { CONTROL_INPUT_STATE } from "../../constants/constants";
import { inputHandlerEventType, inputStateType } from "../../types/components";
import { alertContext } from "../../contexts/alertContext";
import { Link } from "react-router-dom";
import InputComponent from "../../components/inputComponent";
export default function SignUp(): JSX.Element {
const [inputState, setInputState] = useState<inputStateType>(CONTROL_INPUT_STATE);
let errClasses = {
email: false,
password: false,
cnfPassword: false,
username: false,
};
const {
setErrorData,
errorOpen,
} = useContext(alertContext);
const { email, password, cnfPassword, username } = inputState;
function handleInput({ target: { name, value } }: inputHandlerEventType): void {
setInputState((prev) => ({ ...prev, [name]: value }));
};
function handleSignUpPass() {
if (password !== cnfPassword) {
const errorDat = {
title: "Passwords are not equal",
};
return setErrorData(errorDat);
}
let err = [];
Object.keys(inputState)
.forEach((key) => {
if (inputState[key] === '') {
err.push(key);
errClasses[key] = true;
}
});
setErrorData({
title: "Mandatory fields are empty",
list: err,
});
}
return (
<div className="flex h-full w-full flex-col items-center justify-center bg-muted">
<div className="flex w-72 flex-col items-center justify-center gap-2">
<span className="mb-4 text-5xl">⛓️</span>
<span className="mb-6 text-2xl font-semibold text-primary">
Sign up to LangFlow
</span>
<div className="flex w-full items-center justify-center gap-2">
<Button variant="primary" className="w-full py-6">
<FaApple className="h-6 w-6" />
</Button>
<Button variant="primary" className="w-full py-6">
<FaGithub className="h-6 w-6" />
</Button>
<Button variant="primary" className="w-full py-6">
<div className="h-6 w-6">
<GoogleIcon />
</div>
</Button>
</div>
<span className="text-sm text-muted-foreground">or</span>
<Input
className={errClasses.email ? "border-destructive" : "" + " bg-background"}
placeholder="Email address"
name="email"
value={email}
onChange={handleInput}
type="text"
/>
<InputComponent
value={password}
onChange={(value) => handleInput({ target: { name: 'password', value } })}
password={true}
placeholder="Password"
/>
<InputComponent
value={cnfPassword}
onChange={(value) => handleInput({ target: { name: 'cnfPassword', value } })}
password={true}
placeholder="Confirm your password"
/>
<Input
className="bg-background"
placeholder="Username"
name="username"
value={username}
onChange={handleInput}
type="text"
/>
<Button
variant="default"
className="w-full"
onClick={() => {
handleSignUpPass();
}}
>
Sign up
</Button>
<Link to="/login" className="mt-6 w-full">
<Button variant="outline" className="mt-6 w-full">
Already have an account?&nbsp;<b>Sign in</b>
</Button>
</Link>
</div>
</div>
);
}

View file

@ -4,6 +4,7 @@ import FlowPage from "./pages/FlowPage";
import HomePage from "./pages/MainPage"; import HomePage from "./pages/MainPage";
import DeleteAccountPage from "./pages/deleteAccountPage"; import DeleteAccountPage from "./pages/deleteAccountPage";
import LoginPage from "./pages/loginPage"; import LoginPage from "./pages/loginPage";
import SignUp from "./pages/signUpPage";
const Router = () => { const Router = () => {
return ( return (
@ -15,6 +16,7 @@ const Router = () => {
</Route> </Route>
<Route path="*" element={<HomePage />} /> <Route path="*" element={<HomePage />} />
<Route path="/login" element={<LoginPage />} /> <Route path="/login" element={<LoginPage />} />
<Route path="/signup" element={<SignUp/>} />
<Route path="/account"> <Route path="/account">
<Route path="delete" element={<DeleteAccountPage />}></Route> <Route path="delete" element={<DeleteAccountPage />}></Route>
</Route> </Route>

View file

@ -10,6 +10,7 @@ export type InputComponentType = {
editNode?: boolean; editNode?: boolean;
onChangePass?: (value: boolean | boolean) => void; onChangePass?: (value: boolean | boolean) => void;
showPass?: boolean; showPass?: boolean;
placeholder?: string;
}; };
export type ToggleComponentType = { export type ToggleComponentType = {
enabled: boolean; enabled: boolean;
@ -171,3 +172,17 @@ export type IconComponentProps = {
export interface languageMap { export interface languageMap {
[key: string]: string | undefined; [key: string]: string | undefined;
} }
export type inputStateType = {
email: string;
password: string;
cnfPassword: string;
username: string;
};
export type inputHandlerEventType = {
target: {
value: string;
name: string;
};
};