diff --git a/src/router.imba b/src/router.imba index d7605e2..70fe604 100644 --- a/src/router.imba +++ b/src/router.imba @@ -18,7 +18,6 @@ import "./views/choose-slot.imba" import "./main.css" global css - body jc@portrait:flex-end .active filter:hue-rotate(45deg) bxs:md .clickable us:none cursor@hover:pointer o@hover:0.7 tween:opacity 300ms .bordered bd:2px solid violet5 rd:10px diff --git a/src/ui/choose-slot.imba b/src/ui/choose-slot.imba index 7384289..e52797a 100644 --- a/src/ui/choose-slot.imba +++ b/src/ui/choose-slot.imba @@ -1,4 +1,4 @@ -import bookings from "../api/bookings_2023_02_01.json" # bookings.where ending_date >= $date and starting_date <= $date sort b sort_by starting_date +import bookings from "../api/bookings_2023_02_01.json" # bookings.where ending_date >= $date and starting_date <= $date + 3 days sort b sort_by starting_date # make objects for booking in bookings @@ -8,13 +8,10 @@ for booking in bookings import sh from "../ui/slot-size-input.imba" let h = + scope: 3days resolution: 15minutes date: do R.param('alt-day') || R.param('date') - next_day: do - return #next_day if #next_day - let day = new Date(h.date!) - day.setDate(day.getDate! + 1) - #next_day = day + scope_day: do h.move_date h.date!, h.scope slots: do #slots ||= h.calculate_slots! @@ -22,7 +19,7 @@ let h = calculate_slots: do let slots = [] unless bookings.length - slots.push start: h.date!, end: h.next_day! + slots.push start: h.date!, end: h.scope_day! else let first = bookings[0] if first.start > h.date! @@ -35,8 +32,8 @@ let h = let last = bookings[-1] - if last.end < h.next_day! - slots.push start: last.end, end: h.next_day! + if last.end < h.scope_day! + slots.push start: last.end, end: h.move_date(last.end, h.scope) for slot in slots h.adjust(slot, 'start') @@ -54,18 +51,40 @@ let h = calculate_duration: do |slot| Number(slot.end) - Number(slot.start) - duration: do + duration: do # size of booking in time h._duration ||= h.calculate_duration end: R.param('size'), start: sh.zero! + move_date: do |date, interval| + new Date(Number(date) + interval) + +let filtered_slots +let first_available + tag choose-slot def render - h._duration = 0 # reset cache + h._duration = first_available = 0 # reset cache + filtered_slots = h.slots!.filter do |s| s.duration >= h.duration! + let day = h.date!; day = h.move_date(day, day.getTimezoneOffset! * 1minutes) + let next_day = h.move_date(h.date!, 1days) + - if h.slots!.length - for d in h.slots! - if d.duration > h.duration! -

"{d.end}" + if filtered_slots.length + + for i in [0 .. 94] + else

"No slot available this day" - - \ No newline at end of file + if !filtered_slots.length or R.params['alt-date'] + +tag time-slot + def f n + "{if n < 10 then 0 else ''}{n}" + + get free? + for slot in filtered_slots + if data >= slot.start and (h.move_date(data, h.duration!) <= slot.end) + first_available ||= data + return true + false + + "{f data.getHours!}:{f data.getMinutes!}" \ No newline at end of file diff --git a/src/ui/plus-minus.imba b/src/ui/plus-minus.imba index 3f5d91c..da9fb40 100644 --- a/src/ui/plus-minus.imba +++ b/src/ui/plus-minus.imba @@ -7,7 +7,7 @@ tag plus-minus css m:10px > miw:50px h:50px p:19px 5px 0 ta:center fs:180% - + if value
decorate ? decorate(value) : value diff --git a/src/views/choose-slot.imba b/src/views/choose-slot.imba index 25d7eb9..bd50074 100644 --- a/src/views/choose-slot.imba +++ b/src/views/choose-slot.imba @@ -12,8 +12,9 @@ tag view-choose-slot - - "Book slot" +
+ // + // "Book slot" tag SizeHint < action-button prop size