Fix: Reduce maintenance data request frequency.

Fix: The maintenance list should refresh immediately after a new maintenance entry is created.
This commit is contained in:
Tola Leng
2025-05-24 18:20:33 +08:00
parent df047541b9
commit 23be1fca0f
4 changed files with 172 additions and 86 deletions
@@ -61,12 +61,14 @@ const getCompletedMaintenance = async (): Promise<MaintenanceItem[]> => {
const createMaintenance = async (data: CreateMaintenanceInput): Promise<void> => {
await createMaintenanceRecord(data);
clearMaintenanceCache(); // Force cache refresh after creation
console.log('Maintenance created and cache cleared');
};
// Update an existing maintenance record
const updateMaintenanceRecord = async (id: string, data: Partial<MaintenanceItem>): Promise<void> => {
await updateMaintenance(id, data);
clearMaintenanceCache(); // Force cache refresh after update
console.log('Maintenance updated and cache cleared');
};
// Refresh cache manually
@@ -89,4 +91,4 @@ export const maintenanceService = {
};
// Re-export types for convenience
export type { MaintenanceItem, CreateMaintenanceInput };
export type { MaintenanceItem, CreateMaintenanceInput };