Initial commit: Helpdesk application setup
- Backend: Node.js/TypeScript with Prisma ORM - Frontend: Vite + TypeScript - Project configuration and documentation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
75
frontend/src/services/equipment.api.ts
Normal file
75
frontend/src/services/equipment.api.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import { get, getPaginated, post, put, del } from './api';
|
||||
import type { Equipment, Revision } from '@/types';
|
||||
|
||||
export interface EquipmentFilters {
|
||||
search?: string;
|
||||
customerId?: string;
|
||||
typeId?: string;
|
||||
active?: boolean;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
export interface CreateEquipmentData {
|
||||
name: string;
|
||||
typeId: string;
|
||||
brand?: string;
|
||||
model?: string;
|
||||
customerId?: string;
|
||||
address: string;
|
||||
location?: string;
|
||||
partNumber?: string;
|
||||
serialNumber?: string;
|
||||
installDate?: string;
|
||||
warrantyEnd?: string;
|
||||
warrantyStatus?: string;
|
||||
description?: string;
|
||||
notes?: string;
|
||||
active?: boolean;
|
||||
}
|
||||
|
||||
export type UpdateEquipmentData = Partial<CreateEquipmentData>;
|
||||
|
||||
export interface CreateRevisionData {
|
||||
typeId: string;
|
||||
performedDate: string;
|
||||
nextDueDate?: string;
|
||||
findings?: string;
|
||||
result?: string;
|
||||
notes?: string;
|
||||
}
|
||||
|
||||
function buildQueryString(filters: EquipmentFilters): string {
|
||||
const params = new URLSearchParams();
|
||||
if (filters.search) params.append('search', filters.search);
|
||||
if (filters.customerId) params.append('customerId', filters.customerId);
|
||||
if (filters.typeId) params.append('typeId', filters.typeId);
|
||||
if (filters.active !== undefined) params.append('active', String(filters.active));
|
||||
if (filters.page) params.append('page', String(filters.page));
|
||||
if (filters.limit) params.append('limit', String(filters.limit));
|
||||
return params.toString();
|
||||
}
|
||||
|
||||
export const equipmentApi = {
|
||||
getAll: (filters: EquipmentFilters = {}) =>
|
||||
getPaginated<Equipment>(`/equipment?${buildQueryString(filters)}`),
|
||||
|
||||
getById: (id: string) =>
|
||||
get<Equipment>(`/equipment/${id}`),
|
||||
|
||||
create: (data: CreateEquipmentData) =>
|
||||
post<Equipment>('/equipment', data),
|
||||
|
||||
update: (id: string, data: UpdateEquipmentData) =>
|
||||
put<Equipment>(`/equipment/${id}`, data),
|
||||
|
||||
delete: (id: string) =>
|
||||
del<void>(`/equipment/${id}`),
|
||||
|
||||
// Revisions
|
||||
getRevisions: (equipmentId: string) =>
|
||||
get<Revision[]>(`/equipment/${equipmentId}/revisions`),
|
||||
|
||||
createRevision: (equipmentId: string, data: CreateRevisionData) =>
|
||||
post<Revision>(`/equipment/${equipmentId}/revisions`, data),
|
||||
};
|
||||
Reference in New Issue
Block a user