Skip to content

Commit

Permalink
create the home page and update the sign in Page
Browse files Browse the repository at this point in the history
  • Loading branch information
Olasunkanmi Oyinlola authored and Olasunkanmi Oyinlola committed Feb 16, 2024
1 parent ef5161a commit 9731fe2
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 25 deletions.
98 changes: 75 additions & 23 deletions frontend/src/components/AppForms/SignInForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Button, Card, Form } from "react-bootstrap";
import { SubmitHandler, useForm } from "react-hook-form";
import { z } from "zod";
import { FormInput } from "../Forms/form-input";
import { TabComponent } from "../Utilities/tab";
import { Link } from "react-router-dom";

export type loginFormProps = {
email: string;
Expand All @@ -22,31 +24,81 @@ export const LoginForm = () => {
handleSubmit,
formState: { errors },
} = useForm<validationSchema>({ resolver: zodResolver(validateInputSchema) });
const EmailSignUp = () => {
return (
<Card>
<Card.Body>
<Form onSubmit={handleSubmit(onSubmit)}>
<FormInput<loginFormProps>
id="email"
name="email"
placeholder="Enter email"
register={register}
errors={errors}
/>
<FormInput<loginFormProps>
id="password"
name="password"
placeholder="Enter password"
register={register}
errors={errors}
/>
<Button className="w-100" style={{ backgroundColor: "#407c54", borderColor: "#407c54" }} type="submit">
Login
</Button>
</Form>
</Card.Body>
</Card>
);
};

const PhoneNumberSignUp = () => {
return (
<Card>
<Card.Body>
<Form onSubmit={handleSubmit(onSubmit)}>
<FormInput<loginFormProps>
id="email"
name="email"
placeholder="Enter phone number"
register={register}
errors={errors}
/>
<Button className="w-100" style={{ backgroundColor: "#407c54", borderColor: "#407c54" }} type="submit">
Login
</Button>
</Form>
</Card.Body>
</Card>
);
};

const signUpTab = [
{ title: "Email", children: <EmailSignUp /> },
{ title: "Phone", children: <PhoneNumberSignUp /> },
];

const onSubmit: SubmitHandler<validationSchema> = (data) => console.log(data);
return (
<Card>
<Card.Body>
<Form onSubmit={handleSubmit(onSubmit)}>
<FormInput<loginFormProps>
id="email"
name="email"
placeholder="Enter email"
register={register}
errors={errors}
/>
<FormInput<loginFormProps>
id="password"
name="password"
placeholder="Enter password"
register={register}
errors={errors}
/>
<Button className="w-100" variant="primary" type="submit">
Submit
</Button>
</Form>
</Card.Body>
</Card>
<div
style={{
border: "0.1px solid #407c54",
padding: "20px",
borderRadius: "15px",
boxShadow: "0 0 10px rgba(0, 0, 0, 0.1)",
}}
>
<div>
<span>
<p style={{ fontSize: "12px" }}>Login to your Account</p>
</span>
</div>
<TabComponent tabs={signUpTab}></TabComponent>
<div style={{ justifyContent: "center", display: "flex", marginTop: "15px" }}>
<p style={{ fontSize: "12px" }}>
Don't have an account? <Link to="/register">Sign up</Link>
</p>
</div>
</div>
);
};
28 changes: 28 additions & 0 deletions frontend/src/components/Utilities/AuthModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { CSSProperties } from "react";
import { Button } from "react-bootstrap";
import { useNavigate } from "react-router-dom";

export const AuthModal = () => {
const navigate = useNavigate();
const handleSignIn = () => {
navigate("/login");
};
const buttonStyle: CSSProperties = {
width: "100%",
margin: "auto",
};
return (
<div>
<div style={{ marginBottom: "15px" }}>
<Button onClick={handleSignIn} variant="dark" className="w-10" size="lg" style={buttonStyle}>
Sign In
</Button>
</div>
<div>
<Button variant="outline-dark " className="w-10" size="sm" style={buttonStyle}>
Continue as a Guest
</Button>
</div>
</div>
);
};
3 changes: 3 additions & 0 deletions frontend/src/components/Utilities/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ export const Navigation = () => {
</Stack>
</Nav.Link>
</Nav>
{/* <span style={{ fontWeight: 600 }} onClick={previousPage}>
<FontAwesomeIcon icon={faCircleUser} size="xl" /> Profile
</span> */}
<Button
style={{ width: "3rem", height: "3rem", position: "relative" }}
variant="outline-secondary"
Expand Down
28 changes: 28 additions & 0 deletions frontend/src/components/Utilities/tab.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React, { CSSProperties } from "react";
import { Tabs, Tab } from "react-bootstrap";

interface TabProps {
title: string;
children: React.ReactNode;
}

interface TabComponentProps {
tabs: TabProps[];
style?: CSSProperties;
}

export const TabComponent = ({ tabs, style }: Readonly<TabComponentProps>) => {
const renderTabs = () => {
return tabs.map(({ title, children }) => (
<Tab style={style} key={title} eventKey={title} title={title}>
{children}
</Tab>
));
};

return (
<Tabs defaultActiveKey={"Email"} className="mb-3">
{renderTabs()}
</Tabs>
);
};
16 changes: 14 additions & 2 deletions frontend/src/pages/Landing.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { CSSProperties } from "react";
import { CSSProperties, useState } from "react";
import { Button, Stack } from "react-bootstrap";
import { CallToAction } from "../components/Utilities/modal";
import { AuthModal } from "../components/Utilities/AuthModal";

export const Landing = () => {
const [showModal, setShowModal] = useState<boolean>(false);
const handleCloseModal = () => setShowModal(false);
const handleShowModal = () => setShowModal(true);
const pageStyle: CSSProperties = {
margin: 0,
padding: 0,
Expand All @@ -14,7 +19,7 @@ export const Landing = () => {
left: 0,
width: "100%",
height: "100%",
backgroundImage: `url(public/food-background.jpg)`,
backgroundImage: `url(/food-background.jpg)`,
backgroundSize: "cover",
backgroundPosition: "center",
opacity: 0.5,
Expand All @@ -30,6 +35,7 @@ export const Landing = () => {
<div style={backgroundOverlayStyle}></div>
<Stack direction="vertical" gap={3} className="p-3 fixed-bottom">
<Button
onClick={handleShowModal}
className="w-10"
size="lg"
style={{ ...buttonStyle, backgroundColor: "#407c54", borderColor: "#407c54" }}
Expand All @@ -40,6 +46,12 @@ export const Landing = () => {
Order HISTORY
</Button>
</Stack>

<div>
<CallToAction handleAction={handleCloseModal} handleClose={handleCloseModal} show={showModal}>
<AuthModal />
</CallToAction>
</div>
</div>
);
};

0 comments on commit 9731fe2

Please sign in to comment.