import React, { useEffect, useState } from 'react'; import { Link, useNavigate } from 'react-router-dom'; import apiFetch from '../auth/apiFetch.js'; export default function CareerProfileList() { const [rows, setRows] = useState([]); const nav = useNavigate(); useEffect(() => { (async () => { try { const r = await apiFetch('/api/premium/career-profile/all'); if (!r.ok) { // apiFetch already fires session-expired on 401/403, just bail return; } const d = await r.json(); setRows(d.careerProfiles || []); } catch (e) { console.error('Failed to load career profiles:', e); } })(); }, []); async function remove(row) { if (!window.confirm('Delete this career profile?')) return; try { const r = await apiFetch(`/api/premium/career-profile/${encodeURIComponent(row.id)}`, { method: 'DELETE' }); if (!r.ok) { // 401/403 handled by apiFetch const msg = await r.text().catch(() => 'Failed to delete'); alert(msg || 'Failed to delete'); return; } setRows(prev => prev.filter(x => x.id !== row.id)); } catch (e) { console.error('Delete failed:', e); alert('Failed to delete'); } } return (

Career Profiles

{rows.map(r => ( ))} {rows.length === 0 && ( )}
Title Status Start
{r.scenario_title || r.career_name} {r.status} {r.start_date} edit

No career profiles yet.

Start Premium Onboarding
); }