Merge pull request 'Define a button to reset the affinities of all groups' (#179) from reset-all-affinities into main
All checks were successful
Playwright Tests / test (push) Has been skipped
Check usage of free licenses / build-static-assets (push) Successful in 1m28s
Build Nginx-based docker image / build-static-assets (push) Successful in 5m40s

Reviewed-on: #179
This commit is contained in:
bustikiller 2025-01-13 20:31:56 +00:00
commit 69f6fcbebe

View File

@ -5,6 +5,7 @@
import { AbstractApi, } from '@/app/api/abstract-api';
import { Group, GroupSerializer } from '@/app/lib/group';
import { Guest, GuestSerializer } from '@/app/lib/guest';
import { getCsrfToken, getSlug } from '@/app/lib/utils';
import AffinitiesFormDialog from '@/app/ui/components/affinities-form-dialog';
import { classNames } from '@/app/ui/components/button';
import GroupFormDialog from '@/app/ui/components/group-form-dialog';
@ -31,6 +32,16 @@ export default function Page() {
});
}
function resetAffinities() {
fetch(`/api/${getSlug()}/groups/affinities/reset`, {
method: 'POST',
headers: {
'Accept': 'application/json',
'X-CSRF-TOKEN': getCsrfToken(),
}
})
}
const [groupsLoaded, setGroupsLoaded] = useState(false);
const [groups, setGroups] = useState<Array<Group>>([]);
const [groupBeingEdited, setGroupBeingEdited] = useState<Group | undefined>(undefined);
@ -70,7 +81,11 @@ export default function Page() {
<TabPanel header="Groups" leftIcon="pi pi-sitemap mx-2">
<div className="flex flex-col w-full items-center justify-between">
<button onClick={() => setGroupBeingEdited({})} className={classNames('primary')}>Add new</button>
<div>
<button onClick={() => setGroupBeingEdited({})} className={classNames('primary')}>Add new</button>
<button onClick={resetAffinities} className={classNames('yellow')}>Reset affinities</button>
</div>
<GroupFormDialog
key={groupBeingEdited?.id}
groups={groups}