From 0925f365204ca3254d21af0575b7f625bfeb3bf5 Mon Sep 17 00:00:00 2001 From: Chetna Joshi Date: Mon, 22 Jun 2020 14:09:52 +0530 Subject: [PATCH] fixed some issues --- .../EventInvitation/InvitationScreen.js | 20 +++++++++-- .../EventSignupInvitation.js | 33 ++++++++++++++----- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/src/containers/EventInvitation/InvitationScreen.js b/src/containers/EventInvitation/InvitationScreen.js index bcdcc9857..1161da833 100644 --- a/src/containers/EventInvitation/InvitationScreen.js +++ b/src/containers/EventInvitation/InvitationScreen.js @@ -77,6 +77,7 @@ class InvitationScreen extends PureComponent { responseText: "", isUpdateEvent: false, isInvBtnDisable: false, + defaultSelectedSlots: [] // isShowDashboardBtn: false }; } @@ -151,6 +152,17 @@ class InvitationScreen extends PureComponent { isEventSubmited: true }); } + } else { + + let defaultSelectedSlots = this.state.defaultSelectedSlots; + nextProps.eventProfileDetail.eventProfileDetail.eventSlotsList.forEach(element => { + let maxAllowed = element.maxAllowed; + let totalSignedup = element.totalSignedup; + + if (totalSignedup < maxAllowed || maxAllowed === 0) { + defaultSelectedSlots.push(element.eventSlotId); + } + }); } this.setState({ @@ -183,7 +195,7 @@ class InvitationScreen extends PureComponent { if (nextProps.updateInvitationRes !== null) { - console.log("nextProps.updateInvitationRes, ",nextProps.updateInvitationRes); + console.log("nextProps.updateInvitationRes, ", nextProps.updateInvitationRes); this.setState({ isUpdateEvent: false, isInvBtnDisable: false, @@ -194,7 +206,7 @@ class InvitationScreen extends PureComponent { } else if (nextProps.updateInvitationResError !== null) { - console.log("nextProps.updateInvitationResError, ",nextProps.updateInvitationResError); + console.log("nextProps.updateInvitationResError, ", nextProps.updateInvitationResError); this.setState({ isUpdateEvent: false, @@ -302,7 +314,9 @@ class InvitationScreen extends PureComponent { this.props.navigateToUpdateEventInvitation(eventId, false, this.state.invitationNote, rsvp, userType, this.state.selectedSlot, this.state.userName, this.state.token); }) } else { - this.props.navigateToUpdateEventInvitation(eventId, false, this.state.invitationNote, rsvp, userType, this.state.selectedSlot, this.state.userName, this.state.token); + + let selectedSlots = this.state.selectedSlot.length === 0 ? this.state.defaultSelectedSlots : this.state.selectedSlot; + this.props.navigateToUpdateEventInvitation(eventId, false, this.state.invitationNote, rsvp, userType, selectedSlots, this.state.userName, this.state.token); } } } diff --git a/src/layouts/EventSignupInvitation/EventSignupInvitation.js b/src/layouts/EventSignupInvitation/EventSignupInvitation.js index de4094dbc..71543b8ee 100644 --- a/src/layouts/EventSignupInvitation/EventSignupInvitation.js +++ b/src/layouts/EventSignupInvitation/EventSignupInvitation.js @@ -81,8 +81,17 @@ class EventSignupInvitation extends React.Component { } handleShowEdit = (value) => { + this.setState({ isShowEdit: value + }, () => { + let eventSlots = []; + this.state.currentEventInvitation.event.eventSlotsList.forEach(element => { + eventSlots.push(element.eventSlotId); + }); + + this.invitationRightRef.current.showSelectedSlot(eventSlots, false); + this.invitationRightRef.current.showSelectedSlot(this.state.currentEventInvitation.slotIdList, true); }); } @@ -98,10 +107,12 @@ class EventSignupInvitation extends React.Component { isShowSlotDetail: false, isShowEdit: false, selectedSlot: [...selectedSlots] + }, () => { + this.handleShowSlotDetail(true); }); if (value.event.eventSlotsList.length > 0) { - + this.setState({ isAllSlotsFull: false }); value.event.eventSlotsList.forEach(element => { @@ -115,8 +126,6 @@ class EventSignupInvitation extends React.Component { this.setState({ isAllSlotsFull: true }); } - this.handleShowSlotDetail(true); - if (this.invitationRightRef && this.invitationRightRef.current) { this.invitationRightRef.current.showSelectedSlot(selectedSlots, true); } @@ -184,11 +193,19 @@ class EventSignupInvitation extends React.Component { handleSlotSelection = (e, slotId) => { let selectedSlot = this.state.selectedSlot; + + console.log("handle solt selection, ", selectedSlot); + console.log("slotId, ", slotId); + console.log("isExists, ", selectedSlot.indexOf(slotId)); + if (e.target.checked) { - selectedSlot.push(slotId); - this.setState({ - selectedSlot: selectedSlot - }); + + if (selectedSlot.indexOf(slotId) === -1) { + selectedSlot.push(slotId); + this.setState({ + selectedSlot: selectedSlot + }); + } } else { let index = selectedSlot.indexOf(slotId); @@ -272,7 +289,7 @@ class EventSignupInvitation extends React.Component { invitation.rsvp = nextProps.updateInvitationRes.signup.rsvp; invitation.event.eventSlotsList = nextProps.updateInvitationRes.signup.event.eventSlotsList; invitation.event.slotIdList = selectedSlots; - invitation.slotIdList = selectedSlots; + invitation.slotIdList = [...selectedSlots]; signupData[this.state.updateIndex] = invitation invitationData.signupList = signupData; -- GitLab