1
0
Fork 0
mirror of https://github.com/s-frick/effigenix.git synced 2026-03-28 10:09:35 +01:00
effigenix/frontend/packages/api-client/src/resources/storage-locations.ts
Sebastian Frick 72979c9537 feat: Paginierung für alle GET-List-Endpoints (#61)
Einheitliches Paginierungs-Pattern mit page, size und Multi-Field sort
für alle 14 List-Endpoints. Response-Format ändert sich von [...] zu
{ content: [...], page: { number, size, totalElements, totalPages } }.

Backend:
- Shared Kernel: Page<T>, PageRequest, SortField, SortDirection
- PaginationHelper (SQL ORDER BY mit Whitelist), PageResponse DTO
- Paginated Methoden in allen 14 Domain-Repos + JDBC-Implementierungen
- Safety-Limit (500) für findAllBelowMinimumLevel/ExpiryRelevantBatches
- Alle List-Use-Cases akzeptieren PageRequest, liefern Page<T>
- Alle Controller mit page/size/sort Query-Params + PageResponse

Frontend:
- PagedResponse<T> Type auf nested page-Format aktualisiert
- Alle 14 API-Client-Resourcen liefern PagedResponse mit PaginationParams
- Alle Hooks mit Pagination-State (currentPage, totalPages, pageSize)
- Alle List-Screens mit Seiten-Navigation (Pfeiltasten) und Footer

Loadtest:
- Podman-Support im justfile (DOCKER_HOST auto-detect)
- Verschärfte Performance-Schwellwerte basierend auf Ist-Werten
2026-03-20 16:33:20 +01:00

84 lines
3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* StorageLocations resource Inventory BC.
* Endpoints: GET/POST /api/inventory/storage-locations,
* PUT /api/inventory/storage-locations/{id},
* PATCH /api/inventory/storage-locations/{id}/activate|deactivate
*/
import type { AxiosInstance } from 'axios';
import type {
StorageLocationDTO,
TemperatureRangeDTO,
CreateStorageLocationRequest,
UpdateStorageLocationRequest,
PaginationParams,
PagedResponse,
} from '@effigenix/types';
export type StorageType = 'COLD_ROOM' | 'FREEZER' | 'DRY_STORAGE' | 'DISPLAY_COUNTER' | 'PRODUCTION_AREA';
export const STORAGE_TYPE_LABELS: Record<StorageType, string> = {
COLD_ROOM: 'Kühlraum',
FREEZER: 'Tiefkühler',
DRY_STORAGE: 'Trockenlager',
DISPLAY_COUNTER: 'Vitrine',
PRODUCTION_AREA: 'Produktionsbereich',
};
export type {
StorageLocationDTO,
TemperatureRangeDTO,
CreateStorageLocationRequest,
UpdateStorageLocationRequest,
};
export interface StorageLocationFilter {
storageType?: string;
active?: boolean;
}
// ── Resource factory ─────────────────────────────────────────────────────────
const BASE = '/api/inventory/storage-locations';
export function createStorageLocationsResource(client: AxiosInstance) {
return {
async list(filter?: StorageLocationFilter, pagination?: PaginationParams): Promise<PagedResponse<StorageLocationDTO>> {
const params: Record<string, string | string[]> = {};
if (filter?.storageType) params['storageType'] = filter.storageType;
if (filter?.active !== undefined) params['active'] = String(filter.active);
if (pagination?.page != null) params.page = String(pagination.page);
if (pagination?.size != null) params.size = String(pagination.size);
if (pagination?.sort) params.sort = pagination.sort;
const res = await client.get<PagedResponse<StorageLocationDTO>>(BASE, { params });
return res.data;
},
async getById(id: string): Promise<StorageLocationDTO> {
const res = await client.get<StorageLocationDTO>(`${BASE}/${id}`);
return res.data;
},
async create(request: CreateStorageLocationRequest): Promise<StorageLocationDTO> {
const res = await client.post<StorageLocationDTO>(BASE, request);
return res.data;
},
async update(id: string, request: UpdateStorageLocationRequest): Promise<StorageLocationDTO> {
const res = await client.put<StorageLocationDTO>(`${BASE}/${id}`, request);
return res.data;
},
async activate(id: string): Promise<StorageLocationDTO> {
const res = await client.patch<StorageLocationDTO>(`${BASE}/${id}/activate`);
return res.data;
},
async deactivate(id: string): Promise<StorageLocationDTO> {
const res = await client.patch<StorageLocationDTO>(`${BASE}/${id}/deactivate`);
return res.data;
},
};
}
export type StorageLocationsResource = ReturnType<typeof createStorageLocationsResource>;