Commit d5881001 authored by Mattias J Duffy's avatar Mattias J Duffy
Browse files

added week hours

parent 7c7d7e56
Pipeline #1784 passed with stage
in 1 minute and 41 seconds
......@@ -101,7 +101,6 @@ class FacilitiesMap extends React.Component {
render (){
const {facilities,facility,classes,isMapOpen} = this.props
const {position,positionReady,fitBounds,maxBounds,mappedRoute,fitBoundsOptions,mapDialogOpen} = this.state
console.log(fitBounds)
let center,zoom;
try{
center = facility.facility_location.coordinate_location.coordinates;
......
......@@ -7,6 +7,8 @@ import TextwTitle from '../components/TextwTitle'
import FacilitiesMap from '../components/FacilitiesMap'
import classNames from 'classnames';
import Button from 'material-ui/Button';
import Chip from 'material-ui/Chip';
import WeekHours from './WeekHours';
import { toggleSidebar } from '../actions/ui';
const Sidebar = ({facility, isSidebarOpen, isSidebarMapOpen, toggleSidebarMap, facilities}) => {
......@@ -33,6 +35,18 @@ const Sidebar = ({facility, isSidebarOpen, isSidebarMapOpen, toggleSidebarMap, f
}
toggleSidebarMap()
}
let productChips;
try{
let index = -1;
productChips = facility.facility_product_tags.map((tag) => {
index++;
return (<Chip key={tag+index} label={tag} />)
})
}catch(e){
productChips = ''
}
return (
<Paper
className={classNames(['sidebar-root', (!isSidebarOpen && 'sidebar-open'), (isSidebarOpen && 'sidebar-closed')])}>
......@@ -44,11 +58,13 @@ const Sidebar = ({facility, isSidebarOpen, isSidebarMapOpen, toggleSidebarMap, f
</div>
<Divider className={'sidebar-divider'}/>
<div className={'sidebar-label-holder'}>
<TextwTitle label="Location" content="The Johnson Center"/>
<TextwTitle label="Menu" content="https://amenufromaplace.com"/>
<TextwTitle label="Location" content="The Johnson Center"/>
<TextwTitle label="Labels"
content=""/>
<TextwTitle label="Building" content="The Johnson Center"/>
<TextwTitle label="Address" content="https://amenufromaplace.com"/>
<TextwTitle label="Phone Number" content="The Johnson Center"/>
<TextwTitle label="Tags" content={<div className='chip-holder'>{productChips}</div>}/>
<TextwTitle label="Hours" content={<WeekHours facility={facility}/>}/>
</div>
<div className={'sidebar-row2'}>
<FacilitiesMap isMapOpen={isSidebarMapOpen} facilities={facilities} facility={facility}/>
......
import React from 'react'
import {withStyles} from 'material-ui/styles';
import {facilities} from '../reducers/api';
const WeekHours = ({facility}) => {
const convert_am_pm = (time) => {
const timeArr = time
.split(":")
.map((item) => {
return Number(item)
});
let am_pm = "am"
if (timeArr[0] > 12) {
timeArr[0] = timeArr[0] - 12
am_pm = "pm"
}
if (timeArr[1] === 0) {
timeArr[1] = ""
} else {
timeArr[1] = ":" + timeArr[1]
}
return timeArr[0] + timeArr[1] + am_pm;
}
const weekDays = [
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat",
"Sun"
]
let output = [];
try {
const schedule = facility.main_schedule.open_times;
for (let dayOfWeek = 0; dayOfWeek < 7; dayOfWeek++) {
let startDay,
endDay,
startTime,
endTime;
let hours = null;
for (let i = 0; i < schedule.length; i++) {
startDay = schedule[i].start_day;
endDay = schedule[i].end_day;
startTime = schedule[i].start_time;
endTime = schedule[i].end_time;
if (dayOfWeek === startDay) {
hours = convert_am_pm(startTime) + " - " + convert_am_pm(endTime);
break;
} else if (dayOfWeek > startDay && dayOfWeek < endDay) {
hours = '24 hours';
break;
}
}
console.log(dayOfWeek)
if (hours === null) {
hours = 'Closed'
}
output[dayOfWeek] = (
<div key={facility.slug + dayOfWeek} className='week-hours-row'>
<div className='week-hours-day'>{weekDays[dayOfWeek]}</div>
<div className='week-hours-times'>{hours}</div>
</div>
)
}
} catch (e) {}
return (
<div>
{output}
</div>
)
};
export default WeekHours;
\ No newline at end of file
......@@ -31,7 +31,7 @@
}
.sidebar-divider {
margin: 16px;
margin: 16px !important;
}
.sidebar-row1 {
......@@ -61,6 +61,10 @@
width: 100%;
}
.chip-holder {
display: flex;
height:32px;
}
@media screen and (max-width: map-get($breakpoints, lg)) {
.sidebar-root {
display: none !important;
......
......@@ -9,7 +9,6 @@
font-size: 14px;
text-overflow: ellipsis;
width: 100%;
margin:8px;
white-space: nowrap;
overflow: hidden;
color:#354052;
......
.week-hours-row{
display: flex;
font-size: 14px;
color:#354052;
}
.week-hours-day{
font-family: Roboto-Regular,Helvetica-Neue;
margin-right: 16px;
// width:28px;
}
.week-hours-times{
font-family: Roboto-Medium;
margin-bottom: 4px;
}
\ No newline at end of file
......@@ -9,9 +9,7 @@
@import './components/favoriteButton';
@import './components/sidebar';
@import './components/textwTitle';
@import './components/weekHours';
@import './containers/facilityCard';
@import './containers/layout';
.something{
display: flex;
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment