feat(alerts): Quick-Toggle für Alert-Kanäle
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -129,6 +129,13 @@ export default function AlertsPage() {
|
|||||||
},
|
},
|
||||||
onError: (e: Error) => message.error(e.message),
|
onError: (e: Error) => message.error(e.message),
|
||||||
})
|
})
|
||||||
|
const quickToggle = useMutation({
|
||||||
|
mutationFn: async ({ id, row, checked }: { id: number; row: Channel; checked: boolean }) => {
|
||||||
|
await apiClient.put(`/alerts/channels/${id}`, buildPayload({ ...row, active: checked } as ChannelFormValues))
|
||||||
|
},
|
||||||
|
onSuccess: () => { void qc.invalidateQueries({ queryKey: ['alerts', 'channels'] }) },
|
||||||
|
onError: (e: Error) => message.error(e.message),
|
||||||
|
})
|
||||||
const del = useMutation({
|
const del = useMutation({
|
||||||
mutationFn: async (id: number) => { await apiClient.delete(`/alerts/channels/${id}`) },
|
mutationFn: async (id: number) => { await apiClient.delete(`/alerts/channels/${id}`) },
|
||||||
onSuccess: () => { qc.invalidateQueries({ queryKey: ['alerts', 'channels'] }) },
|
onSuccess: () => { qc.invalidateQueries({ queryKey: ['alerts', 'channels'] }) },
|
||||||
@@ -161,8 +168,14 @@ export default function AlertsPage() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t('alerts.col.active'), dataIndex: 'active', width: 80,
|
title: t('alerts.col.active'), dataIndex: 'active', width: 80,
|
||||||
render: (v: boolean) =>
|
render: (v: boolean, r: Channel) => (
|
||||||
v ? <Tag color="green">an</Tag> : <Tag>aus</Tag>,
|
<Switch
|
||||||
|
size="small"
|
||||||
|
checked={v}
|
||||||
|
loading={quickToggle.isPending && quickToggle.variables?.id === r.id}
|
||||||
|
onChange={(checked) => quickToggle.mutate({ id: r.id, row: r, checked })}
|
||||||
|
/>
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t('common.actions'), key: 'a', width: 180,
|
title: t('common.actions'), key: 'a', width: 180,
|
||||||
|
|||||||
Reference in New Issue
Block a user