Fixes
All checks were successful
Build and Push Docker Images / build-backend (push) Successful in 3m8s
Build and Push Docker Images / build-frontend (push) Successful in 1m15s

This commit is contained in:
2026-03-04 20:44:19 +01:00
parent 9cef3964e9
commit 52c182cb5f
14 changed files with 569 additions and 372 deletions

View File

@@ -502,9 +502,22 @@ export async function createCustomerInventoryItem(
}
export async function fetchPlants(token: string, includeArchived = false): Promise<Plant[]> {
const plants = await apiRequest<Plant[]>('/api/resource/plants', { token });
if (includeArchived) return plants || [];
return (plants || []).filter((plant) => !plant.archived);
const plants = await apiRequest<Array<Plant & { description?: unknown }>>('/api/resource/plants', { token });
const normalized = (plants || []).map((plant) => {
const legacyDescription = typeof plant.description === 'string'
? plant.description
: (plant.description && typeof plant.description === 'object' && 'text' in (plant.description as Record<string, unknown>)
? String((plant.description as Record<string, unknown>).text || '')
: null);
return {
...plant,
description: legacyDescription || null,
} as Plant;
});
if (includeArchived) return normalized;
return normalized.filter((plant) => !plant.archived);
}
export async function createPlant(
@@ -518,7 +531,15 @@ export async function createPlant(
return apiRequest<Plant>('/api/resource/plants', {
method: 'POST',
token,
body: payload,
body: {
name: payload.name,
customer: payload.customer ?? null,
description: {
text: payload.description?.trim() || '',
html: '',
json: [],
},
},
});
}