Skip to content

Commit

Permalink
feat: added rest of thek page including login and other page multi la…
Browse files Browse the repository at this point in the history
…gn support
  • Loading branch information
yeasin2002 committed Aug 20, 2024
1 parent e0b904e commit 3c529f2
Show file tree
Hide file tree
Showing 9 changed files with 160 additions and 90 deletions.
14 changes: 14 additions & 0 deletions src/Internationalization/languages/bn.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,19 @@
"heading": "আমাদের প্রদত্ত সেবা",
"subheading": "আমরা বিভিন্ন ধরণের ডেন্টাল সেবা প্রদান করি",
"listOfContent": "সেবাসমূহ"
},
"useAuth": {
"areYouDoctor": "আপনি কি ডাক্তার?",
"loginHere": "তাহলে লগইন করুণ ",
"asDoctor": "ডাক্তার হিসেবে.",
"emailPlaceholder": "আপনার ইমেইল ঠিকানা লিখুন ",
"singup": "সাইন-আপ",
"register": {
"heading": "আপনি নিজে রেজিস্টার করতে পারবেন না ",
"subHeading": " শুধুমাত্র ডাক্তাররা আপনাকে একজন ব্যবহারকারী হিসাবে নিবন্ধন করতে পারেন.",
"bookAppointment": "বুকিং করুণ ",
"bookAppointment2": "আপনার অ্যাপয়েন্টমেন্ট ",
"bookAppointment3": "ডাক্তারদের সাথে চিকিৎসা নিতে "
}
}
}
14 changes: 14 additions & 0 deletions src/Internationalization/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,19 @@
"heading": "Service that we provide",
"subheading": "We provide various type of dental services",
"listOfContent": "List of our Services"
},
"useAuth": {
"areYouDoctor": "Are you a doctor?",
"loginHere": "login here",
"asDoctor": "as a doctor.",
"emailPlaceholder": "Write your email here",
"singup": "Sing Up ",
"register": {
"heading": "You can's register yourself",
"subHeading": "Only doctors can register you as an user.",
"bookAppointment": "book your",
"bookAppointment2": "appointment",
"bookAppointment3": "with doctor and get treatment."
}
}
}
27 changes: 17 additions & 10 deletions src/app/[lang]/(front-end)/(user-auth)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,26 @@ import { Home } from "@/components/icons";
import Image from "next/image";
import { ReactNode } from "react";

import OT from "@/assets/images/OT.webp";
import { LinkTo, Logo } from "@/components";
import Link from "next/link";
import { ShowMatchRoute } from "./ShowMatchRoute";
import { getDictionary } from "@/Internationalization";

export async function generateStaticParams() {
return [{ lang: "bn" }, { lang: "en" }];
}

