handleSubmitReasonForMaxOrAverage && handleSaveBooleanValue
Thu Sep 19 2024 12:13:58 GMT+0000 (Coordinated Universal Time)
Saved by
@alfred.roshan
handleSubmitReasonForMaxOrAverage = e => {
const { surveyId, currentSurveyId, consultantId, reasonForMaxOrAverage } = this.state;
this.setState({ loading: true });
this.setState({ maxOrAverageSelectionWarningModal: false });
const body = {
reasonForMaxOrAverage: reasonForMaxOrAverage
}
updateConsultantsOrSurveyProperty({
surveyId,
consultantId,
property: "reasonForMaxOrAverage"
}, body).then((res) => {
console.log("updated the reason for max and average", res)
this.setState({ loading: false });
}).catch((err) => {
console.log("error while updating", err)
this.setState({ loading: false });
})
// const surveysRef = firebase
// .firestore()
// .collection(this.state.consultantId ? 'portfolio-surveys-consultants' : 'surveys');
// surveysRef
// .doc(this.state.surveyId ? this.state.surveyId : this.state.currentSurveyId)
// .update({
// reasonForMaxOrAverage: this.state.reasonForMaxOrAverage,
// })
// .then(() => {
// this.setState({ loading: false });
// })
// .catch(error => {
// console.log('error updating parent topics');
// });
};
handleSaveBooleanValue = (type, value) => {
console.log("handleSaveBooleanValue", type, value)
this.setState({ [type]: value });
const payload = {
[type]: value,
}
updateConsultantsOrSurveyProperty(
{
surveyId: this.state.surveyId,
consultantId: this.state.consultantId,
property: type,
},
payload,
).then(() => { })
.catch(error => {
console.log('error updating');
});
// const surveysRef = firebase
// .firestore()
// .collection(this.state.consultantId ? 'portfolio-surveys-consultants' : 'surveys');
// surveysRef
// .doc(this.state.surveyId ? this.state.surveyId : this.state.currentSurveyId)
// .update({
// [type]: value,
// })
// .then(() => { })
// .catch(error => {
// console.log('error updating');
// });
};
content_copyCOPY
Comments