|
| 1 | +"use client"; |
| 2 | +import { useState, useEffect } from "react"; |
| 3 | +import { motion, AnimatePresence } from "framer-motion"; |
| 4 | +import { |
| 5 | + FiArrowLeft, FiCheck, FiEye, FiDownload, FiX, FiFileText, FiBookOpen, |
| 6 | +} from "react-icons/fi"; |
| 7 | +import { trainingDetails, profile } from "@/data/portfolio"; |
| 8 | +import RateCard from "@/components/RateCard"; |
| 9 | + |
| 10 | +/* -------- material preview modal (cert-style) -------- */ |
| 11 | +function MaterialModal({ item, onClose }) { |
| 12 | + const isPdf = item?.type === "pdf" || item?.file?.toLowerCase().endsWith(".pdf"); |
| 13 | + useEffect(() => { |
| 14 | + const onKey = (e) => e.key === "Escape" && onClose(); |
| 15 | + document.addEventListener("keydown", onKey); |
| 16 | + document.body.style.overflow = "hidden"; |
| 17 | + return () => { |
| 18 | + document.removeEventListener("keydown", onKey); |
| 19 | + document.body.style.overflow = ""; |
| 20 | + }; |
| 21 | + }, [onClose]); |
| 22 | + |
| 23 | + return ( |
| 24 | + <motion.div |
| 25 | + initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} |
| 26 | + onClick={onClose} |
| 27 | + className="fixed inset-0 z-[100] flex items-center justify-center p-4 bg-black/70 backdrop-blur-sm" |
| 28 | + > |
| 29 | + <motion.div |
| 30 | + initial={{ scale: 0.94, y: 12, opacity: 0 }} |
| 31 | + animate={{ scale: 1, y: 0, opacity: 1 }} |
| 32 | + exit={{ scale: 0.94, y: 12, opacity: 0 }} |
| 33 | + transition={{ type: "spring", stiffness: 260, damping: 24 }} |
| 34 | + onClick={(e) => e.stopPropagation()} |
| 35 | + className="relative w-full max-w-3xl glass rounded-2xl border border-line overflow-hidden" |
| 36 | + > |
| 37 | + <div className="flex items-start justify-between gap-4 p-5 border-b border-line"> |
| 38 | + <div className="min-w-0"> |
| 39 | + <h3 className="font-bold truncate">{item.name}</h3> |
| 40 | + {item.detail && <p className="text-xs text-muted truncate">{item.detail}</p>} |
| 41 | + </div> |
| 42 | + <button data-hover onClick={onClose} aria-label="Close" |
| 43 | + className="w-9 h-9 shrink-0 rounded-full border border-line flex items-center justify-center hover:border-accent hover:text-accent transition-colors"> |
| 44 | + <FiX size={18} /> |
| 45 | + </button> |
| 46 | + </div> |
| 47 | + |
| 48 | + <div className="p-5"> |
| 49 | + {isPdf ? ( |
| 50 | + <object data={item.file} type="application/pdf" className="w-full h-[65vh] rounded-lg bg-white"> |
| 51 | + <p className="text-muted text-sm"> |
| 52 | + Preview unavailable.{" "} |
| 53 | + <a href={item.file} target="_blank" rel="noopener noreferrer" className="text-accent hover:underline">Open PDF ↗</a> |
| 54 | + </p> |
| 55 | + </object> |
| 56 | + ) : ( |
| 57 | + /* eslint-disable-next-line @next/next/no-img-element */ |
| 58 | + <img src={item.file} alt={item.name} className="w-full max-h-[65vh] object-contain rounded-lg bg-white" /> |
| 59 | + )} |
| 60 | + </div> |
| 61 | + |
| 62 | + <div className="flex flex-wrap items-center justify-end gap-3 p-5 border-t border-line"> |
| 63 | + <a href={item.file} target="_blank" rel="noopener noreferrer" data-hover |
| 64 | + className="text-sm px-4 py-2 rounded-full border border-line hover:border-accent hover:text-accent transition-colors flex items-center gap-2"> |
| 65 | + <FiEye size={15} /> Open full |
| 66 | + </a> |
| 67 | + {item.downloadable && ( |
| 68 | + <a href={item.file} download data-hover |
| 69 | + className="text-sm px-4 py-2 rounded-full bg-accent text-bg font-semibold hover:opacity-90 transition flex items-center gap-2"> |
| 70 | + <FiDownload size={15} /> Download |
| 71 | + </a> |
| 72 | + )} |
| 73 | + </div> |
| 74 | + </motion.div> |
| 75 | + </motion.div> |
| 76 | + ); |
| 77 | +} |
| 78 | + |
| 79 | +export default function TrainingDetailsPage() { |
| 80 | + const [active, setActive] = useState(null); |
| 81 | + const d = trainingDetails; |
| 82 | + |
| 83 | + return ( |
| 84 | + <main className="min-h-screen"> |
| 85 | + {/* Hero + back link */} |
| 86 | + <section className="relative overflow-hidden pt-16 pb-14 border-b border-line"> |
| 87 | + <div className="pointer-events-none absolute inset-0 -z-10"> |
| 88 | + <div className="absolute top-0 right-1/4 w-80 h-80 rounded-full bg-accent/15 blur-3xl" /> |
| 89 | + </div> |
| 90 | + <div className="container"> |
| 91 | + <a href="/" data-hover |
| 92 | + className="inline-flex items-center gap-2 text-sm text-muted hover:text-accent transition-colors"> |
| 93 | + <FiArrowLeft size={16} /> Back to home |
| 94 | + </a> |
| 95 | + <h1 className="text-3xl sm:text-5xl font-extrabold mt-6">{d.heading}</h1> |
| 96 | + <p className="text-muted mt-4 max-w-2xl">{d.intro}</p> |
| 97 | + </div> |
| 98 | + </section> |
| 99 | + |
| 100 | + {/* Modules (simple list) + Outcomes */} |
| 101 | + <section className="py-16"> |
| 102 | + <div className="container grid md:grid-cols-2 gap-12"> |
| 103 | + <div> |
| 104 | + <h2 className="text-2xl font-bold mb-6 flex items-center gap-2"> |
| 105 | + <FiBookOpen className="text-accent" /> Course Modules |
| 106 | + </h2> |
| 107 | + <ul className="space-y-4"> |
| 108 | + {d.modules.map((m, i) => ( |
| 109 | + <motion.li key={m.title} |
| 110 | + initial={{ opacity: 0, x: -12 }} |
| 111 | + whileInView={{ opacity: 1, x: 0 }} |
| 112 | + viewport={{ once: true }} |
| 113 | + transition={{ duration: 0.4, delay: i * 0.05 }} |
| 114 | + className="flex gap-3"> |
| 115 | + <span className="mt-0.5 w-7 h-7 shrink-0 rounded-lg bg-gradient-to-br from-accent to-accent2 text-bg text-xs font-bold flex items-center justify-center"> |
| 116 | + {i + 1} |
| 117 | + </span> |
| 118 | + <div> |
| 119 | + <h3 className="font-semibold">{m.title}</h3> |
| 120 | + <p className="text-muted text-sm">{m.desc}</p> |
| 121 | + </div> |
| 122 | + </motion.li> |
| 123 | + ))} |
| 124 | + </ul> |
| 125 | + </div> |
| 126 | + |
| 127 | + <div> |
| 128 | + <h2 className="text-2xl font-bold mb-6">What You'll Be Able To Do</h2> |
| 129 | + <ul className="space-y-3"> |
| 130 | + {d.outcomes.map((o) => ( |
| 131 | + <li key={o} className="flex items-start gap-3 glass rounded-xl p-4"> |
| 132 | + <span className="mt-0.5 w-6 h-6 shrink-0 rounded-md bg-accent/15 text-accent flex items-center justify-center"> |
| 133 | + <FiCheck size={14} /> |
| 134 | + </span> |
| 135 | + <span className="text-sm">{o}</span> |
| 136 | + </li> |
| 137 | + ))} |
| 138 | + </ul> |
| 139 | + </div> |
| 140 | + </div> |
| 141 | + </section> |
| 142 | + |
| 143 | + {/* Materials — preview cards */} |
| 144 | + {d.materials?.length > 0 && ( |
| 145 | + <section className="py-16 border-t border-line"> |
| 146 | + <div className="container"> |
| 147 | + <h2 className="text-2xl font-bold mb-3">Training Materials</h2> |
| 148 | + <p className="text-muted mb-8 text-sm"> |
| 149 | + Click to preview. Samples only — full materials provided with booking. |
| 150 | + </p> |
| 151 | + <div className="grid sm:grid-cols-2 lg:grid-cols-3 gap-5"> |
| 152 | + {d.materials.map((m, i) => ( |
| 153 | + <motion.button |
| 154 | + key={m.name} type="button" data-hover |
| 155 | + onClick={() => setActive(m)} |
| 156 | + initial={{ opacity: 0, y: 20 }} |
| 157 | + whileInView={{ opacity: 1, y: 0 }} |
| 158 | + viewport={{ once: true }} |
| 159 | + transition={{ duration: 0.45, delay: i * 0.06 }} |
| 160 | + whileHover={{ y: -6 }} |
| 161 | + className="text-left glass rounded-2xl p-5 hover:border-accent/60 transition-colors" |
| 162 | + > |
| 163 | + <div className="flex items-center gap-3"> |
| 164 | + <span className="w-11 h-11 shrink-0 rounded-xl bg-gradient-to-br from-accent to-accent2 flex items-center justify-center text-bg"> |
| 165 | + <FiFileText size={20} /> |
| 166 | + </span> |
| 167 | + <div className="min-w-0"> |
| 168 | + <h3 className="font-semibold leading-tight">{m.name}</h3> |
| 169 | + {m.sample && ( |
| 170 | + <span className="text-[10px] font-mono px-2 py-0.5 rounded-full bg-accent/10 text-accent mt-1 inline-block"> |
| 171 | + SAMPLE |
| 172 | + </span> |
| 173 | + )} |
| 174 | + </div> |
| 175 | + </div> |
| 176 | + {m.detail && <p className="text-muted text-sm mt-3">{m.detail}</p>} |
| 177 | + <span className="mt-3 inline-flex items-center gap-1.5 text-xs font-medium text-accent"> |
| 178 | + <FiEye size={13} /> Preview |
| 179 | + </span> |
| 180 | + </motion.button> |
| 181 | + ))} |
| 182 | + </div> |
| 183 | + </div> |
| 184 | + </section> |
| 185 | + )} |
| 186 | + |
| 187 | + {/* Rate card (reused) */} |
| 188 | + <section className="py-16 border-t border-line"> |
| 189 | + <div className="container"> |
| 190 | + <h2 className="text-2xl sm:text-3xl font-bold mb-2">Training Options & Rates</h2> |
| 191 | + <p className="text-muted mb-10 text-sm">Pick the format that fits — book directly via WhatsApp or email.</p> |
| 192 | + <RateCard /> |
| 193 | + </div> |
| 194 | + </section> |
| 195 | + |
| 196 | + <footer className="py-10 border-t border-line text-center text-sm text-muted"> |
| 197 | + <a href="/" className="text-accent hover:underline">← Back to portfolio</a> |
| 198 | + </footer> |
| 199 | + |
| 200 | + <AnimatePresence> |
| 201 | + {active && <MaterialModal item={active} onClose={() => setActive(null)} />} |
| 202 | + </AnimatePresence> |
| 203 | + </main> |
| 204 | + ); |
| 205 | +} |
0 commit comments