+export const getLocationStatus = (name, logic, state) => {
+ if (state[name]) return 'cleared';
+ if (logic[name]) return logic[name];
+ return logic.fallback;
+};
+
+export const getCombinedStatus = statuses => {
+ if (statuses.filter(s => s === 'cleared').length === statuses.length) {
+ return 'cleared';
+ }
+ if (statuses.filter(s => ['available', 'cleared'].includes(s)).length === statuses.length) {
+ return 'available';
+ }
+ if (statuses.filter(s => ['unavailable', 'cleared'].includes(s)).length === statuses.length) {
+ return 'unavailable';
+ }
+ return 'partial';
+};
+
+export const aggregateLocationStatus = (names, logic, state) => {
+ const statuses = names.map(name => getLocationStatus(name, logic, state));
+ return getCombinedStatus(statuses);
+};
+