62 行
1.8 KiB
TypeScript
62 行
1.8 KiB
TypeScript
import { apiRequestData } from "./http";
|
|
import type { ConfidentialityLevel, EmployeeBasic } from "./projects";
|
|
|
|
export type ContractRegistryItem = {
|
|
id: string;
|
|
contractNo: string;
|
|
projectId: string | null;
|
|
counterpartyName: string;
|
|
summary: string;
|
|
confidentialityLevel: ConfidentialityLevel;
|
|
archiveLocation: string;
|
|
offlineArchiveNo: string | null;
|
|
ownerEmployeeId: string;
|
|
status: string;
|
|
createdAt: string | null;
|
|
updatedAt: string | null;
|
|
owner: EmployeeBasic | null;
|
|
project: { id: string; projectNo: string; name: string } | null;
|
|
};
|
|
|
|
export async function fetchContractsRegistry(projectId?: string) {
|
|
const suffix = projectId ? `?projectId=${encodeURIComponent(projectId)}` : "";
|
|
return apiRequestData<{ items: ContractRegistryItem[] }>(`/api/contracts-registry${suffix}`);
|
|
}
|
|
|
|
export async function createContractRegistry(payload: {
|
|
contractNo: string;
|
|
projectId?: string | null;
|
|
counterpartyName: string;
|
|
summary: string;
|
|
confidentialityLevel?: ConfidentialityLevel;
|
|
archiveLocation: string;
|
|
offlineArchiveNo?: string | null;
|
|
ownerEmployeeId?: string;
|
|
status?: string;
|
|
}) {
|
|
return apiRequestData<{ item: ContractRegistryItem }>("/api/contracts-registry", {
|
|
method: "POST",
|
|
body: JSON.stringify(payload),
|
|
});
|
|
}
|
|
|
|
export async function patchContractRegistry(
|
|
id: string,
|
|
payload: Partial<{
|
|
contractNo: string;
|
|
projectId: string | null;
|
|
counterpartyName: string;
|
|
summary: string;
|
|
confidentialityLevel: ConfidentialityLevel;
|
|
archiveLocation: string;
|
|
offlineArchiveNo: string | null;
|
|
ownerEmployeeId: string;
|
|
status: string;
|
|
}>,
|
|
) {
|
|
return apiRequestData<{ item: ContractRegistryItem }>(`/api/contracts-registry/${id}`, {
|
|
method: "PATCH",
|
|
body: JSON.stringify(payload),
|
|
});
|
|
}
|