-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added rest of thek page including login and other page multi la…
…gn support
- Loading branch information
1 parent
e0b904e
commit 3c529f2
Showing
9 changed files
with
160 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/app/[lang]/(front-end)/(user-auth)/login/logInForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
"use client"; | ||
|
||
import { zodResolver } from "@hookform/resolvers/zod"; | ||
import { useForm } from "react-hook-form"; | ||
import * as z from "zod"; | ||
|
||
// import { loginPatient_server } from "@/actions"; | ||
import { Email, InputCombo, InputComboForPassword, Lock } from "@/components"; | ||
import { loginFormSchema } from "@/schema"; | ||
import toast from "react-hot-toast"; | ||
|
||
type LoginFormData = z.infer<typeof loginFormSchema>; | ||
interface Props { | ||
dictionary: any; | ||
} | ||
|
||
export const LoginForm = ({ dictionary }: Props) => { | ||
const { | ||
register, | ||
handleSubmit, | ||
formState: { errors, isLoading }, | ||
setError, | ||
} = useForm<LoginFormData>({ | ||
resolver: zodResolver(loginFormSchema), | ||
}); | ||
|
||
const onSubmit = async (data: LoginFormData) => { | ||
const toastId = toast.loading("Processing", { id: "login" }); | ||
try { | ||
// const res = await loginPatient_server(data); | ||
// if (!res.success) throw new Error(res.message); | ||
// toast.success(res.message, { id: toastId }); | ||
} catch (error: any) { | ||
toast.error(error?.message || "Invalid email or password", { | ||
id: toastId, | ||
}); | ||
} | ||
}; | ||
|
||
return ( | ||
<form onSubmit={handleSubmit(onSubmit)}> | ||
<InputCombo | ||
register={register("email")} | ||
error={errors.email?.message} | ||
icon={<Email />} | ||
placeholder={dictionary?.emailPlaceholder || "Email"} | ||
/> | ||
|
||
<InputComboForPassword | ||
register={register("password")} | ||
error={errors.password?.message} | ||
icon={<Lock />} | ||
placeholder="*******" | ||
/> | ||
<InputComboForPassword | ||
register={register("confirmPassword")} | ||
error={errors.confirmPassword?.message} | ||
icon={<Lock />} | ||
placeholder="******" | ||
/> | ||
|
||
<button | ||
className="mt-6 w-full transform rounded-lg bg-blue-500 px-6 py-3 text-sm font-medium capitalize tracking-wide text-white transition-colors duration-300 hover:bg-blue-400 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-50 2xl:py-4 2xl:text-2xl" | ||
type="submit" | ||
> | ||
{dictionary?.singup} | ||
</button> | ||
</form> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,25 @@ | ||
"use client"; | ||
import React from "react"; | ||
import { LoginForm } from "./logInForm"; | ||
import { getDictionary } from "@/Internationalization"; | ||
|
||
import { zodResolver } from "@hookform/resolvers/zod"; | ||
import { useForm } from "react-hook-form"; | ||
import * as z from "zod"; | ||
|
||
// import { loginPatient_server } from "@/actions"; | ||
import { Email, InputCombo, InputComboForPassword, Lock } from "@/components"; | ||
import { loginFormSchema } from "@/schema"; | ||
import toast from "react-hot-toast"; | ||
|
||
type LoginFormData = z.infer<typeof loginFormSchema>; | ||
|
||
const Login = () => { | ||
const { | ||
register, | ||
handleSubmit, | ||
formState: { errors, isLoading }, | ||
setError, | ||
} = useForm<LoginFormData>({ | ||
resolver: zodResolver(loginFormSchema), | ||
}); | ||
|
||
const onSubmit = async (data: LoginFormData) => { | ||
const toastId = toast.loading("Processing", { id: "login" }); | ||
try { | ||
// const res = await loginPatient_server(data); | ||
// if (!res.success) throw new Error(res.message); | ||
// toast.success(res.message, { id: toastId }); | ||
} catch (error: any) { | ||
toast.error(error?.message || "Invalid email or password", { | ||
id: toastId, | ||
}); | ||
} | ||
interface Props { | ||
params: { | ||
lang: string; | ||
}; | ||
} | ||
|
||
return ( | ||
<form onSubmit={handleSubmit(onSubmit)}> | ||
<InputCombo | ||
register={register("email")} | ||
error={errors.email?.message} | ||
icon={<Email />} | ||
placeholder="Email address" | ||
/> | ||
|
||
<InputComboForPassword | ||
register={register("password")} | ||
error={errors.password?.message} | ||
icon={<Lock />} | ||
placeholder="*******" | ||
/> | ||
<InputComboForPassword | ||
register={register("confirmPassword")} | ||
error={errors.confirmPassword?.message} | ||
icon={<Lock />} | ||
placeholder="******" | ||
/> | ||
const LoginPage = async ({ params }: Props) => { | ||
const dictionary = await getDictionary(params.lang, "useAuth"); | ||
|
||
<button | ||
className="mt-6 w-full transform rounded-lg bg-blue-500 px-6 py-3 text-sm font-medium capitalize tracking-wide text-white transition-colors duration-300 hover:bg-blue-400 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-50 2xl:text-2xl 2xl:py-4" | ||
type="submit" | ||
> | ||
Sign Up | ||
</button> | ||
</form> | ||
return ( | ||
<> | ||
<LoginForm dictionary={dictionary} /> | ||
</> | ||
); | ||
}; | ||
|
||
export default Login; | ||
export default LoginPage; | ||
|
||
export async function generateStaticParams() { | ||
return [{ lang: "bn" }, { lang: "en" }]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,33 @@ | ||
import { LinkTo } from "@/components"; | ||
import { getDictionary } from "@/Internationalization"; | ||
import React from "react"; | ||
|
||
export async function generateStaticParams() { | ||
return [{ lang: "bn" }, { lang: "en" }]; | ||
interface Props { | ||
params: { | ||
lang: string; | ||
}; | ||
} | ||
|
||
const Register = () => { | ||
const Register = async ({ params }: Props) => { | ||
const dictionary = await getDictionary(params.lang, "useAuth"); | ||
|
||
return ( | ||
<div className="flex flex-col items-center justify-center py-20"> | ||
<h3>You {`can's `} register yourself</h3> | ||
<p>Only doctors can register you as an user.</p> | ||
<div className="flex flex-col items-center justify-center py-20 text-center"> | ||
<h3>{dictionary.register.heading}</h3> | ||
<p>{dictionary.register.subHeading}</p> | ||
<p className="mt-5"> | ||
book your | ||
{dictionary.register.bookAppointment} | ||
<LinkTo href={"/about-us"} className="mx-1 text-main-400"> | ||
appointment | ||
{dictionary.register.bookAppointment2} | ||
</LinkTo> | ||
with doctor and get treatment. | ||
{dictionary.register.bookAppointment3} | ||
</p> | ||
</div> | ||
); | ||
}; | ||
|
||
export async function generateStaticParams() { | ||
return [{ lang: "bn" }, { lang: "en" }]; | ||
} | ||
|
||
export default Register; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters