App: potwierdzenie wycofania wniosku przez ConfirmDialog (brak natychmiastowego DELETE)

This commit is contained in:
tisachi
2026-10-16 23:50:58 +02:00
parent 09b29d7714
commit 8d30fa2c51
2 changed files with 22 additions and 8 deletions

View File

@@ -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<GymClaim | null>(null);
const [busyId, setBusyId] = useState<string | null>(null);
const [withdrawTarget, setWithdrawTarget] = useState<GymClaim | null>(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 (
<>
<PageHeader
title="Wnioski o siłownie"
actions={<BackButton onClick={() => navigate('/profile')} />}
/>
<PageHeader title="Wnioski" actions={<BackButton onClick={() => navigate('/profile')} />} />
{isLoading && <Loading />}
{error && <ErrorText>Błąd: {(error as Error).message}</ErrorText>}
@@ -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
</Button>
@@ -147,6 +147,18 @@ export default function ProfileClaims() {
)}
<ClaimModal open={newOpen} onClose={() => setNewOpen(false)} />
<ConfirmDialog
open={withdrawTarget != null}
onClose={() => 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}
/>
<ClaimModal
open={resubmit != null}
onClose={() => setResubmit(null)}

View File

@@ -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();
});