Backend modules from tastefully 8bd93d15: core-libs, core-session, api-gateway, mobile-api, services-auth, services-system, services-counter, services-member, services-log, services-email. solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal from tastefully 8bd93d15. Copied as tracked files only. Literal secrets replaced with environment placeholders: - services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY, MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default) - services-system: JUMIO_TOKEN, JUMIO_SECRET (optional) - services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed - core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default removed, ipgeolocation key read from IPGEOLOCATION_API_KEY - services-system EkycAppConfig: commented Jumio credentials removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
122 lines
4.5 KiB
TypeScript
122 lines
4.5 KiB
TypeScript
"use client";
|
|
|
|
import { useState } from "react";
|
|
import { motion, AnimatePresence } from "framer-motion";
|
|
import { Download, CheckCircle2, X } from "lucide-react";
|
|
import { type GalleryImage } from "./ImageGallery";
|
|
|
|
/** Trigger a browser download for a gallery image (no-op when it has no src). */
|
|
/** True when the src URL path (query string ignored) ends in .pdf. */
|
|
export function isPdfSrc(src?: string): boolean {
|
|
if (!src) return false;
|
|
try {
|
|
return new URL(src, "http://localhost").pathname.toLowerCase().endsWith(".pdf");
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
export function downloadGalleryImage(img: GalleryImage) {
|
|
if (!img.src) return;
|
|
const a = document.createElement("a");
|
|
a.href = img.src;
|
|
a.download = `${img.title.replace(/\s+/g, "_").toLowerCase()}.${isPdfSrc(img.src) ? "pdf" : "png"}`;
|
|
a.target = "_blank";
|
|
document.body.appendChild(a);
|
|
a.click();
|
|
document.body.removeChild(a);
|
|
}
|
|
|
|
interface Props {
|
|
/** image to preview; null closes the lightbox */
|
|
image: GalleryImage | null;
|
|
onClose: () => void;
|
|
}
|
|
|
|
/** Fullscreen image preview overlay with a download action. */
|
|
export default function ImageLightbox({ image, onClose }: Props) {
|
|
const [saved, setSaved] = useState(false);
|
|
|
|
const handleDownload = () => {
|
|
if (image) downloadGalleryImage(image);
|
|
setSaved(true);
|
|
setTimeout(() => setSaved(false), 2200);
|
|
};
|
|
|
|
return (
|
|
<AnimatePresence>
|
|
{image && (
|
|
<>
|
|
<motion.div
|
|
initial={{ opacity: 0 }}
|
|
animate={{ opacity: 1 }}
|
|
exit={{ opacity: 0 }}
|
|
onClick={onClose}
|
|
className="fixed inset-0 z-[60]"
|
|
style={{ background: "rgba(0,0,0,0.85)", backdropFilter: "blur(12px)" }}
|
|
/>
|
|
<motion.div
|
|
initial={{ opacity: 0, scale: 0.88 }}
|
|
animate={{ opacity: 1, scale: 1 }}
|
|
exit={{ opacity: 0, scale: 0.92 }}
|
|
transition={{ type: "spring", stiffness: 340, damping: 28 }}
|
|
className="fixed inset-4 z-[60] flex flex-col items-center justify-center"
|
|
onClick={onClose}
|
|
>
|
|
{/* Close */}
|
|
<motion.button
|
|
whileTap={{ scale: 0.85 }}
|
|
className="absolute top-2 right-2 w-10 h-10 rounded-full flex items-center justify-center z-10"
|
|
style={{ background: "rgba(255,255,255,0.1)", border: "1px solid rgba(255,255,255,0.2)" }}
|
|
>
|
|
<X strokeWidth={2} className="w-5 h-5 stroke-white" />
|
|
</motion.button>
|
|
|
|
{/* Image — natural ratio, full modal width, height auto */}
|
|
<div className="w-full rounded-2xl overflow-hidden">
|
|
{image.src ? (
|
|
// eslint-disable-next-line @next/next/no-img-element -- arbitrary remote image URLs; next/image would require per-host remotePatterns config and fixed dimensions.
|
|
<img
|
|
src={image.src}
|
|
alt={image.title}
|
|
className="w-full h-auto block"
|
|
style={{ maxHeight: "75vh", objectFit: "contain" }}
|
|
/>
|
|
) : (
|
|
<div
|
|
className="w-full flex items-center justify-center relative"
|
|
style={{ background: image.gradient, aspectRatio: "16 / 10" }}
|
|
>
|
|
<div className="absolute inset-0 stripe-animate opacity-20 pointer-events-none" />
|
|
<p className="text-2xl font-extrabold text-white/60">{image.title}</p>
|
|
</div>
|
|
)}
|
|
</div>
|
|
|
|
{/* Title + download */}
|
|
<div className="flex items-center gap-3 mt-4">
|
|
<p className="text-sm font-bold text-white">{image.title}</p>
|
|
<motion.button
|
|
onClick={(e) => { e.stopPropagation(); handleDownload(); }}
|
|
whileTap={{ scale: 0.9 }}
|
|
className="flex items-center gap-1.5 px-3 py-2 rounded-xl text-xs font-bold"
|
|
style={{
|
|
background: saved ? "rgba(34,197,94,0.2)" : "rgba(255,107,0,0.2)",
|
|
border: `1px solid ${saved ? "rgba(34,197,94,0.4)" : "rgba(255,107,0,0.4)"}`,
|
|
color: saved ? "#22c55e" : "#FF6B00",
|
|
}}
|
|
>
|
|
{saved ? (
|
|
<><CheckCircle2 strokeWidth={2} className="w-3.5 h-3.5" /> Saved</>
|
|
) : (
|
|
<><Download strokeWidth={2} className="w-3.5 h-3.5" /> View</>
|
|
)}
|
|
</motion.button>
|
|
</div>
|
|
</motion.div>
|
|
</>
|
|
)}
|
|
</AnimatePresence>
|
|
);
|
|
}
|