DH V2 CI / WEB · typecheck, build (push) Successful in 45s
Production dependency audit / API · production dependencies (push) Successful in 27s
DH V2 CI / API · typecheck, tests, build (push) Successful in 1m15s
Production dependency audit / WEB · production dependencies (push) Successful in 15s
DH V2 CI / Docker / migrations / production images (push) Successful in 2m21s
DH V2 CI / Promote verified main to deploy (push) Successful in 9s
Android CI / RC / Android · lint, tests, debug APK, release compile (push) Failing after 6m25s
87 lines
2.1 KiB
TypeScript
87 lines
2.1 KiB
TypeScript
import { apiRequest } from './api';
|
|
|
|
export interface InventoryFunction {
|
|
id: string;
|
|
code: string;
|
|
name: string;
|
|
description: string | null;
|
|
isActive: boolean;
|
|
sortOrder: number;
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
}
|
|
|
|
export interface InventoryFunctionAssignment {
|
|
id: string;
|
|
assetId: string;
|
|
functionId: string;
|
|
functionCode: string;
|
|
functionName: string;
|
|
validFrom: string;
|
|
validUntil: string | null;
|
|
reason: string | null;
|
|
changedBy: string | null;
|
|
changedByUsername: string | null;
|
|
createdAt: string;
|
|
}
|
|
|
|
export interface InventoryFunctionHistory {
|
|
asset: {
|
|
id: string;
|
|
code: string;
|
|
name: string;
|
|
typeCode: string;
|
|
typeName: string;
|
|
familyCode: string | null;
|
|
familyName: string | null;
|
|
};
|
|
currentFunction: InventoryFunctionAssignment | null;
|
|
history: InventoryFunctionAssignment[];
|
|
}
|
|
|
|
export async function listInventoryFunctions(includeInactive = false) {
|
|
const query = includeInactive ? '?includeInactive=true' : '';
|
|
return (await apiRequest<{ data: InventoryFunction[] }>(`/inventory-functions${query}`)).data;
|
|
}
|
|
|
|
export function getInventoryFunctionHistory(assetId: string) {
|
|
return apiRequest<InventoryFunctionHistory>(`/assets/${assetId}/function-history`);
|
|
}
|
|
|
|
export function changeInventoryFunction(
|
|
assetId: string,
|
|
input: { functionId: string | null; effectiveAt?: string; reason?: string | null },
|
|
) {
|
|
return apiRequest<InventoryFunctionHistory>(`/assets/${assetId}/function`, {
|
|
method: 'POST',
|
|
body: JSON.stringify(input),
|
|
});
|
|
}
|
|
|
|
export function createInventoryFunction(input: {
|
|
code: string;
|
|
name: string;
|
|
description?: string | null;
|
|
sortOrder?: number;
|
|
}) {
|
|
return apiRequest<InventoryFunction>('/inventory-functions', {
|
|
method: 'POST',
|
|
body: JSON.stringify(input),
|
|
});
|
|
}
|
|
|
|
export function updateInventoryFunction(
|
|
id: string,
|
|
input: {
|
|
name?: string;
|
|
description?: string | null;
|
|
isActive?: boolean;
|
|
sortOrder?: number;
|
|
},
|
|
) {
|
|
return apiRequest<InventoryFunction>(`/inventory-functions/${id}`, {
|
|
method: 'PATCH',
|
|
body: JSON.stringify(input),
|
|
});
|
|
}
|