const Auth = ({ children }: { children: ReactNode }) => {
interface Props {
children: ReactNode;
params: { lang: string };
}

const Auth = async ({ children, params }: Props) => {
const dictionary = await getDictionary(params.lang, "useAuth");

return (
<section
className="relative grid grid-cols-1 items-center justify-center p-4 md:grid-cols-2 h-full"
className="relative grid h-full grid-cols-1 items-center justify-center p-4 md:grid-cols-2"
aria-label="patient login"
>
<Link
Expand All @@ -36,8 +43,8 @@ const Auth = ({ children }: { children: ReactNode }) => {
/>
</div>

<div className="container mx-auto flex min-h-[70vh] h-full items-center justify-center px-6 dark:bg-gray-900 w-full">
<div className="w-full max-w-md 2xl:max-w-2xl mx-auto">
<div className="container mx-auto flex h-full min-h-[70vh] w-full items-center justify-center px-6 dark:bg-gray-900">
<div className="mx-auto w-full max-w-md 2xl:max-w-2xl">
<div className="mx-auto flex justify-center">
<Logo
href={"/"}
Expand All @@ -47,12 +54,12 @@ const Auth = ({ children }: { children: ReactNode }) => {
</div>
<ShowMatchRoute />
{children}
<p className="mt-4 text-center 2xl:text-2xl">
Are you a doctor?
<LinkTo href={"/admin"} className="mx-1 text-main-400 ">
login here
<p className="mt-4 text-center 2xl:text-2xl">
{dictionary?.areYouDoctor}
<LinkTo href={"/admin"} className="mx-1 text-main-400">
{dictionary?.loginHere}
</LinkTo>
as a doctor.
{dictionary?.asDoctor}
</p>
</div>
</div>
Expand Down
70 changes: 70 additions & 0 deletions src/app/[lang]/(front-end)/(user-auth)/login/logInForm.tsx
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>
);
};
80 changes: 18 additions & 62 deletions src/app/[lang]/(front-end)/(user-auth)/login/page.tsx
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" }];
}
27 changes: 18 additions & 9 deletions src/app/[lang]/(front-end)/(user-auth)/register/page.tsx
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;
7 changes: 4 additions & 3 deletions src/app/[lang]/(front-end)/about-us/AboutFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react";
import Link from "next/link";
import { convertEnglishToBengaliNumber } from "@/utils";
import { getDictionary } from "@/Internationalization";
import { LinkTo } from "@/components";

interface Props {
lang: string;
Expand Down Expand Up @@ -36,14 +37,14 @@ const AboutFooter = async ({ lang, ...props }: Props) => {
</p>
<nav className="flex gap-4 sm:ml-auto sm:gap-6">
{menuItems.map((items) => (
<Link
<LinkTo
key={items.href}
className="text-xs underline-offset-4 hover:underline 2xl:text-xl"
href={items.href}
rel="ugc"
// rel="ugc"
>
{items.label}
</Link>
</LinkTo>
))}
</nav>
</footer>
Expand Down
5 changes: 2 additions & 3 deletions src/components/sections/Nav/LargeNav.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use client";

import Link from "next/link";
import { usePathname } from "next/navigation";
import React from "react";

Expand Down Expand Up @@ -34,7 +33,7 @@ export const LargeNav = ({ rootMenuItems, login, ...props }: Props) => {
return (
<div className={cn(props.className)} {...props}>
{rootMenuItems.map((item, index) => (
<Link
<LinkTo
key={index}
className={cn(
`mx-3 flex items-center text-deepBlue-100 2xl:text-2xl ${HindSiliguri.className}`,
Expand All @@ -44,7 +43,7 @@ export const LargeNav = ({ rootMenuItems, login, ...props }: Props) => {
href={item.href}
>
{item.label}
</Link>
</LinkTo>
))}

<LangSwitcher />
Expand Down
6 changes: 3 additions & 3 deletions src/components/sections/Nav/MobileNav.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use client";

import { AlignJustify } from "lucide-react";
import Link from "next/link";
import React from "react";

import {
Expand All @@ -14,6 +13,7 @@ import {
import { HindSiliguri, HindSiliguri600 } from "@/fonts";
import { cn } from "@/utils";
import { usePathname } from "next/navigation";
import { LinkTo } from "@/components/client";

interface Props extends React.ComponentProps<"div"> {
rootMenuItems: {
Expand All @@ -34,7 +34,7 @@ export const MobileNav = ({ rootMenuItems, ...props }: Props) => {
<DropdownMenuContent className="-translate-x-8">
{rootMenuItems.map((item, index) => (
<DropdownMenuItem key={index}>
<Link
<LinkTo
className={cn(
`mx-3 flex items-center text-deepBlue-100 ${HindSiliguri.className}`,
pathname === item.href &&
Expand All @@ -43,7 +43,7 @@ export const MobileNav = ({ rootMenuItems, ...props }: Props) => {
href={item.href}
>
{item.label}
</Link>
</LinkTo>
</DropdownMenuItem>
))}
</DropdownMenuContent>
Expand Down

0 comments on commit 3c529f2

Please sign in to comment.