diff --git a/frontend/src/components/SeoPreview/SeoPreview.tsx b/frontend/src/components/SeoPreview/SeoPreview.tsx index 84139ca..bb7268d 100644 --- a/frontend/src/components/SeoPreview/SeoPreview.tsx +++ b/frontend/src/components/SeoPreview/SeoPreview.tsx @@ -1,131 +1,159 @@ -import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog"; +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; + 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; + open: boolean; + onOpenChange: (open: boolean) => void; + previewData?: SeoPreviewData | null; + url?: string; + title?: string; } export default function SeoPreview({ - open, - onOpenChange, - previewData, - url, - title = "SEO Preview", + 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"; + const previewUrl = url || "#"; - return ( - - - - {title} - + const hasSeoData = + !!previewData?.seo && + !!( + previewData.seo.ogImage || + previewData.seo.ogTitle || + previewData.seo.seoTitle || + previewData.seo.ogDescription || + previewData.seo.metaDescription + ); - {previewData ? ( - - - - Social Media Preview (WhatsApp / Facebook) - + const imageUrl = + previewData?.seo?.ogImage || + "https://placehold.co/1200x630?text=GG+Hospital"; - - - - + const ogTitle = + previewData?.seo?.ogTitle || previewData?.seo?.seoTitle || "GG Hospital"; - - - gg-hospital.com - + const ogDescription = + previewData?.seo?.ogDescription || + previewData?.seo?.metaDescription || + "No description available"; - - {ogTitle} - + const searchTitle = + previewData?.seo?.seoTitle || + previewData?.seo?.ogTitle || + "SEO title preview"; - - {ogDescription} - - - - + const searchDescription = + previewData?.seo?.metaDescription || + previewData?.seo?.ogDescription || + "No meta description available"; - - - Google Search Preview - + return ( + + + + {title} + - - - - {previewUrl} - + {hasSeoData ? ( + + {/* Social Preview */} + + + Social Media Preview (WhatsApp / Facebook) + - - {searchTitle} - - + + + + - - {searchDescription} - - - - - ) : ( - - No preview data available. - - )} + + + gg-hospital.com + - - onOpenChange(false)}> - Close - - - - - ); + + {ogTitle} + + + + {ogDescription} + + + + + + {/* Google Preview */} + + + Google Search Preview + + + + + + {previewUrl} + + + + {searchTitle} + + + + + {searchDescription} + + + + + ) : ( + + No preview data available. + + )} + + + onOpenChange(false)}> + Close + + + + + ); } diff --git a/frontend/src/pages/HealthPackagePage.tsx b/frontend/src/pages/HealthPackagePage.tsx index 8f83d20..ab8e287 100644 --- a/frontend/src/pages/HealthPackagePage.tsx +++ b/frontend/src/pages/HealthPackagePage.tsx @@ -9,13 +9,13 @@ import { createHealthPackageApi, createCategoryApi, updateCategoryApi, - deleteCategoryApi, HealthPackage, HealthCategory, } from "@/api/healthCheck"; import PackageInquiriesTab from "@/components/PackageInquiriesTab/PackageInquiriesTab"; import HealthPackageModal from "@/components/HealthPackageModal/HealthPackageModal"; +import SeoPreview from "@/components/SeoPreview/SeoPreview"; import { Table, @@ -771,86 +771,12 @@ export default function HealthPackagePage() { - {/* --- VIEW MODAL --- */} - - - - - {selectedPackage?.name} - - - - - - - Category - - - {selectedPackage?.category?.name} - - - - - Pricing - - - {selectedPackage?.discountedPrice != null - ? `₹${selectedPackage.discountedPrice}` - : selectedPackage?.price != null - ? `₹${selectedPackage.price}` - : "Not Entered"} - - - - - - Inclusions - - - {selectedPackage?.inclusions && - typeof selectedPackage.inclusions === "object" && - !Array.isArray(selectedPackage.inclusions) ? ( - Object.entries(selectedPackage.inclusions).map( - ([category, tests], idx) => ( - - - {category} - - - {Array.isArray(tests) && - tests.map((item, i) => ( - - ✓ {item} - - ))} - - - ), - ) - ) : ( - - {Array.isArray(selectedPackage?.inclusions) && - selectedPackage.inclusions.map((item, i) => ( - - ✓ {item} - - ))} - - )} - - - - - setViewModal(false)}>Close - - - + ); }
- Social Media Preview (WhatsApp / Facebook) -
- gg-hospital.com -
- {ogDescription} -
- Google Search Preview -
- {previewUrl} -
+ Social Media Preview (WhatsApp / Facebook) +
- {searchDescription} -
+ gg-hospital.com +
+ {ogDescription} +
+ Google Search Preview +
+ {previewUrl} +
+ {searchDescription} +
- Category -
- {selectedPackage?.category?.name} -
- Pricing -
- {selectedPackage?.discountedPrice != null - ? `₹${selectedPackage.discountedPrice}` - : selectedPackage?.price != null - ? `₹${selectedPackage.price}` - : "Not Entered"} -