mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-18 13:44:12 +00:00
refactor: extract timer data to hook
This commit is contained in:
committed by
Carlos Valente
parent
78184b23b7
commit
20ee391525
@@ -4,3 +4,22 @@ export type ViewData<T> = {
|
||||
data: T;
|
||||
status: QueryStatus;
|
||||
};
|
||||
|
||||
/**
|
||||
* Aggregates a loading status from multiple query statuses.
|
||||
* If all statuses are 'pending', returns 'pending'.
|
||||
* If all statuses are 'success', returns 'success'.
|
||||
* If any status is 'error', returns 'error'.
|
||||
*/
|
||||
export function aggregateQueryStatus(statuses: QueryStatus[]): QueryStatus {
|
||||
if (statuses.every((status) => status === 'pending')) {
|
||||
return 'pending';
|
||||
}
|
||||
if (statuses.every((status) => status === 'success')) {
|
||||
return 'success';
|
||||
}
|
||||
if (statuses.some((status) => status === 'error')) {
|
||||
return 'error';
|
||||
}
|
||||
return 'pending';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user