In this episode, we're cleaning up our list of slots by making sure we only show the ones that actually have employees available. Why keep midnight slots or other times when nobody is around? It just clutters up our display!
So, we start by creating a method to remove those empty slots. We use collection filtering to easily toss out any slots with zero available employees. As we go, we use some quick checks to make sure it’s working (like dumping out the data and seeing what’s left).
Next, we also make sure to filter inside each day—meaning, not only do we remove empty slots, but we also remove days if all their slots have no available employees. For this, we add a handy hasEmployees
helper on the slot, which simply checks if there are any employees assigned.
By the end, refreshing the page shows us a much neater list: only the valid slots (and days) when employees are actually available. No more pointless blanks in our schedule!