metis-desk/apps/server/src/unlink-asset.integration-helper.ts
David b45925f3e2 feat(assets): implement asset picker dialog and selection components
- Added `useAssetPickerController` for managing asset selection logic.
- Created `AssetSelectProps` type for defining asset selection properties.
- Implemented `AssetPickerDialog` for displaying the asset selection interface.
- Developed `AssetPickerList` for rendering the list of selectable assets.
- Introduced `AssetSelect` component for integrating the asset picker into forms.
- Created `AssetList` component for shared asset listing functionality.
- Added tests for workstation creation logic to ensure proper validation.
- Implemented workstation asset fields and association fields for managing workstation assets.
- Developed workstation lifecycle dialog for managing work profile states.
- Added form progress component for visualizing multi-step forms.
2026-10-14 19:42:59 +02:00

31 lines
967 B
TypeScript

import assert from "node:assert/strict";
import { InventoryResponseSchema } from "@metis/assets/common";
type Request = (path: string, body?: unknown) => Promise<Response>;
export async function unlinkAssetFromWorkstations(
request: Request,
companyId: string,
assetId: string
) {
const inventory = InventoryResponseSchema.parse(
await (await request(`/assets/${companyId}`)).json()
);
for (const station of inventory.workstations.filter(
(item) => item.values.active && item.values.assetIds.includes(assetId)
)) {
const response = await request(`/assets/${companyId}/workstations/${station.id}/update`, {
values: {
...station.values,
computerAssetId:
station.values.computerAssetId === assetId ? null : station.values.computerAssetId,
assetIds: station.values.assetIds.filter((id) => id !== assetId),
},
});
assert.equal(response.status, 200, await response.clone().text());
}
}