Created
June 1, 2020 17:33
-
-
Save emanueleDiVizio/1fdde07f05d9dffea68b84924f17348e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const lastShiftSelector = state => state.shifts.slice(-1)[0] | |
const useIsOnShift = () => { | |
const lastShift = useSelector(lastShiftSelector) | |
const currentTime = useCurrentTime() | |
const [isOnShift, setIsOnShift] = useState(false) | |
useEffect(() => { | |
if (lastShift) { | |
setIsOnShift(currentTime.isBefore(lastShift.endTime)) | |
} | |
}, [currentTime]) | |
return isOnShift | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment