/
afanasevn
/
MaxSystems
Обзор
Документация
Войти
/
afanasevn
/
MaxSystems
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
client/src/api/works.ts
130 строк
3 KB
IBS\NAfanasev
Add project files.
18 июн 2026, 01:12
18 июн 2026, 01:12
b06aa39
Код
Авторство
О чём код?
import { apiGet, apiPatch } from './http' export type WorkType = | 'Ticket' | 'Maintenance' | 'Repair' | 'Inspection' | 'Installation' | 'Project' | 'Contractor' | 'Documentation' | 'Purchase' | 'Warehouse' | 'Organizational' export type WorkStatus = | 'New' | 'Assigned' | 'InProgress' | 'WaitingAccess' | 'WaitingMaterials' | 'WaitingContractor' | 'WaitingApproval' | 'Done' | 'OnReview' | 'Closed' | 'Cancelled' export type Priority = 'P1' | 'P2' | 'P3' | 'P4' | 'Planned' export type EquipmentSystem = | 'Ups' | 'Acs' | 'Cctv' | 'Lan' | 'Hvac' | 'Telecom' | 'Other' export type WorkListItem = { id: string number: string title: string type: WorkType system: EquipmentSystem status: WorkStatus plannedDate: string priority: Priority equipmentName: string | null isOverdue: boolean } export type WorkMaterialItem = { itemId: string itemName: string quantity: number notes: string | null } export type Checklist = { type: string itemsJson: string summaryJson: string | null completed: boolean } export type WorkDetail = { id: string number: string serviceDeskTicket: string | null type: WorkType category: string system: EquipmentSystem equipmentId: string | null equipmentName: string | null priority: Priority leadSpecialistId: string | null leadSpecialistName: string | null assigneeId: string | null assigneeName: string | null plannedDate: string actualDate: string | null status: WorkStatus waitReason: string | null title: string description: string | null result: string | null needsPurchase: boolean needsRework: boolean recommendations: string | null isOverdue: boolean checklist: Checklist | null materials: WorkMaterialItem[] } export type WorkListFilters = { status?: WorkStatus system?: EquipmentSystem type?: WorkType overdue?: boolean } export type UpdateWorkStatusPayload = { status: WorkStatus waitReason?: string result?: string } export async function fetchWorksList(filters: WorkListFilters = {}): Promise<WorkListItem[]> { const params = new URLSearchParams() if (filters.status) params.set('status', filters.status) if (filters.system) params.set('system', filters.system) if (filters.type) params.set('type', filters.type) if (filters.overdue) params.set('overdue', 'true') const query = params.toString() const path = query ? `/api/works?${query}` : '/api/works' return apiGet<WorkListItem[]>(path) } export async function fetchWorkDetail(id: string): Promise<WorkDetail> { return apiGet<WorkDetail>(`/api/works/${id}`) } export async function updateWorkStatus( id: string, payload: UpdateWorkStatusPayload, ): Promise<WorkListItem> { return apiPatch<WorkListItem>(`/api/works/${id}`, payload) }