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
| _this.requestTimeOutStatus = function (row, seat) { | |
| var currentStatus = SeatService.getStatusForSeatWith(row, seat); | |
| var fireBaseTimeDifference = reservationTime - moment().diff(moment(JSON.parse(currentStatus.date)), 'seconds'); | |
| return fireBaseTimeDifference > 60 ? Math.round(fireBaseTimeDifference / 60) + 'm' : Math.round(fireBaseTimeDifference) + 's'; | |
| }; |
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
| transform(value: any, args?: any): any { | |
| if (typeof value !== 'number') return '…' | |
| const inHours = value / 60 / 60 / 1000 | |
| const inMinutes = value / 60 / 1000 | |
| const inSeconds = value / 1000 | |
| if (value < 1) return '…' | |
| if (inHours > 1) return `${Math.round(inHours)}h` | |
| if (inMinutes > 1) return `${Math.round(inMinutes)}m` | |
| return `${Math.round(inSeconds)}s` | |
| } |
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 styleTime = ({completed, total}) => loadingStringIf(completed) || msAsHoursRounded(total) || msAsMinutesRounded(total) || msAsSecondsRounded(total) || loadingString(); |
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
| import {curry} from "ramda"; | |
| // Take a function and a value, return the function with the applied value if the value is evaluated as true | |
| const falseOr = curry((fn, value) => value && fn(value)); | |
| // Return a string that indicates loading | |
| const loadingString = () => '…'; | |
| // Return the loading string but only if the input evaluates to true | |
| const loadingStringIf = falseOr(loadingString); |
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
| import {compose, curry} from "ramda"; | |
| // Take a function and a value, return the function with the applied value if the value is evaluated as true | |
| const falseOr = curry((fn, value) => value && fn(value)); | |
| // Take a function and a value, return the value if the function returns true | |
| const valueIf = curry((fn, value) => fn(value) && value); | |
| // Take a duration in ms and convert it to either Hours, minutes or seconds; | |
| const msToHours = (duration) => duration / 60 / 60 / 1000; | |
| // Check if a value evaluates to true and if it is over one | |
| const overOne = (value) => isNumber(value) && value > 1; | |
| // Postfix function that takes a postfix and a value and adds it to the back of the value |
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 asHours = (duration) => { | |
| const stepOne = msToHours(duration); | |
| const stepTwo = valueIf(overOne(stepOne)); | |
| const stepThree = falseOr(Math.round(stepTwo)); | |
| const stepFour = falseOr(PostFixHours(stepThree)); | |
| return stepFour; | |
| } | |
| // Or, if you're a mad man. Like this: | |
| const asHours = (duration) => falseOr(postFixHours(falseOr(Math.round(valueIf(overOne(msToHours(duration))))))); |
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
| // Take a duration in ms and convert it to either Hours, minutes or seconds; | |
| const msToHours = (duration) => duration / 60 / 60 / 1000; |
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
| import {compose, curry} from "ramda"; | |
| // Check if a value is number | |
| const isNumber = (value) => typeof value === 'number'; | |
| // Take a function and a value, return the value if the function returns true | |
| const valueIf = curry((fn, value) => fn(value) && value); | |
| // Check if a value evaluates to true and if it is over one | |
| const overOne = (value) => isNumber(value) && value > 1; |
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 asHours = (duration) => { | |
| const stepOne = msToHours(duration); | |
| const stepTwo = valueIf(overOne, stepOne); | |
| const stepThree = falseOr(Math.round(stepTwo)); | |
| const stepFour = falseOr(PostFixHours(stepThree)); | |
| return stepFour; | |
| } |
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 asHours = compose(falseOr(postFixHours), falseOr(Math.round), valueIf(overOne, stepOne?), msToHours); |
OlderNewer