Files: 64e6e544f024c42315d1103b3b6735dfb4a20f84 / views / new-steps / pick-times.js
1506 bytesRaw
1 | const { h, computed } = require('mutant') |
2 | const DayPicker = require('../component/day-picker.js') |
3 | const TimePicker = require('../component/time-picker.js') |
4 | |
5 | module.exports = function PickTimes ({ state, prev, next }) { |
6 | const nextBtn = computed(state, ({ days, times }) => { |
7 | var opts = (!days.length || !times.length) |
8 | ? { disabled: 'disabled' } |
9 | : { className: '-primary', 'ev-click': next } |
10 | |
11 | return h('button', opts, 'Scry') |
12 | }) |
13 | |
14 | return h('ScryNewPickTimes', [ |
15 | DayPicker(state), |
16 | computed(state.days, days => { |
17 | if (!days.length) { |
18 | return h('div.time-picker-pristine', [ |
19 | h('label', 'Dates and Times'), |
20 | h('div.instruction', 'Select one or multiple dates') |
21 | ]) |
22 | } |
23 | |
24 | return h('div.time-picker', [ |
25 | h('label', `Same times for all dates (${days.length})`), |
26 | TimePicker(state), |
27 | h('div.timezone', [ |
28 | h('label', 'Timezone of your scry is'), |
29 | h('div.zone', [ |
30 | getTimezone(), |
31 | h('span', ['(UTC ', getTimezoneOffset(), ')']) |
32 | ]) |
33 | ]) |
34 | ]) |
35 | }), |
36 | h('div.actions', [ |
37 | prev ? h('button', { 'ev-click': prev }, 'Back') : null, |
38 | next ? nextBtn : null |
39 | ]) |
40 | ]) |
41 | } |
42 | |
43 | // functions |
44 | |
45 | function getTimezone () { |
46 | try { |
47 | return Intl.DateTimeFormat().resolvedOptions().timeZone |
48 | } catch (e) { |
49 | return '??' |
50 | } |
51 | } |
52 | |
53 | function getTimezoneOffset () { |
54 | const offset = new Date().getTimezoneOffset() / -60 |
55 | return offset > 0 ? `+${offset}` : offset |
56 | } |
57 |
Built with git-ssb-web