"use client"; import { useState, useEffect } from "react"; import { JobPosition } from "@/lib/api/careerService"; import JobApplicationForm from "./JobApplicationForm"; interface JobSingleProps { job: JobPosition; } const JobSingle = ({ job }: JobSingleProps) => { const [showApplicationForm, setShowApplicationForm] = useState(false); // Prevent body scroll when modal is open useEffect(() => { if (showApplicationForm) { // Get scrollbar width to prevent layout shift const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth; // Save current scroll position const scrollY = window.scrollY; // Prevent background scroll document.body.style.position = 'fixed'; document.body.style.top = `-${scrollY}px`; document.body.style.left = '0'; document.body.style.right = '0'; document.body.style.overflow = 'hidden'; if (scrollbarWidth > 0) { document.body.style.paddingRight = `${scrollbarWidth}px`; } } else { // Get the scroll position from body top const scrollY = parseInt(document.body.style.top || '0') * -1; // Restore scroll document.body.style.position = ''; document.body.style.top = ''; document.body.style.left = ''; document.body.style.right = ''; document.body.style.overflow = ''; document.body.style.paddingRight = ''; // Restore scroll position window.scrollTo(0, scrollY); } // Cleanup on unmount return () => { const scrollY = parseInt(document.body.style.top || '0') * -1; document.body.style.position = ''; document.body.style.top = ''; document.body.style.left = ''; document.body.style.right = ''; document.body.style.overflow = ''; document.body.style.paddingRight = ''; if (scrollY > 0) { window.scrollTo(0, scrollY); } }; }, [showApplicationForm]); const formatSalary = () => { if (job.salary_min && job.salary_max) { return `${job.salary_currency} ${job.salary_min}-${job.salary_max} ${job.salary_period}`; } else if (job.salary_min) { return `From ${job.salary_currency} ${job.salary_min} ${job.salary_period}`; } else if (job.salary_max) { return `Up to ${job.salary_currency} ${job.salary_max} ${job.salary_period}`; } return "Competitive"; }; const scrollToForm = () => { setShowApplicationForm(true); setTimeout(() => { const formElement = document.getElementById('application-form'); if (formElement) { formElement.scrollIntoView({ behavior: 'smooth', block: 'start' }); } }, 100); }; return ( <> {/* Job Header Banner */}
{job.department || 'Career Opportunity'}

{job.title}

location_on {job.location}
work {job.employment_type.replace('-', ' ').replace(/\b\w/g, l => l.toUpperCase())} {job.employment_type.split('-')[0].charAt(0).toUpperCase() + job.employment_type.split('-')[0].slice(1)}
group {job.open_positions} {job.open_positions === 1 ? 'Position' : 'Positions'} {job.open_positions} {job.open_positions === 1 ? 'Pos' : 'Pos'}
{job.experience_required && (
school {job.experience_required}
)}
{/* Job Content Section */}

About This Position

{job.short_description && (

{job.short_description}

)}
{job.about_role && (
info

About This Role

{job.about_role}

)} {job.requirements && job.requirements.length > 0 && (
task_alt

Requirements

    {job.requirements.map((req, index) => (
  • {req}
  • ))}
)} {job.responsibilities && job.responsibilities.length > 0 && (
assignment

Key Responsibilities

    {job.responsibilities.map((resp, index) => (
  • {resp}
  • ))}
)} {job.qualifications && job.qualifications.length > 0 && (
workspace_premium

Qualifications

    {job.qualifications.map((qual, index) => (
  • {qual}
  • ))}
)} {job.bonus_points && job.bonus_points.length > 0 && (
stars

Nice to Have

    {job.bonus_points.map((bonus, index) => (
  • {bonus}
  • ))}
)} {job.benefits && job.benefits.length > 0 && (
card_giftcard

What We Offer

    {job.benefits.map((benefit, index) => (
  • {benefit}
  • ))}
)}
JOB DETAILS
payments

Salary Range

{formatSalary()}

{job.salary_additional && (

{job.salary_additional}

)}
work

Employment Type

{job.employment_type.replace('-', ' ').replace(/\b\w/g, l => l.toUpperCase())}

location_on

Location

{job.location}

event

Start Date

{job.start_date}

groups

Openings

{job.open_positions} {job.open_positions === 1 ? 'Position' : 'Positions'} Available

Application takes ~5 minutes ~5 min

{ e.currentTarget.style.backgroundColor = '#f5f5f5'; e.currentTarget.style.borderColor = '#667eea'; }} onMouseLeave={(e) => { e.currentTarget.style.backgroundColor = 'transparent'; e.currentTarget.style.borderColor = '#e0e0e0'; }} > arrow_back Back to Career Page Back
{/* Application Form Modal/Popup */} {showApplicationForm && ( <> {/* Backdrop Overlay */}
setShowApplicationForm(false)} aria-hidden="true" /> {/* Modal Container */}
{ // Close when clicking the container background if (e.target === e.currentTarget) { setShowApplicationForm(false); } }} onKeyDown={(e) => { // Close on ESC key if (e.key === 'Escape') { setShowApplicationForm(false); } }} ref={(el) => { if (el) { setTimeout(() => el.focus(), 100); } }} >
e.stopPropagation()} onTouchStart={(e) => e.stopPropagation()} onTouchMove={(e) => e.stopPropagation()} > setShowApplicationForm(false)} />
{/* Animation Styles */} )} ); }; export default JobSingle;