refactor: rename module to pipely and migrate web UI to MUI
- Rename Go module from onixbyte.com/message-converter-manifest to onixbyte.com/pipely - Replace shadcn UI with Material UI components across all pages - Add axios-based API client in shared/web-client with credentials management - Organise API calls into feature modules: auth, devices, deployments, artefacts, users - Add .env.example with VITE_API_BASE_URL pointing to pipely.onixbyte.com - Fix deprecated FormEvent → MouseEvent in dialog submit handlers
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import WebClient from "@/shared/web-client"
|
||||
|
||||
export interface User {
|
||||
id: string
|
||||
username: string
|
||||
role: "admin" | "user"
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export interface CreateUserRequest {
|
||||
username: string
|
||||
password: string
|
||||
role: "admin" | "user"
|
||||
}
|
||||
|
||||
export interface UpdateUserRequest {
|
||||
username?: string
|
||||
password?: string
|
||||
role?: "admin" | "user"
|
||||
}
|
||||
|
||||
export interface UsersResponse {
|
||||
data: User[]
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
}
|
||||
|
||||
export interface UsersQuery {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
}
|
||||
|
||||
export async function getUsers(query?: UsersQuery): Promise<UsersResponse> {
|
||||
const params = new URLSearchParams()
|
||||
if (query?.page) params.append("page", query.page.toString())
|
||||
if (query?.pageSize) params.append("pageSize", query.pageSize.toString())
|
||||
|
||||
const queryString = params.toString()
|
||||
const { data } = await WebClient.get<UsersResponse>(
|
||||
`/users${queryString ? `?${queryString}` : ""}`
|
||||
)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function createUser(request: CreateUserRequest): Promise<User> {
|
||||
const { data } = await WebClient.post<User>("/users", request)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function updateUser(id: string, request: UpdateUserRequest): Promise<User> {
|
||||
const { data } = await WebClient.put<User>(`/users/${id}`, request)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function deleteUser(id: string): Promise<void> {
|
||||
await WebClient.delete<void>(`/users/${id}`)
|
||||
}
|
||||
Reference in New Issue
Block a user