Merge pull request 'Add a confirmation dialog before deleting a guest' (#284) from confirmation-dialog-remove-guest into main
All checks were successful
Check usage of free licenses / build-static-assets (push) Successful in 51s
Playwright Tests / test (push) Successful in 11m49s
Build Nginx-based docker image / build-static-assets (push) Successful in 12m11s

Reviewed-on: #284
This commit is contained in:
bustikiller 2025-06-15 11:28:14 +00:00
commit cd6574389f
2 changed files with 8 additions and 2 deletions

View File

@ -3,7 +3,7 @@
'use client';
import { AbstractApi } from '@/app/api/abstract-api';
import { Guest , GuestSerializer} from '@/app/lib/guest';
import { Guest, GuestSerializer } from '@/app/lib/guest';
import { PencilIcon, TrashIcon } from '@heroicons/react/24/outline';
import clsx from 'clsx';
import TableOfContents from '../components/table-of-contents';
@ -48,7 +48,12 @@ export default function guestsTable({ guests, onUpdate, onEdit }: {
</td>
<td>
<div className="flex flex-row items-center">
<TrashIcon className='size-6 cursor-pointer' onClick={() => { api.destroy(serializer, guest, onUpdate)}} />
<TrashIcon className='size-6 cursor-pointer' onClick={() => {
if (window.confirm(`Are you sure you want to delete guest "${guest.name}"?`)) {
api.destroy(serializer, guest, onUpdate)
}
}}
/>
<PencilIcon className='size-6 cursor-pointer' onClick={() => onEdit(guest)} />
</div>
</td>

View File

@ -70,6 +70,7 @@ test('should allow CRUD on guests', async ({ page }) => {
await expect(page.getByText('There are 3 elements in the list')).toBeVisible();
// Delete John Fire
page.on('dialog', dialog => dialog.accept());
await page.getByRole('row').nth(1).locator('svg').nth(0).click(); // Click delete icon
await expect(page.getByText('There are 2 elements in the list')).toBeVisible();
});