Hide add FAB at task limit

This commit is contained in:
Codex Agent
2026-01-21 10:30:12 +01:00
parent 683939a354
commit b39bbfad87
2 changed files with 33 additions and 12 deletions

View File

@@ -1555,17 +1555,19 @@ export default function MobileEventTasksPage() {
</AlertDialog.Portal> </AlertDialog.Portal>
</AlertDialog> </AlertDialog>
<FloatingActionButton {canAddTasks ? (
onPress={() => { <FloatingActionButton
if (!canAddTasks) { onPress={() => {
toast.error(limitReachedMessage); if (!canAddTasks) {
return; toast.error(limitReachedMessage);
} return;
setShowFabMenu(true); }
}} setShowFabMenu(true);
label={t('events.tasks.add', 'Add')} }}
icon={Plus} label={t('events.tasks.add', 'Add')}
/> icon={Plus}
/>
) : null}
<MobileSheet <MobileSheet
open={showFabMenu} open={showFabMenu}

View File

@@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import { describe, expect, it, vi } from 'vitest'; import { describe, expect, it, vi } from 'vitest';
import { act, fireEvent, render, screen } from '@testing-library/react'; import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
import * as api from '../../api'; import * as api from '../../api';
const fixtures = vi.hoisted(() => ({ const fixtures = vi.hoisted(() => ({
@@ -309,4 +309,23 @@ describe('MobileEventTasksPage', () => {
expect((await screen.findAllByText('Auswahl löschen')).length).toBeGreaterThan(0); expect((await screen.findAllByText('Auswahl löschen')).length).toBeGreaterThan(0);
}); });
it('hides the add FAB when the task limit is reached', async () => {
(api.getEvent as unknown as { mockResolvedValueOnce: (value: any) => void }).mockResolvedValueOnce({
...fixtures.event,
limits: {
tasks: {
limit: 2,
remaining: 0,
},
},
});
render(<MobileEventTasksPage />);
expect(await screen.findByText('Photo task mode')).toBeInTheDocument();
await waitFor(() => {
expect(screen.queryByLabelText('Add')).not.toBeInTheDocument();
});
});
}); });