(project: ProcessedProject)
| 102 | }; |
| 103 | |
| 104 | const handleDelete = async (project: ProcessedProject) => { |
| 105 | if (!confirm(`Are you sure you want to delete project ${project.name}?`)) { |
| 106 | return; |
| 107 | } |
| 108 | try { |
| 109 | const response = await fetch('/api/wiki/projects', { |
| 110 | method: 'DELETE', |
| 111 | headers: { 'Content-Type': 'application/json' }, |
| 112 | body: JSON.stringify({ |
| 113 | owner: project.owner, |
| 114 | repo: project.repo, |
| 115 | repo_type: project.repo_type, |
| 116 | language: project.language, |
| 117 | }), |
| 118 | }); |
| 119 | if (!response.ok) { |
| 120 | const errorBody = await response.json().catch(() => ({ error: response.statusText })); |
| 121 | throw new Error(errorBody.error || response.statusText); |
| 122 | } |
| 123 | setProjects(prev => prev.filter(p => p.id !== project.id)); |
| 124 | } catch (e: unknown) { |
| 125 | console.error('Failed to delete project:', e); |
| 126 | alert(`Failed to delete project: ${e instanceof Error ? e.message : 'Unknown error'}`); |
| 127 | } |
| 128 | }; |
| 129 | |
| 130 | return ( |
| 131 | <div className={`${className}`}> |
no test coverage detected