11import React , { Component } from 'react'
22import { Link , Route } from 'react-router-dom'
3- import ReactTooltip from 'react-tooltip'
43import { colour_contrast , group_by } from '../../utils'
54import { If , Bull } from '../shared/Tools'
6- import { CalendarCheck , CalendarPlus , CalendarTimes } from '../shared/Svgs'
75import AptModal from './AptModal'
86
97const LS_KEY = '_tcs_user_data_'
10- // matches value in appointments.scss
11- const NARROW = 750
128
139const group_appointments = apts => {
1410 // group appointments by month then day
15- return group_by ( apts , a => a . start . match ( / \d { 4 } - \d { 2 } / ) [ 0 ] )
11+ return group_by ( apts , a => a . start . substr ( 0 , 7 ) )
1612 . map ( apts_ => ( {
1713 date : apts_ [ 0 ] . start ,
18- appointments : group_by ( apts_ , a => a . start . match ( / \d { 4 } - \d { 2 } - \d { 2 } / ) [ 0 ] )
14+ appointments : group_by ( apts_ , a => a . start . substr ( 0 , 10 ) )
1915 } ) )
2016}
2117
2218const Apt = ( { apt, props, appointment_attendees} ) => {
2319 const full = apt . attendees_max === apt . attendees_count
24- const narrow = window . innerWidth < NARROW
25- const colour = full ? '#CCC' : apt . service_colour
26- let Icon , tip
20+ let status
2721 const spaces_ctx = { spaces : apt . attendees_max - apt . attendees_count }
2822 if ( appointment_attendees && appointment_attendees [ apt . id ] !== undefined ) {
29- Icon = CalendarCheck
30- tip = props . config . get_text ( full ? 'no_spaces_attending' : 'spaces_attending' , spaces_ctx )
23+ status = props . config . get_text ( full ? 'no_spaces_attending' : 'spaces_attending' , spaces_ctx )
3124 } else {
32- Icon = full ? CalendarTimes : CalendarPlus
33- tip = props . config . get_text ( full ? 'no_spaces' : 'spaces' , spaces_ctx )
25+ status = props . config . get_text ( full ? 'no_spaces' : 'spaces' , spaces_ctx )
3426 }
3527 return (
3628 < Link to = { props . root . url ( `appointment/${ apt . link } ` ) } className = "tcs-item" >
37- < div className = { `tcs-apt ${ colour_contrast ( colour ) } ` } style = { { background : colour } } data-tip = { tip } >
38- < div >
39- < Icon />
40- < span > { props . config . date_fns . format ( apt . start , 'HH:mm' ) } </ span >
41- < span > { apt . topic } </ span >
42- { narrow && < br /> }
43- < span > ({ apt . service_name } )</ span >
29+ < div className = { `tcs-apt ${ colour_contrast ( apt . service_colour ) } ` } style = { { background : apt . service_colour } } >
30+ < div style = { { fontWeight : 700 , marginRight : 10 } } >
31+ { props . config . date_fns . format ( apt . start , 'HH:mm' ) }
32+ </ div >
33+ < div className = "tcs-truncate" >
34+ { apt . topic } < Bull /> { apt . service_name }
35+ </ div >
36+ < div className = "tcs-right" style = { { fontWeight : 700 } } >
37+ { props . config . format_money ( apt . price ) }
38+ </ div >
39+ < div className = "tcs-truncate" style = { { gridColumn : 2 } } >
40+ { status }
4441 </ div >
4542 < div className = "tcs-right" >
46- < span > { props . config . format_time_diff ( apt . finish , apt . start ) } </ span >
47- { narrow ? < br /> :< Bull /> }
48- < span > { props . config . format_money ( apt . price ) } </ span >
43+ { props . config . format_duration ( apt . finish , apt . start ) }
4944 </ div >
5045 </ div >
5146 </ Link >
@@ -57,9 +52,8 @@ const AptDayGroup = ({appointments, props, appointment_attendees}) => {
5752 return (
5853 < div className = "tcs-apt-group-day" >
5954 < div className = "tcs-day" >
60- { props . config . date_fns . format ( first_apt . start , 'Do' ) }
61- < br />
6255 { props . config . date_fns . format ( first_apt . start , 'ddd' ) }
56+ < div className = "tcs-day-no" > { props . config . date_fns . format ( first_apt . start , 'd' ) } </ div >
6357 </ div >
6458 < div >
6559 { appointments . map ( apt => (
@@ -114,7 +108,6 @@ class Appointments extends Component {
114108 appointments,
115109 more_pages : appointments . count > appointments . results . length + on_previous_pages ,
116110 } )
117- ReactTooltip . rebuild ( )
118111 }
119112
120113 signin ( ) {
@@ -182,7 +175,6 @@ class Appointments extends Component {
182175 </ div >
183176 ) ) }
184177
185- < ReactTooltip effect = "solid" />
186178 < If v = { this . state . page > 1 || this . state . more_pages } >
187179 < div className = "tcs-pagination" >
188180 < Link
0 commit comments