import React, { useState, useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; import { Search, Plus } from 'lucide-react'; import { useJobPostings, useApplications } from '@/lib/krowHooks'; import { base44 } from '@/api/base44Client'; import KROWJobPostingCard from '@/components/krow/KROWJobPostingCard'; import CertificationManager from '@/components/krow/CertificationManager'; export default function Positions() { const navigate = useNavigate(); const { data: postings = [], isLoading } = useJobPostings(); const { data: applications = [] } = useApplications(); const [search, setSearch] = useState(''); const [statusFilter, setStatusFilter] = useState('all'); const [isAdmin, setIsAdmin] = useState(false); useEffect(() => { base44.auth.me().then(u => setIsAdmin(u?.role === 'admin')).catch(() => {}); }, []); const filtered = postings.filter(p => { const matchesSearch = !search || p.title.toLowerCase().includes(search.toLowerCase()) || p.role_category?.toLowerCase().includes(search.toLowerCase()); const matchesStatus = statusFilter === 'all' || p.status === statusFilter; return matchesSearch && matchesStatus; }); const statsForPosting = (postingId) => { const apps = applications.filter(a => a.job_posting_id === postingId); return { applied: apps.length, screened: apps.filter(a => a.status !== 'applied').length, hired: apps.filter(a => a.status === 'hired').length, }; }; return (

Positions

{postings.length} job postings

{/* Action Bar */}
setSearch(e.target.value)} placeholder="Search positions..." className="w-full h-9 pl-10 pr-4 rounded-full border border-[#E5E7EB] bg-white text-[13px] text-[#111827] shadow-2xs hover:border-[#D1D5DB] focus:border-[#2563EB] focus:ring-2 focus:ring-[#2563EB]/20 focus:outline-none transition-all" />
{isAdmin && }
{/* Grid */} {isLoading ? (
{[...Array(6)].map((_, i) =>
)}
) : filtered.length === 0 ? (

No positions found

) : (
{filtered.map(posting => ( ))}
)}
); }