saveWorkshopAnswerEntry -- Save new comment in iro to answerEntries
Thu Sep 19 2024 09:53:08 GMT+0000 (Coordinated Universal Time)
Saved by
@alfred.roshan
saveWorkshopAnswerEntry = () => {
const { surveyId, currentSurveyId, consultantId, selectedworkshop } = this.state;
console.log("selectedworkshop in saveWorkshopAnswerEntry", selectedworkshop)
// const matrixWorkshopsRef = firebase
// .firestore()
// .collection(consultantId ? 'portfolio-surveys-consultants' : 'surveys')
// .doc(surveyId ? surveyId : currentSurveyId)
// .collection('workshops')
// .doc(selectedworkshop.id);
const updatedWorkshop = {
...selectedworkshop,
answeredEntries: [...selectedworkshop.answeredEntries],
};
const newWorkshops = Array.from(this.state.workshops || []);
const workshopIndex = newWorkshops.findIndex(item => item.id === updatedWorkshop.id);
if (workshopIndex > -1) {
newWorkshops[workshopIndex] = updatedWorkshop;
this.setState({
workshops: newWorkshops,
selectedworkshop: updatedWorkshop,
});
} else {
this.setState({
selectedworkshop: updatedWorkshop,
});
}
saveToWorkshopAnswerEntry({
surveyId,
consultantId,
workshopId: selectedworkshop.id,
type: "impact",
}, [...selectedworkshop.answeredEntries]).then((res) => {
console.log("added to workshop entry", res)
}).catch(error => {
console.log('error saving entry');
});
// Create POST api to answeredEntries in Porfolio-survey-consultatnts/survey Models or WorkshopsModel?
// matrixWorkshopsRef
// .update({
// answeredEntries: [...selectedworkshop.answeredEntries],
// })
// .then(() => {
// console.log(`saved entry`);
// })
// .catch(error => {
// console.log('error saving entry');
// });
};
content_copyCOPY
Comments