Refactor .gitignore to streamline ignored files and enhance clarity. Update CLAUDE.md to improve unit test instructions and add coverage reporting details. Revise README.md for better project overview and deployment instructions. Refactor ChannelEndpoints and StreamingEndpoints to utilize SegmentFiles for file resolution, improving code maintainability. Remove unused JunctionHandlers and update DependencyInjection for cleaner service registration. Enhance media processing services for better job handling and error management. Update frontend API types for consistency and clarity.
This commit is contained in:
@@ -5,7 +5,8 @@ import { useState } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { z } from 'zod'
|
||||
import { HttpError } from '@/shared/api/client'
|
||||
import { qk } from '@/shared/api/query-keys'
|
||||
import { useApiError } from '@/shared/lib/use-api-error'
|
||||
import { Badge } from '@/shared/ui/badge'
|
||||
import { Button } from '@/shared/ui/button'
|
||||
import {
|
||||
@@ -19,7 +20,6 @@ import {
|
||||
import { Input } from '@/shared/ui/input'
|
||||
import { Label } from '@/shared/ui/label'
|
||||
import { SortHeader, sortRows, useTableSort } from '@/shared/ui/sortable'
|
||||
import { toast } from '@/shared/ui/toast-store'
|
||||
import { createRole, deleteRole, listRoles, updateRole } from './api'
|
||||
|
||||
const schema = z.object({ name: z.string().min(1).max(64) })
|
||||
@@ -27,14 +27,15 @@ const schema = z.object({ name: z.string().min(1).max(64) })
|
||||
export function RolesPanel() {
|
||||
const { t } = useTranslation()
|
||||
const queryClient = useQueryClient()
|
||||
const { data: roles, isLoading } = useQuery({ queryKey: ['admin', 'roles'], queryFn: listRoles })
|
||||
const { data: roles, isLoading } = useQuery({ queryKey: qk.roles.all, queryFn: listRoles })
|
||||
const { sort, toggle } = useTableSort('name', false)
|
||||
const sortedRoles = sortRows(roles ?? [], sort, {
|
||||
name: (r) => r.name.toLowerCase(),
|
||||
system: (r) => r.isSystem,
|
||||
})
|
||||
|
||||
const invalidate = () => queryClient.invalidateQueries({ queryKey: ['admin', 'roles'] })
|
||||
const invalidate = () => queryClient.invalidateQueries({ queryKey: qk.roles.all })
|
||||
const onError = useApiError()
|
||||
|
||||
const createMutation = useMutation({
|
||||
mutationFn: (name: string) => createRole(name),
|
||||
@@ -44,17 +45,13 @@ export function RolesPanel() {
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: (id: string) => deleteRole(id),
|
||||
onSuccess: invalidate,
|
||||
onError: (error) => {
|
||||
toast.error(error instanceof HttpError ? error.detail : t('common.error'))
|
||||
},
|
||||
onError,
|
||||
})
|
||||
|
||||
const renameMutation = useMutation({
|
||||
mutationFn: ({ id, name }: { id: string; name: string }) => updateRole(id, name),
|
||||
onSuccess: invalidate,
|
||||
onError: (error) => {
|
||||
toast.error(error instanceof HttpError ? error.detail : t('common.error'))
|
||||
},
|
||||
onError,
|
||||
})
|
||||
|
||||
const [open, setOpen] = useState(false)
|
||||
@@ -66,7 +63,7 @@ export function RolesPanel() {
|
||||
reset()
|
||||
setOpen(false)
|
||||
} catch (error) {
|
||||
toast.error(error instanceof HttpError ? error.detail : t('common.error'))
|
||||
onError(error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user