import React from 'react'; import ReactDOM from 'react-dom'; import { motion, AnimatePresence } from 'framer-motion'; // --- Icons --- const BuildingIcon = () => (); const LocationIcon = () => (); const MoneyIcon = () => (); const CloseIcon = () => (); const CheckIcon = () => (); const JobDetail = ({ job, onClose, onApply, isApplied, isApplying }) => { // Determine if the job is expired based on the deadline string const isExpired = React.useMemo(() => { if (!job || !job.deadline || job.deadline === 'Open') return false; const deadlineDate = new Date(job.deadline); const today = new Date(); today.setHours(0, 0, 0, 0); return deadlineDate < today; }, [job]); // Portal renders this outside the main app flow return ReactDOM.createPortal( {job && ( e.stopPropagation()} > {/* Modal Header */} {job.title} {job.company} {/* Modal Content */} {job.location} {job.salary} {job.type} About the Role {job.description || "No description provided."} {/* Safe Skills Rendering */} {job.skills && job.skills.length > 0 && ( <> Skills Required {job.skills.map((skill, index) => ( {skill} ))} > )} Posted: {job.postedAt} • Deadline: {job.deadline} {/* Modal Footer */} Close {/* Logic for Apply Button */} {isApplied ? ( Applied ) : ( onApply && onApply(job.id)} disabled={isApplying || isExpired} style={{ padding: '0.75rem 2rem', backgroundColor: (isApplying || isExpired) ? '#4b5563' : '#FBBF24', color: (isApplying || isExpired) ? '#d1d5db' : '#1a202c', border: 'none', borderRadius: '0.5rem', fontWeight: 'bold', cursor: (isApplying || isExpired) ? 'not-allowed' : 'pointer' }} > {isApplying ? 'Applying...' : (isExpired ? 'Expired' : 'Apply Now')} )} )} , document.body ); }; export default JobDetail;
{job.description || "No description provided."}