Skip to content

Commit

Permalink
feat: added doctors list
Browse files Browse the repository at this point in the history
  • Loading branch information
yeasin2002 committed Aug 22, 2024
1 parent 46be3b2 commit 2257ad0
Show file tree
Hide file tree
Showing 33 changed files with 307 additions and 91 deletions.
4 changes: 2 additions & 2 deletions global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import mongoose from "mongoose";
import globalThisType from "globalthis";

declare global {
var mongoose: typeof mongoose;
var globalThis: globalThisType;
const mongoose: typeof mongoose;
const globalThis: globalThisType;

type InternationalizationType =
| typeof bdLanguage
Expand Down
13 changes: 9 additions & 4 deletions src/Internationalization/languages/bn.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"global": {
"name": "Rima's Dental",
"name": "রিমা'স ডেন্টাল",
"login": "লগইন",
"register": "রেজিস্টার"
},
Expand All @@ -23,7 +23,8 @@
"home": "হোম",
"about_us": "আমাদের সম্পর্কে",
"services": "সার্ভিসসমূহ",
"login": "লগইন"
"login": "লগইন",
"dashboard": "ড্যাশবোর্ড"
},
"home": {
"hero": {
Expand Down Expand Up @@ -62,7 +63,11 @@
"footerInfo": {
"contact": {
"title": "যোগাযোগ",
"value": ["০১৭৩১-৫১৯০২৫", "০১৫৩৩-৮৮১১০২", "০১৬৭৯-১১২৭২৫"]
"value": [
"০১৭৩১-৫১৯০২৫",
"০১৫৩৩-৮৮১১০২",
"০১৬৭৯-১১২৭২৫"
]
},
"address": {
"title": "ঠিকানা",
Expand Down Expand Up @@ -136,4 +141,4 @@
"bookAppointment3": "ডাক্তারদের সাথে চিকিৎসা নিতে "
}
}
}
}
17 changes: 11 additions & 6 deletions src/Internationalization/languages/en.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"global": {
"name": "রিমা'স ডেন্টাল",
"login": "লগইন",
"register": "রেজিস্টার"
"name": "Rima's Dental",
"login": "Login",
"register": "Register"
},
"shared": {
"appointment": {
Expand All @@ -23,7 +23,8 @@
"home": "Home",
"about_us": "About us",
"services": "Services",
"login": "Login"
"login": "Login",
"dashboard": "Dashboard"
},
"home": {
"hero": {
Expand Down Expand Up @@ -62,7 +63,11 @@
"footerInfo": {
"contact": {
"title": "Contact",
"value": ["01731-519025", "01533-881102", "01679-112725"]
"value": [
"01731-519025",
"01533-881102",
"01679-112725"
]
},
"address": {
"title": "Address",
Expand Down Expand Up @@ -135,4 +140,4 @@
"bookAppointment3": "with doctor and get treatment."
}
}
}
}
File renamed without changes.
2 changes: 2 additions & 0 deletions src/actions/auth.actions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./doctor-auth.action";
export * from "./patient-auth.actions";
File renamed without changes.
3 changes: 3 additions & 0 deletions src/actions/doctors.actions/doctor-mutations.actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use server";

export const updatePendingDoctors = () => {};
25 changes: 25 additions & 0 deletions src/actions/doctors.actions/doctor-queries.actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"use server";

import { db } from "@/model";
import { Doctor } from "@/types";

export const getAllDoctors = async () => {
try {
await db.connectDB();
const doctors: Doctor[] =
(await db.Doctors.find({ isPending: false }).lean()) || [];
const pendingDoctors: Doctor[] =
(await db.Doctors.find({ isPending: true }).lean()) || [];

return {
success: true,
message: "success",
data: { doctors, pendingDoctors },
};
} catch (error: any) {
return {
success: false,
message: error.message,
};
}
};
2 changes: 2 additions & 0 deletions src/actions/doctors.actions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./doctor-queries.actions";
export * from "./doctor-mutations.actions";
2 changes: 0 additions & 2 deletions src/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
export * from "./patient-auth.actions";
export * from "./sendingEmail.action";
export * from "./utils.actions";
export * from "./doctor-auth.action";
2 changes: 1 addition & 1 deletion src/app/[lang]/(front-end)/(user-auth)/login/logInForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useForm } from "react-hook-form";
import Swal from "sweetalert2";
import toast from "react-hot-toast";

import { loginPatient_server } from "@/actions";
import { loginPatient_server } from "@/actions/auth.actions";
import { Email, InputCombo, InputComboForPassword, Lock } from "@/components";
import { loginFormSchema } from "@/schema";
import { loginFormData } from "@/types";
Expand Down
8 changes: 6 additions & 2 deletions src/app/[lang]/(front-end)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Nav } from "@/components";
import { getDictionary } from "@/Internationalization";
import { authSession } from "@/lib/auth";
import React from "react";
import { auth } from "@/auth";

const FrontEndLayout = async ({
children,
Expand All @@ -11,12 +12,15 @@ const FrontEndLayout = async ({
params: { lang: string };
}>) => {
const dic = await getDictionary(params.lang, "root_menu");
const doctorSession = await auth();
const session = await authSession.getSession();
console.log("🚀 ~ Patient Session:", session);

// console.log("🚀 ~ doctor session:", doctorSession);
// console.log("🚀 ~Patient session:", session);

return (
<>
<Nav dictionary={dic} />
<Nav dictionary={dic} doctorSession={doctorSession} />
{children}
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const Doctors = () => {
</div>
</div>
<div className="mt-10 grid grid-cols-2 gap-2 md:gap-x-8 lg:gap-x-10 xl:gap-x-14">
<DoctorsCards className="max-w-full" imageClassName="h-80" />
<DoctorsCards className="max-w-full" imageClassName="h-80" />
{/* <DoctorsCards className="max-w-full" imageClassName="h-80" /> */}
{/* <DoctorsCards className="max-w-full" imageClassName="h-80" /> */}
</div>
</section>
</div>
Expand Down
50 changes: 50 additions & 0 deletions src/app/[lang]/admin/(dashboard)/doctors/ShowDoctorList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React from "react";
import { Button, DoctorsCards } from "@/components";
import { Doctor } from "@/types";

import virusDisinfection from "@/assets/images/VirusDisinfection.gif";
import Image from "next/image";

interface Props extends React.ComponentProps<"div"> {
doctors: Doctor[];
}

export const ShowDoctorList = ({ doctors, ...props }: Props) => {
return (
<section className="p-4" {...props}>
<div className="mt-2">
<div>
<h1 className="font-grotesk text-4xl font-bold text-main-400 sm:text-5xl md:text-6xl lg:text-7xl">
Doctors
</h1>
<p> Your Devoted and Knowledgeable Doctors</p>
</div>
</div>
<div>
{doctors.length === 0 ? (
<div className="flex flex-col items-center justify-center">
<Image
src={virusDisinfection}
alt="No Doctor"
className="size-72"
/>
<p className="font-grotesk text-xl font-bold text-zinc-800 sm:text-2xl md:text-3xl lg:text-4xl">
No doctors found
</p>
</div>
) : (
<div className="grid grid-cols-2 gap-x-4">
{doctors.map((doctor) => (
<DoctorsCards
className="max-w-full"
imageClassName={"h-96"}
key={doctor._id}
data= {doctor}
/>
))}
</div>
)}
</div>
</section>
);
};
33 changes: 33 additions & 0 deletions src/app/[lang]/admin/(dashboard)/doctors/ShowPendingDoctors.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from "react";
import { Button, DoctorsCards } from "@/components";
import { Doctor } from "@/types";

interface Props extends React.ComponentProps<"div"> {
doctors: Doctor[];
}

export const ShowPendingDoctorList = ({ doctors, ...props }: Props) => {
if (doctors.length == 0) return "";
return (
<section className="p-4" {...props}>
<div className="mt-2">
<div>
<h1 className="font-grotesk text-4xl font-bold text-main-400 sm:text-5xl md:text-6xl lg:text-7xl">
Pending Doctors
</h1>
<p>Who registered as a doctor</p>
</div>
</div>
<div className="mt-10 grid grid-cols-2 gap-x-4">
{doctors.map((doctor) => (
<DoctorsCards
className="max-w-full"
imageClassName={"h-96"}
key={doctor._id}
data= {doctor}
/>
))}
</div>
</section>
);
};
18 changes: 18 additions & 0 deletions src/app/[lang]/admin/(dashboard)/doctors/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { getAllDoctors } from "@/actions/doctors.actions/doctor-queries.actions";

import React from "react";
import { ShowDoctorList } from "./ShowDoctorList";
import { ShowPendingDoctorList } from "./ShowPendingDoctors";

const Doctors = async () => {
const data = await getAllDoctors();

return (
<div>
<ShowDoctorList doctors={data?.data?.doctors!} />
<ShowPendingDoctorList doctors={data?.data?.pendingDoctors!} />
</div>
);
};

export default Doctors;
2 changes: 1 addition & 1 deletion src/app/[lang]/admin/(dashboard)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DashboardAnalytics, DashboardStates } from "@/components/dashboard";

const Admin = () => {
const Admin = async () => {
return (
<section className="space-y-16 px-4 py-2">
<DashboardStates />
Expand Down
2 changes: 1 addition & 1 deletion src/app/[lang]/admin/(doctors-auth)/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import toast from "react-hot-toast";
import { useParams, useRouter } from "next/navigation";

import { loginFormSchema } from "@/schema";
import { loginWithAuthJs } from "@/actions";
import { loginWithAuthJs } from "@/actions/auth.actions";
import { loginFormData } from "@/types";
import {
Email,
Expand Down
2 changes: 1 addition & 1 deletion src/app/[lang]/admin/(doctors-auth)/register/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
import { registerFormSchema } from "@/schema";
import { cn } from "@/utils";
import { registerFormData } from "@/types";
import { loginWithAuthJs, registerDoctor_server } from "@/actions";
import { loginWithAuthJs, registerDoctor_server } from "@/actions/auth.actions";

const Register = () => {
const router = useRouter();
Expand Down
Binary file added src/assets/images/VirusDisinfection.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions src/components/Cards/TeamCard.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import React from "react";
interface Props extends React.ComponentProps<"div"> {}
interface Props extends React.ComponentProps<"div"> {
doctor: Doctor;
}

import doctorIcon from "@/assets/temp/doctor-3.jpg";
import { FacebookLogo, WhatsappLogo } from "@/components/icons";
import Image from "next/image";
import { Doctor } from "@/types";

export const TeamCard = (props: Props) => {
export const TeamCard = ({ doctor, ...props }: Props) => {
return (
<div
{...props}
Expand Down
2 changes: 1 addition & 1 deletion src/components/dashboard/DashboardNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet";
import { Doctor02, LinkTo } from "@/components";
import { dashboardNav } from "@/data/navItems";
import { cn } from "@/utils";
import { logoutWithAuthJs } from "@/actions";
import { logoutWithAuthJs } from "@/actions/auth.actions";

interface Props extends React.ComponentProps<"div"> {}

Expand Down
Loading

0 comments on commit 2257ad0

Please sign in to comment.