diff --git a/app/src/pages/profile/ProfileClaims.tsx b/app/src/pages/profile/ProfileClaims.tsx index 36a6aeb..4bc45db 100644 --- a/app/src/pages/profile/ProfileClaims.tsx +++ b/app/src/pages/profile/ProfileClaims.tsx @@ -10,6 +10,7 @@ import { Badge, Button, Card, + ConfirmDialog, EmptyState, ErrorText, ListRow, @@ -43,9 +44,10 @@ export default function ProfileClaims() { const [newOpen, setNewOpen] = useState(false); const [resubmit, setResubmit] = useState(null); const [busyId, setBusyId] = useState(null); + const [withdrawTarget, setWithdrawTarget] = useState(null); useTopbar({ - title: 'Profil — wnioski', + title: 'Wnioski', back: '/profile', actions: [{ label: 'Nowy wniosek o siłownię', icon: Plus, onClick: () => setNewOpen(true) }], }); @@ -60,6 +62,7 @@ export default function ProfileClaims() { push((e as Error).message, 'error'); } finally { setBusyId(null); + setWithdrawTarget(null); } }; @@ -67,10 +70,7 @@ export default function ProfileClaims() { return ( <> - navigate('/profile')} />} - /> + navigate('/profile')} />} /> {isLoading && } {error && Błąd: {(error as Error).message}} @@ -124,7 +124,7 @@ export default function ProfileClaims() { size="sm" variant="secondary" disabled={busyId === c.id} - onClick={() => void withdraw(c.id)} + onClick={() => setWithdrawTarget(c)} > Wycofaj @@ -147,6 +147,18 @@ export default function ProfileClaims() { )} setNewOpen(false)} /> + setWithdrawTarget(null)} + onConfirm={() => withdrawTarget && void withdraw(withdrawTarget.id)} + title="Wycofać wniosek?" + description={ + withdrawTarget ? `${claimTitle(withdrawTarget)} — wniosek zostanie trwale wycofany.` : '' + } + confirmLabel="Wycofaj" + danger + busy={busyId != null} + /> setResubmit(null)} diff --git a/app/test/e2e/profile-claims.spec.ts b/app/test/e2e/profile-claims.spec.ts index b7a9b63..e676460 100644 --- a/app/test/e2e/profile-claims.spec.ts +++ b/app/test/e2e/profile-claims.spec.ts @@ -12,7 +12,7 @@ async function loginToClaims(page: import('@playwright/test').Page) { await expect(page.getByRole('heading', { name: 'Profil' })).toBeVisible(); // kafel „Wnioski” prowadzi na podstronę await page.getByRole('link', { name: /^Wnioski / }).click(); - await expect(page.getByRole('heading', { name: 'Wnioski o siłownie' })).toBeVisible(); + await expect(page.getByRole('heading', { name: 'Wnioski', level: 1 })).toBeVisible(); } test('profil: podstrona „Wnioski” — nowy wniosek o nową realną siłownię', async ({ page }) => { @@ -39,7 +39,9 @@ test('profil: podstrona „Wnioski” — nowy wniosek o nową realną siłowni await expect(page.getByText('Nowa siłownia', { exact: true })).toBeVisible(); await expect(page.getByText('Oczekuje', { exact: true })).toBeVisible(); - // wycofanie + // wycofanie: wiersz → potwierdzenie w ConfirmDialog (brak natychmiastowego DELETE) + await page.getByRole('button', { name: 'Wycofaj' }).click(); + await expect(page.getByText('Wycofać wniosek?')).toBeVisible(); await page.getByRole('button', { name: 'Wycofaj' }).click(); await expect(page.getByText('Wniosek wycofany')).toBeVisible(); });