diff --git a/frontend/src/pages/Doctor.tsx b/frontend/src/pages/Doctor.tsx index b84ee08..2b7ce0d 100644 --- a/frontend/src/pages/Doctor.tsx +++ b/frontend/src/pages/Doctor.tsx @@ -1,6 +1,6 @@ import { useState, useEffect, useCallback } from "react"; import { AxiosError } from "axios"; - +import { Eye } from "lucide-react"; import { BytescaleUploader } from "@/components/BytescaleUploader/BytescaleUploader"; import { @@ -60,6 +60,8 @@ const DAYS = [ ]; export default function DoctorPage() { + const WEBSITE_URL = import.meta.env.VITE_WEBSITE_URL; + const [doctors, setDoctors] = useState([]); const [departments, setDepartments] = useState([]); const [loading, setLoading] = useState(true); @@ -100,6 +102,8 @@ export default function DoctorPage() { slug: "", tags: [], }); + const [openOgPreview, setOpenOgPreview] = useState(false); + const [previewDoctor, setPreviewDoctor] = useState(null); const fetchAll = useCallback(async () => { setLoading(true); @@ -316,7 +320,10 @@ export default function DoctorPage() { } } - console.log("Current form state:", form); // Debug log to check form state + function handlePreview(doc: any) { + setPreviewDoctor(doc); + setOpenOgPreview(true); + } async function handleSubmit() { try { @@ -332,6 +339,24 @@ export default function DoctorPage() { } } + const createSlug = (text: string) => { + if (!text) return ""; + + return text + .toString() + .toLowerCase() + .trim() + .replace(/\s+/g, "-") + .replace(/[^\w-]+/g, "") + .replace(/--+/g, "-"); + }; + + const getDoctorUrl = (doctor: any) => { + const slug = doctor?.seo?.slug || createSlug(doctor?.name); + + return `${WEBSITE_URL}/${doctor?.doctorId}/${slug}`; + }; + return (
@@ -492,6 +517,14 @@ export default function DoctorPage() {
+
); }