Skip to content

Commit

Permalink
Merge branch 'ViewBookings' of github.com:Arushi1912/miteb-frontend i…
Browse files Browse the repository at this point in the history
…nto ViewBookings
  • Loading branch information
Arushi1912 committed Jan 27, 2019
2 parents 21c0fdc + a37f3c3 commit 5a69726
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/Services/firebaseDBService.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ function extractRooms (avl) {
})
}

async function getBlockedRooms (dates) {
export const getBlockedRooms = async (startDate, endDate) => {
let dates = getDateArr(startDate, endDate)
let rooms = []
let blocked
await firebaseDB.ref('blocked/').once('value')
Expand All @@ -147,7 +148,7 @@ async function getBlockedRooms (dates) {
export const fetchRooms = async (startDate, endDate, callback) => {
let dateArr = getDateArr(startDate, endDate)
let blockedRooms
await getBlockedRooms(dateArr).then(rooms => {
await getBlockedRooms(startDate, endDate).then(rooms => {
blockedRooms = rooms
})
return new Promise((resolve, reject) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const EventDetails = (props) => {
disabled
style={{ minWidth: 300 }}
/>
<Divider />
<Divider />
</div>
</List>
</div>
Expand Down
11 changes: 6 additions & 5 deletions src/components/ClassroomComponent/ViewBookingsComponent/Rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class RoomsContainer extends Component {
componentWillReceiveProps (newProps) {
let tempTaken = newProps.takenRooms ? newProps.takenRooms : this.state.takenRooms
let tempApproved = newProps.approvedRooms ? newProps.approvedRooms : this.state.approvedRooms
this.setState({ takenRooms: tempTaken, approvedRooms: tempApproved })
let tempBlocked = newProps.blockedRooms ? newProps.blockedRooms : this.state.blockedRooms
this.setState({ takenRooms: tempTaken, approvedRooms: tempApproved, blockedRooms: tempBlocked })
}

render () {
Expand Down Expand Up @@ -58,8 +59,8 @@ class RoomsContainer extends Component {
label={label}
style={styles.roomButton}
labelStyle={styles.roomButtonLabel}
// disabledBackgroundColor={'#FAE0DE'}
disabled={!(scope.state.takenRooms).includes(props.id)}
disabledBackgroundColor={(scope.state.blockedRooms).includes(props.id) ? '#FAE0DE' : ''}
disabled={!(scope.state.takenRooms).includes(props.id) || (scope.state.blockedRooms).includes(props.id)}
// color={(scope.state.takenRooms).includes(props.id) ? 'default' : 'secondary'}
default={(scope.state.takenRooms).includes(props.id)}
secondary={(scope.state.approvedRooms).includes(props.id)}
Expand Down Expand Up @@ -98,12 +99,12 @@ class RoomsContainer extends Component {
</div>
<div style={styles.buttonsRow}>
<MyRaisedButton id={3202} />
<MyRaisedButton id={3203} /> DIRECTOR
<MyRaisedButton id={3203} />
<MyRaisedButton id={3204} />
<MyRaisedButton id={3205} />
</div>
<div style={styles.buttonsRow}>
<MyRaisedButton id={3302} /> PARIKSHIT
<MyRaisedButton id={3302} />
<MyRaisedButton id={3303} />
<MyRaisedButton id={3304} />
<MyRaisedButton id={3305} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import DatePicker from 'material-ui/DatePicker'
import RoomsContainer from './Rooms'
import { connect } from 'react-redux'
import moment from 'moment'
import { fetchRooms, getDisabledDates, getBookingDetails, fetchApprovedRooms } from '../../../Services/firebaseDBService'
import { fetchRooms, getDisabledDates, getBookingDetails, fetchApprovedRooms, getBlockedRooms } from '../../../Services/firebaseDBService'
import { EventDetails } from './EventDetailsComponent'

class ViewBooking extends React.Component {
Expand All @@ -21,6 +21,7 @@ class ViewBooking extends React.Component {
dateSelected: false,
takenRooms: [],
approvedRooms: [],
blockedRooms: [],
fetchingRooms: true,
isRoomSelected: false,
selectedRoom: null,
Expand Down Expand Up @@ -64,6 +65,10 @@ class ViewBooking extends React.Component {
.catch(function (error) {
console.log(error)
})
getBlockedRooms(this.state.selectedDate, this.state.selectedDate)
.then(function (res) {
scope.setState({ blockedRooms: res })
})
}

handleDate (event, date) {
Expand Down Expand Up @@ -108,7 +113,7 @@ class ViewBooking extends React.Component {
required
/>
</div>
<RoomsContainer datesSelected={this.state.dateSelected} fetchingRooms={this.state.fetchingRooms} takenRooms={this.state.takenRooms} approvedRooms={this.state.approvedRooms} handleSelectedRoom={(temp) => this.handleSelectedRoom(temp)} />
<RoomsContainer datesSelected={this.state.dateSelected} fetchingRooms={this.state.fetchingRooms} takenRooms={this.state.takenRooms} approvedRooms={this.state.approvedRooms} blockedRooms={this.state.blockedRooms} handleSelectedRoom={(temp) => this.handleSelectedRoom(temp)} />
<div style={{ marginTop: '20px', textAlign: 'left' }}>
<EventDetails isMobile={this.props.isMobile} isRoomSelected={this.state.isRoomSelected} fetchingEventData={this.state.fetchingEventData} eventDetails={this.state.eventDetails} />
</div>
Expand Down

0 comments on commit 5a69726

Please sign in to comment.