Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seller signup #748

Merged
merged 4 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client"

import { orderItemProps } from "@/app/MyOrders/components/orderItem";
import { orderItemProps } from "@/app/(Customer)/MyOrders/components/orderItem";
import Image from "next/image";


Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion app/MyOrders/page.tsx → app/(Customer)/MyOrders/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ const Orders = () => {
} else {
setIsFirstRender(false);
}
}, [currentPage]);
}, [isFirstRender,currentPage]);

return (
<div className="h-full mb-10 dark:bg-DarkGray">
Expand Down
1 change: 1 addition & 0 deletions app/Teams/page.tsx → app/(Customer)/Teams/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const Teams = () => {
return (
<></>
// Dont remove the comments below!
// <div className="h-full pb-20 dark:bg-DarkGray">
// <div className="h-full">
// <div className="text-white flex items-center justify-center bg-customTeal dark:bg-gradient-to-r from-Green to-Yellow h-full mb-20 p-24">
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions app/(Customer)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Footer from "@/components/footer";
import Navbar from "@/components/Navbar/navbar";

export default function Layout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
// <body>
<>
<Navbar />
{children}
<Footer />
</>
// {/* </body> */}
);
}
File renamed without changes.
File renamed without changes.
145 changes: 145 additions & 0 deletions app/(Seller)/auth/components/loginPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Spinner } from "@/components/ui/spinner";
import { Eye, EyeOff, Mail, User } from "lucide-react";
import { signIn, useSession } from "next-auth/react";
import { useState } from "react";
import toast from "react-hot-toast";

interface LoginPageProps {
switchCss: boolean;
setSwitchCss: (value: boolean) => void;
isResetOpen: boolean;
setIsResetOpen: (value: boolean) => void;
loading: boolean;
setError: (value: string) => void;
setloading: (value: boolean) => void;
}

const LoginPage: React.FC<LoginPageProps> = ({
switchCss,
setSwitchCss,
isResetOpen,
setIsResetOpen,
loading,
setloading,
setError,
}) => {
const session = useSession();

const [email, setEmail] = useState("");
const [password, setPassword] = useState("");

const [showPassword, setShowPassword] = useState(false);

const handleSubmit = async (e: React.FormEvent) => {
setloading(true);
e.preventDefault();

const result = await signIn("credentials", {
email,
password,
redirect: false,
});
console.log(result);
if (result?.error) setError("Invalid email or password");
else {
toast.success(`Welcome ${session.data?.user?.name}`);
window.location.href = "/"; // Redirect on success
}
setloading(false);
};

return (
<>
{switchCss && !isResetOpen && (
<div className="flex flex-col z-10 items-center justify-start pt-24 pr-14 gap-4 w-2/4">
<div className="font-nunito text-4xl text-customTeal dark:text-Green font-extrabold">
Login
</div>
<form
// closed login button
onSubmit={handleSubmit}
className="w-full flex dark:text-gray-200 flex-col items-center gap-4"
>
<div className="flex items-center w-4/5 justify-center">
<Input
className="rounded-full"
type="email"
placeholder="Email"
value={email}
onChange={(e) => setEmail(e.target.value)}
/>
<User className="h-7 w-7 text-customTeal dark:text-Yellow" />
</div>
<div className="flex items-center w-4/5 justify-center">
<Input
className="rounded-full"
type={showPassword ? "text" : "password"}
placeholder="Password"
value={password}
onChange={(e) => setPassword(e.target.value)}
/>
<div
className=" cursor-pointer"
onClick={() => setShowPassword(!showPassword)}
>
{showPassword ? (
<EyeOff className="h-7 w-7 text-customTeal dark:text-Yellow" />
) : (
<Eye className="h-7 w-7 text-customTeal dark:text-Yellow" />
)}
</div>
</div>
<Button
type="submit"
disabled
// disabled={loading}
className="rounded-full bg-customTeal dark:bg-Green font-bold h-10 w-4/5 disabled"
>
{loading ? <Spinner /> : "Login"}
</Button>
</form>
<div
className="text-customTeal dark:text-Green cursor-pointer"
onClick={() => setIsResetOpen(!isResetOpen)}
>
Forgot Password?
</div>
<div className="flex items-center dark:text-gray-500 justify-center gap-2">
Don&apos;t have an account?
<div
className="text-customTeal dark:text-Green cursor-pointer"
onClick={() => setSwitchCss(!switchCss)}
>
{" "}
Sign Up
</div>
</div>
</div>
)}
{switchCss && isResetOpen && (
<div className="flex flex-col z-10 items-center justify-start pt-32 pr-14 gap-4 w-2/4">
<div className="font-nunito text-4xl text-customTeal dark:text-Green font-extrabold">
Forgot Password
</div>
<div className="flex items-center gap-2 w-4/5 justify-center">
<Input className="rounded-full" type="text" placeholder="Email" />
<Mail className="h-7 w-7 text-customTeal dark:text-Yellow" />
</div>
<Button className="rounded-full font-bold h-10 w-4/5 bg-customTeal dark:bg-Green">
Send reset link
</Button>
<div
className="text-customTeal dark:text-Green cursor-pointer"
onClick={() => setIsResetOpen(!isResetOpen)}
>
Back to Login
</div>
</div>
)}
</>
);
};

