slots.js
1 export const SlotState = { 2 Free: 'Free', // [default] not filled yet, or host has vacated the slot 3 Filled: 'Filled', // host has filled slot 4 Finished: 'Finished', // successfully completed 5 Failed: 'Failed', // the request has failed 6 Paid: 'Paid', // host has been paid 7 Cancelled: 'Cancelled' // when request was cancelled then slot is cancelled as well 8 } 9 10 export function toSlotState(idx) { 11 return Object.values(SlotState).at(idx) 12 } 13 14 export function getStateColour(state) { 15 if (state === SlotState.Free) { 16 return 'yellow' 17 } else if (state === SlotState.Filled) { 18 return 'green' 19 } else if (state === SlotState.Finished) { 20 return 'blue' 21 } else if (state === SlotState.Paid) { 22 return 'gray' 23 } else { 24 return 'red' 25 } 26 }