- Backend: Node.js/TypeScript with Prisma ORM - Frontend: Vite + TypeScript - Project configuration and documentation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
76 lines
2.0 KiB
TypeScript
76 lines
2.0 KiB
TypeScript
import { get, getPaginated, post, put, del } from './api';
|
|
import type { RMA } from '@/types';
|
|
|
|
export interface RMAFilters {
|
|
search?: string;
|
|
customerId?: string;
|
|
statusId?: string;
|
|
assignedToId?: string;
|
|
page?: number;
|
|
limit?: number;
|
|
}
|
|
|
|
export interface CreateRMAData {
|
|
customerId?: string;
|
|
customerName?: string;
|
|
customerAddress?: string;
|
|
customerEmail?: string;
|
|
customerPhone?: string;
|
|
customerICO?: string;
|
|
submittedBy: string;
|
|
productName: string;
|
|
invoiceNumber?: string;
|
|
purchaseDate?: string;
|
|
productNumber?: string;
|
|
serialNumber?: string;
|
|
accessories?: string;
|
|
issueDescription: string;
|
|
statusId: string;
|
|
requiresApproval?: boolean;
|
|
assignedToId?: string;
|
|
}
|
|
|
|
export interface UpdateRMAData {
|
|
statusId?: string;
|
|
proposedSolutionId?: string;
|
|
requiresApproval?: boolean;
|
|
approvedById?: string;
|
|
receivedDate?: string;
|
|
receivedLocation?: string;
|
|
internalNotes?: string;
|
|
resolutionDate?: string;
|
|
resolutionNotes?: string;
|
|
assignedToId?: string;
|
|
}
|
|
|
|
function buildQueryString(filters: RMAFilters): string {
|
|
const params = new URLSearchParams();
|
|
if (filters.search) params.append('search', filters.search);
|
|
if (filters.customerId) params.append('customerId', filters.customerId);
|
|
if (filters.statusId) params.append('statusId', filters.statusId);
|
|
if (filters.assignedToId) params.append('assignedToId', filters.assignedToId);
|
|
if (filters.page) params.append('page', String(filters.page));
|
|
if (filters.limit) params.append('limit', String(filters.limit));
|
|
return params.toString();
|
|
}
|
|
|
|
export const rmaApi = {
|
|
getAll: (filters: RMAFilters = {}) =>
|
|
getPaginated<RMA>(`/rma?${buildQueryString(filters)}`),
|
|
|
|
getById: (id: string) =>
|
|
get<RMA>(`/rma/${id}`),
|
|
|
|
create: (data: CreateRMAData) =>
|
|
post<RMA>('/rma', data),
|
|
|
|
update: (id: string, data: UpdateRMAData) =>
|
|
put<RMA>(`/rma/${id}`, data),
|
|
|
|
delete: (id: string) =>
|
|
del<void>(`/rma/${id}`),
|
|
|
|
approve: (id: string) =>
|
|
post<RMA>(`/rma/${id}/approve`),
|
|
};
|