From c80cdd4efb6b5f95fe14e6e7c78d7d5094cf4fc8 Mon Sep 17 00:00:00 2001 From: Marek Piasecki Date: Thu, 12 Jan 2023 21:41:49 +0100 Subject: [PATCH] confirmation page --- src/router.imba | 5 +++- src/ui/choose-slot.imba | 46 ++++++++++++++++++++++------- src/views/booking-confirmation.imba | 39 ++++++++++++++++++++++++ src/views/choose-slot.imba | 5 +--- 4 files changed, 79 insertions(+), 16 deletions(-) create mode 100644 src/views/booking-confirmation.imba diff --git a/src/router.imba b/src/router.imba index 70fe604..8f55d83 100644 --- a/src/router.imba +++ b/src/router.imba @@ -15,17 +15,20 @@ R.init(helpers: H, views: ['day-select', 'choose-slot', 'booking-confirmation'], import "./views/day-select.imba" import "./views/choose-slot.imba" +import "./views/booking-confirmation.imba" import "./main.css" global css .active filter:hue-rotate(45deg) bxs:md .clickable us:none cursor@hover:pointer o@hover:0.7 tween:opacity 300ms + .confirmed filter:invert(90%) + .hide d:none .bordered bd:2px solid violet5 rd:10px .bordered-complex > bd: 2px solid violet5 bdy:none @first bdt:2px solid violet6 rd:20px 20px 0 0 @last bdb:2px solid violet6 rd:0 0 20px 20px tag app - + imba.mount \ No newline at end of file diff --git a/src/ui/choose-slot.imba b/src/ui/choose-slot.imba index e52797a..aba3b3c 100644 --- a/src/ui/choose-slot.imba +++ b/src/ui/choose-slot.imba @@ -7,14 +7,14 @@ for booking in bookings import sh from "../ui/slot-size-input.imba" -let h = +global.Slot_h = let h = scope: 3days resolution: 15minutes - date: do R.param('alt-day') || R.param('date') + date: do let day = ( R.param('alt-date') || R.param('date') ); h.move_date(day, day.getTimezoneOffset! * 1minutes) scope_day: do h.move_date h.date!, h.scope slots: do - #slots ||= h.calculate_slots! + h._slots ||= h.calculate_slots! calculate_slots: do let slots = [] @@ -33,7 +33,7 @@ let h = let last = bookings[-1] if last.end < h.scope_day! - slots.push start: last.end, end: h.move_date(last.end, h.scope) + slots.push start: last.end, end: h.move_date(last.end, 730days) for slot in slots h.adjust(slot, 'start') @@ -57,14 +57,18 @@ let h = move_date: do |date, interval| new Date(Number(date) + interval) + f: do |n| "{if n < 10 then 0 else ''}{n}" + let filtered_slots let first_available tag choose-slot + css my: 20px + def render - h._duration = first_available = 0 # reset cache + h._slots = 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 day = h.date! let next_day = h.move_date(h.date!, 1days) @@ -74,11 +78,9 @@ tag choose-slot else

"No slot available this day" - 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 @@ -87,4 +89,26 @@ tag time-slot return true false - "{f data.getHours!}:{f data.getMinutes!}" \ No newline at end of file + get time_from do "{h.f data.getHours!}:{h.f data.getMinutes!}" + get time_to do let day = h.move_date(data, h.duration!); "{h.f day.getHours!}:{h.f day.getMinutes!}" + + css d:block fs:xx-small h:10px + &.activated bgc:violet7 zoom:2 + > .hide d:inline + &.active, &.activated c:violet9 fs:large h:40px lh: 45px + @hover bgc:violet9 c:white zoom:2 + .hide d:inline + + def action + if flags.contains('active') + R.write 'from', time_from + R.go R.to_path('booking-confirmation') + + + time_from + <.hide> + " - " + time_to + +R.setters['from'] = do |v| v.replace(':','!') +R.getters['from'] = do |v| v.replace('!',':') \ No newline at end of file diff --git a/src/views/booking-confirmation.imba b/src/views/booking-confirmation.imba new file mode 100644 index 0000000..c1f5f38 --- /dev/null +++ b/src/views/booking-confirmation.imba @@ -0,0 +1,39 @@ +import h from '../ui/slot-size-input.imba' + +tag view-booking-confirmation + + def render + let time_from = Slot_h.date! + time_from.setHours *R.params.from.split('!') + let time_to = Slot_h.move_date time_from, Slot_h.duration! + + + + " - - - " + +

+ duration + R.params.confirm ? "Cancel" : "Confirm" +

$card.timezone + +tag time-card + prop date + + prop date_s + prop time + prop timezone + + get process_date + let s = date.toString! + date_s = s.substr 0, 15 + time = s.substr 16, 8 + timezone = s.substr(34) + + def render + process_date + + + desc + <[d:rflex]> +

time +

date_s diff --git a/src/views/choose-slot.imba b/src/views/choose-slot.imba index bd50074..78a2614 100644 --- a/src/views/choose-slot.imba +++ b/src/views/choose-slot.imba @@ -12,10 +12,7 @@ tag view-choose-slot -
- // - // "Book slot" - + tag SizeHint < action-button prop size "{ size }h"