From fa06126219b9be6319f2207bd27f2aa353b0859e Mon Sep 17 00:00:00 2001 From: rishalkv Date: Tue, 26 May 2026 11:38:34 +0530 Subject: [PATCH] chore: add seo reusable component --- .../src/components/SeoPreview/SeoPreview.tsx | 131 ++++++++++++++++++ frontend/src/pages/Doctor.tsx | 98 +------------ 2 files changed, 138 insertions(+), 91 deletions(-) create mode 100644 frontend/src/components/SeoPreview/SeoPreview.tsx diff --git a/frontend/src/components/SeoPreview/SeoPreview.tsx b/frontend/src/components/SeoPreview/SeoPreview.tsx new file mode 100644 index 0000000..84139ca --- /dev/null +++ b/frontend/src/components/SeoPreview/SeoPreview.tsx @@ -0,0 +1,131 @@ +import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog"; +import { Button } from "@/components/ui/button"; + +interface SeoPreviewData { + seo?: { + ogImage?: string; + ogTitle?: string; + seoTitle?: string; + ogDescription?: string; + metaDescription?: string; + slug?: string; + }; + doctorId?: string; + name?: string; +} + +interface SeoPreviewProps { + open: boolean; + onOpenChange: (open: boolean) => void; + previewData?: SeoPreviewData | null; + url?: string; + title?: string; +} + +export default function SeoPreview({ + open, + onOpenChange, + previewData, + url, + title = "SEO Preview", +}: SeoPreviewProps) { + const previewUrl = url || "#"; + const imageUrl = + previewData?.seo?.ogImage || "https://placehold.co/1200x630?text=GG+Hospital"; + const ogTitle = + previewData?.seo?.ogTitle || previewData?.seo?.seoTitle || "GG Hospital"; + const ogDescription = + previewData?.seo?.ogDescription || previewData?.seo?.metaDescription || + "No description available"; + const searchTitle = + previewData?.seo?.seoTitle || previewData?.seo?.ogTitle || "SEO title preview"; + const searchDescription = + previewData?.seo?.metaDescription || previewData?.seo?.ogDescription || + "No meta description available"; + + return ( + + + + {title} + + + {previewData ? ( +
+
+

+ Social Media Preview (WhatsApp / Facebook) +

+ + +
+ OG Preview +
+ +
+

+ gg-hospital.com +

+ +

+ {ogTitle} +

+ +

+ {ogDescription} +

+
+
+
+ +
+

+ Google Search Preview +

+ +
+ +

+ {previewUrl} +

+ +

+ {searchTitle} +

+
+ +

+ {searchDescription} +

+
+
+
+ ) : ( +
+ No preview data available. +
+ )} + + + + +
+
+ ); +} diff --git a/frontend/src/pages/Doctor.tsx b/frontend/src/pages/Doctor.tsx index 2b7ce0d..c127f6f 100644 --- a/frontend/src/pages/Doctor.tsx +++ b/frontend/src/pages/Doctor.tsx @@ -28,6 +28,7 @@ import { DialogTitle, DialogFooter, } from "@/components/ui/dialog"; +import SeoPreview from "@/components/SeoPreview/SeoPreview"; import { Input } from "@/components/ui/input"; import { Badge } from "@/components/ui/badge"; import { Switch } from "@/components/ui/switch"; @@ -1159,97 +1160,12 @@ export default function DoctorPage() { - - - - SEO Preview - - - {previewDoctor && ( -
- {/* SOCIAL MEDIA PREVIEW */} -
-

- Social Media Preview (WhatsApp / Facebook) -

- - - {/* IMAGE */} -
- OG Preview -
- - {/* CONTENT */} -
-

- gg-hospital.com -

- -

- {previewDoctor?.seo?.ogTitle || - previewDoctor?.seo?.seoTitle || - "GG Hospital"} -

- -

- {previewDoctor?.seo?.ogDescription || - previewDoctor?.seo?.metaDescription || - "No description available"} -

-
-
-
- - {/* GOOGLE SEARCH PREVIEW */} -
-

- Google Search Preview -

- -
- - {/* URL */} -

- {getDoctorUrl(previewDoctor)} -

- - {/* TITLE */} -

- {previewDoctor?.seo?.seoTitle || - previewDoctor?.seo?.ogTitle || - "SEO title preview"} -

-
- - {/* DESCRIPTION */} -

- {previewDoctor?.seo?.metaDescription || - previewDoctor?.seo?.ogDescription || - "No meta description available"} -

-
-
-
- )} -
-
+ ); }