Refactor and enhance UI components across multiple pages
- Improved import organization and formatting in PlaylistsPage, RegisterPage, SoundsPage, SettingsPage, and UsersPage for better readability. - Added error handling and user feedback with toast notifications in SoundsPage and SettingsPage. - Enhanced user experience by implementing debounced search functionality in PlaylistsPage and SoundsPage. - Updated the layout and structure of forms in SettingsPage and UsersPage for better usability. - Improved accessibility and semantics by ensuring proper labeling and descriptions in forms. - Fixed minor bugs related to state management and API calls in various components.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { apiClient } from '../client'
|
||||
import type { User } from '@/types/auth'
|
||||
import { apiClient } from '../client'
|
||||
|
||||
export interface Plan {
|
||||
id: number
|
||||
@@ -56,7 +56,7 @@ export interface NormalizationResponse {
|
||||
export class AdminService {
|
||||
async listUsers(limit = 100, offset = 0): Promise<User[]> {
|
||||
return apiClient.get<User[]>(`/api/v1/admin/users/`, {
|
||||
params: { limit, offset }
|
||||
params: { limit, offset },
|
||||
})
|
||||
}
|
||||
|
||||
@@ -69,11 +69,15 @@ export class AdminService {
|
||||
}
|
||||
|
||||
async disableUser(userId: number): Promise<MessageResponse> {
|
||||
return apiClient.post<MessageResponse>(`/api/v1/admin/users/${userId}/disable`)
|
||||
return apiClient.post<MessageResponse>(
|
||||
`/api/v1/admin/users/${userId}/disable`,
|
||||
)
|
||||
}
|
||||
|
||||
async enableUser(userId: number): Promise<MessageResponse> {
|
||||
return apiClient.post<MessageResponse>(`/api/v1/admin/users/${userId}/enable`)
|
||||
return apiClient.post<MessageResponse>(
|
||||
`/api/v1/admin/users/${userId}/enable`,
|
||||
)
|
||||
}
|
||||
|
||||
async listPlans(): Promise<Plan[]> {
|
||||
@@ -85,27 +89,38 @@ export class AdminService {
|
||||
return apiClient.post<ScanResponse>(`/api/v1/admin/sounds/scan`)
|
||||
}
|
||||
|
||||
async normalizeAllSounds(force = false, onePass?: boolean): Promise<NormalizationResponse> {
|
||||
async normalizeAllSounds(
|
||||
force = false,
|
||||
onePass?: boolean,
|
||||
): Promise<NormalizationResponse> {
|
||||
const params = new URLSearchParams()
|
||||
if (force) params.append('force', 'true')
|
||||
if (onePass !== undefined) params.append('one_pass', onePass.toString())
|
||||
|
||||
|
||||
const queryString = params.toString()
|
||||
const url = queryString ? `/api/v1/admin/sounds/normalize/all?${queryString}` : `/api/v1/admin/sounds/normalize/all`
|
||||
|
||||
const url = queryString
|
||||
? `/api/v1/admin/sounds/normalize/all?${queryString}`
|
||||
: `/api/v1/admin/sounds/normalize/all`
|
||||
|
||||
return apiClient.post<NormalizationResponse>(url)
|
||||
}
|
||||
|
||||
async normalizeSoundsByType(soundType: 'SDB' | 'TTS' | 'EXT', force = false, onePass?: boolean): Promise<NormalizationResponse> {
|
||||
async normalizeSoundsByType(
|
||||
soundType: 'SDB' | 'TTS' | 'EXT',
|
||||
force = false,
|
||||
onePass?: boolean,
|
||||
): Promise<NormalizationResponse> {
|
||||
const params = new URLSearchParams()
|
||||
if (force) params.append('force', 'true')
|
||||
if (onePass !== undefined) params.append('one_pass', onePass.toString())
|
||||
|
||||
|
||||
const queryString = params.toString()
|
||||
const url = queryString ? `/api/v1/admin/sounds/normalize/type/${soundType}?${queryString}` : `/api/v1/admin/sounds/normalize/type/${soundType}`
|
||||
|
||||
const url = queryString
|
||||
? `/api/v1/admin/sounds/normalize/type/${soundType}?${queryString}`
|
||||
: `/api/v1/admin/sounds/normalize/type/${soundType}`
|
||||
|
||||
return apiClient.post<NormalizationResponse>(url)
|
||||
}
|
||||
}
|
||||
|
||||
export const adminService = new AdminService()
|
||||
export const adminService = new AdminService()
|
||||
|
||||
Reference in New Issue
Block a user