import * as React from 'react' import { groupBy } from 'lodash' import * as moment from 'moment' import * as momentTimezone from 'moment-timezone' import * as humanize from '../../utils/humanize' const styles = (...styles: object[]) => Object.assign({}, ...styles) const linkStyle = { cursor: 'pointer', textDecoration: 'none', color: '#0176FF', } const fontFamily = `'Helvetica', 'Arial', sans-serif` const Column = ({ children, style, ...rest }: any): JSX.Element => {children} const Row = ({ children, style, ...rest }: any): JSX.Element => {children}
const MeetingHeader = ({ children }: any): JSX.Element => { const style = { paddingBottom: '10px' } return ( {children} ) } const MeetingFooter = ({ calendarUrl }: any): JSX.Element => { const style = { textAlign: 'center', fontSize: '12px', } return ( Don’t see a time that works? Grab another time on my calendar {/* https://s3.amazonaws.com/drift-prod-static/assets/bolt-img.png is a hosted version of bolt-img.png */} Meetings by Drift ) } interface IMeetingNameProps { name: string, } const MeetingName = ({ name }: IMeetingNameProps): JSX.Element => { const style = { fontWeight: 'bold', fontSize: '16px', } as React.CSSProperties return {name} } const computeAvailabilitySlotsByDate = (slots: number[], timezone: string) => { return groupBy(slots, slot => momentTimezone.tz(slot, timezone).startOf('day').valueOf()) } interface IMeetingTimesProps { meetingBaseUrl: string, meetingTimes: number[], meetingDuration: number, timezone: string, } const MeetingTime = ({ scheduleTimeUrl, meetingTime, meetingDuration, displayTimezone }: any): JSX.Element => { const startTime = moment(new Date(meetingTime)).tz(displayTimezone) const endTime = moment(startTime).add(meetingDuration, 'minutes') const isCrossMeridiem = (startTime.format('a') !== endTime.format('a')) const startTimeString = isCrossMeridiem ? startTime.format('h:mma').slice(0, -1) : startTime.format('h:mm') const endTimeString = endTime.format('h:mma').slice(0, -1) const style = { paddingTop: '8px', paddingBottom: '8px', background: '#FAFBFC', fontWeight: 'bold', border: '1px solid #B5D2E1', borderRadius: '3px', textAlign: 'center', } return ( {startTimeString} – {endTimeString} ) } const SwimlaneHeader = ({ children }: any): JSX.Element => { const style = { fontWeight: 'bold', paddingTop: '8px', paddingBottom: '4px', textAlign: 'center', } return ( {children} ) } const MeetingDateSwimlane = ({ children, meetingDate, displayTimezone, isLast }: any): JSX.Element => { const style = isLast ? {} : { paddingRight: '14px' } return ( {moment(new Date(meetingDate)).tz(displayTimezone).format('ddd, MMM D')} {children} ) } const MeetingTimes = ({ meetingBaseUrl, meetingTimes, meetingDuration, timezone }: IMeetingTimesProps): JSX.Element => { const availabilitySlotsByDate = computeAvailabilitySlotsByDate(meetingTimes, timezone) const style = { paddingTop: '4px', paddingBottom: '10px', borderTop: '1px solid #E1EEF4', } return ( Select a time below to instantly book a meeting {Object.keys(availabilitySlotsByDate).sort().slice(0, 3).map((date, i) => ( {availabilitySlotsByDate[date].sort().slice(0, 3).map((availabilitySlot, j) => ( ))} ))} ) } interface IMeetingTimezoneProps { agentTimezone: string, widgetColor: string, } const MeetingTimezone = ({ agentTimezone, widgetColor }: IMeetingTimezoneProps): JSX.Element => { const style = { display: 'inline-block', borderRadius: '3px', backgroundColor: `#${widgetColor}`, color: '#FFFFFF', } as React.CSSProperties const zoneAbbr = momentTimezone.tz(agentTimezone).format('z') return ( Timezone:  {zoneAbbr}  ) } interface IMeetingDetailsProps { agentName: string, agentTimezone: string, meetingDuration: number, } const MeetingDetails = ({ agentName, meetingDuration }: IMeetingDetailsProps): JSX.Element => { const style = { fontWeight: 'bold', fontSize: '14px', whiteSpace: 'pre', } as React.CSSProperties let meetingDetailsString = '' if (agentName) { meetingDetailsString += `With ${agentName} · ` } meetingDetailsString += `${humanize.humanizeMeetingDuration(meetingDuration)}` return {meetingDetailsString} } interface IOneClickSchedulingProps { meetingBaseUrl: string, agentAvatarUrl: string, agentName: string, meetingDuration: number, meetingName: string, agentTimezone: string, availabilitySlots: number[], widgetColor: string, } class OneClickScheduling extends React.Component { constructor(props: IOneClickSchedulingProps) { super(props) } render() { const { meetingBaseUrl, agentAvatarUrl, agentName, availabilitySlots, meetingDuration, meetingName, agentTimezone, widgetColor, } = this.props return ( {agentAvatarUrl && ( )} ) } } export default OneClickScheduling