export default LoginPage;
177 changes: 177 additions & 0 deletions app/(Seller)/auth/components/signupPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { AtSign, Phone, User, Eye, EyeOff } from "lucide-react"; // Import Eye and EyeOff
import React, { useState } from "react";
import toast from "react-hot-toast";
import axios from "axios"
import { Spinner } from "@/components/ui/spinner";

interface SignupPageProps {
switchCss: boolean;
setSwitchCss: (value: boolean) => void;
setError: (value: string) => void;
loading:boolean,
setloading:(value:boolean)=>void;
}

const SignupPage: React.FC<SignupPageProps> =({ switchCss, setSwitchCss,setError ,loading,setloading}) => {
// State for form fields
const [fullname, setFullname] = useState("");
const [mobileNumber, setmobileNumber] = useState("");
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [confirmPassword, setConfirmPassword] = useState("");

// State for showing passwords
const [showPassword, setShowPassword] = useState(false);
const [showConfirmPassword, setShowConfirmPassword] = useState(false);

// Handle form submission
const handleSubmit = async(e: React.FormEvent) => {
setloading(true)
e.preventDefault();

// Basic validation
if (!fullname || !mobileNumber || !email || !password || !confirmPassword) {
setError("All fields are required.");
setloading(false)
return;
}
if (password !== confirmPassword) {
setError("Passwords do not match.");
setloading(false)
return;
}


const result = await axios.post('/api/auth/signup/seller',{
email,
password,
name:fullname,
mobileNumber
})
console.log(result)
if (!result) setError("Invalid email or password");
else {
toast.success(`Successful, you can login now.`)
// ${session.data?.user?.name}
window.location.href = "/auth/seller"; // Redirect on success
}

// Reset form fields after submission
setFullname("");
setmobileNumber("");
setEmail("");
setPassword("");
setConfirmPassword("");

setloading(false)
};

return (
<>
{!switchCss && (
<div className="flex flex-col dark:text-gray-200 z-10 items-center justify-start pt-12 pl-14 gap-4 w-2/4">
<div className="font-nunito text-4xl text-customTeal dark:text-Green font-extrabold">
Sign Up
</div>
<form
onSubmit={handleSubmit}
className="w-full flex flex-col items-center justify-center"
>
<div className="flex items-center w-4/5 justify-center mb-4">
<Input
className="rounded-full"
type="text"
placeholder="Fullname"
value={fullname}
onChange={(e) => setFullname(e.target.value)}
/>
<User className="h-7 w-7 text-customTeal dark:text-Yellow" />
</div>
<div className="flex items-center w-4/5 justify-center mb-4">
<Input
className="rounded-full"
type="text"
placeholder="mobileNumber"
value={mobileNumber}
onChange={(e) => setmobileNumber(e.target.value)}
/>
<Phone className="h-7 w-7 text-customTeal dark:text-Yellow" />
</div>
<div className="flex items-center w-4/5 justify-center mb-4">
<Input
className="rounded-full"
type="email"
placeholder="Email"
value={email}
onChange={(e) => setEmail(e.target.value)}
/>
<AtSign className="h-7 w-7 text-customTeal dark:text-Yellow" />
</div>
<div className="flex items-center w-4/5 justify-center mb-4 relative">
{" "}
{/* Added relative for positioning */}
<Input
className="rounded-full pr-12" // Added padding for the icon
type={showPassword ? "text" : "password"} // Toggle password visibility
placeholder="Enter Password"
value={password}
onChange={(e) => setPassword(e.target.value)}
/>
<div
className=" cursor-pointer"
onClick={() => setShowPassword(!showPassword)}
>
{showPassword ? (
<EyeOff className="h-7 w-7 text-customTeal dark:text-Yellow" />
) : (
<Eye className="h-7 w-7 text-customTeal dark:text-Yellow" />
)}
</div>
</div>
<div className="flex items-center w-4/5 justify-center mb-4 relative">
{" "}
{/* Added relative for positioning */}
<Input
className="rounded-full pr-12" // Added padding for the icon
type={showConfirmPassword ? "text" : "password"} // Toggle password visibility
placeholder="Confirm Password"
value={confirmPassword}
onChange={(e) => setConfirmPassword(e.target.value)}
/>
<div
className="cursor-pointer"
onClick={() => setShowConfirmPassword(!showConfirmPassword)}
>
{showConfirmPassword ? (
<EyeOff className="h-7 w-7 text-customTeal dark:text-Yellow" />
) : (
<Eye className="h-7 w-7 text-customTeal dark:text-Yellow" />
)}
</div>
</div>
<Button
className="rounded-full h-10 w-4/5 font-bold bg-customTeal dark:bg-Green"
type="submit"
// disabled
>
{loading ? <Spinner /> : "Sign Up"}
</Button>
</form>
<div className="flex items-center dark:text-gray-500 justify-center gap-2">
Already have an account?
<div
className="text-customTeal dark:text-Green cursor-pointer"
onClick={() => setSwitchCss(!switchCss)}
>
Login
</div>
</div>
</div>
)}
</>
);
};

export default SignupPage;
Loading