init
This commit is contained in:
commit
fcec12e5ba
78 files changed
+9569
No files matched your search
@@ -0,0 +1,81 @@
|
||||
import { apiClient, toQuery } from '@/lib/api-client.ts'
|
||||
import type { User } from '@/api/user.api.ts'
|
||||
|
||||
export interface Issue {
|
||||
id: number
|
||||
key: string
|
||||
title: string
|
||||
content: string
|
||||
status: 'OPEN' | 'IN_PROGRESS' | 'DONE' | 'CANCELLED'
|
||||
priority: 0 | 1 | 2 | 3 | 4
|
||||
assigneeId: string
|
||||
reporterId: string
|
||||
assignee?: User
|
||||
reporter?: User
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export interface Meta {
|
||||
page: number
|
||||
totalCount: number
|
||||
totalPages: number
|
||||
}
|
||||
|
||||
export interface CreateIssueInput {
|
||||
key: string
|
||||
title: string
|
||||
projectId: string
|
||||
content?: string
|
||||
status?: Issue['status']
|
||||
priority?: Issue['priority']
|
||||
assignee?: string
|
||||
}
|
||||
|
||||
export type UpdateIssueInput = Partial<CreateIssueInput>
|
||||
|
||||
export interface IssueStatByStatus {
|
||||
status: Issue['status']
|
||||
label: string
|
||||
count: number
|
||||
}
|
||||
|
||||
export interface IssueStat {
|
||||
total: number
|
||||
byStatus: IssueStatByStatus[]
|
||||
}
|
||||
|
||||
// CLIENT REQUEST
|
||||
|
||||
export async function itemsList(params: {
|
||||
page: number
|
||||
limit: number
|
||||
text?: string | null
|
||||
projectId?: string | null
|
||||
}) {
|
||||
// `text` (free-text search) has no backend support yet — kept in the
|
||||
// signature so callers don't need to change, but not sent over the wire.
|
||||
const query = toQuery({ page: params.page, limit: params.limit, projectId: params.projectId })
|
||||
return apiClient.get<{ list: Issue[]; meta: Meta }>(`/api/issues/list${query}`)
|
||||
}
|
||||
|
||||
export async function itemGetByKey(ckey: string) {
|
||||
return apiClient.get<Issue>(`/api/issues/by-key/${ckey}`)
|
||||
}
|
||||
|
||||
export async function itemCreate(input: CreateIssueInput) {
|
||||
return apiClient.post<Issue>('/api/issues', input)
|
||||
}
|
||||
|
||||
export async function itemUpdate(id: number, input: UpdateIssueInput) {
|
||||
return apiClient.patch<Issue>(`/api/issues/${id}`, input)
|
||||
}
|
||||
|
||||
export async function itemDelete(id: number) {
|
||||
await apiClient.delete(`/api/issues/${id}`)
|
||||
return true
|
||||
}
|
||||
|
||||
export async function itemStat() {
|
||||
return apiClient.get<IssueStat>('/api/issues/stats')
|
||||
}
|
||||
Reference in new issue
Block a user