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 (
{postings.length} job postings
No positions found