saveFinancialWorkshopAnswerEntry -- add to answeerEntries for Financial WS
Thu Sep 19 2024 09:54:15 GMT+0000 (Coordinated Universal Time)
Saved by
@alfred.roshan
saveFinancialWorkshopAnswerEntry = () => {
const { surveyId, currentSurveyId, consultantId, selectedfinancialworkshop } = this.state;
// const matrixWorkshopsRef = firebase
// .firestore()
// .collection(consultantId ? 'portfolio-surveys-consultants' : 'surveys')
// .doc(surveyId ? surveyId : currentSurveyId)
// .collection('financial-workshops')
// .doc(selectedfinancialworkshop.id);
const updatedWorkshop = {
...selectedfinancialworkshop,
answeredEntries: [...selectedfinancialworkshop.answeredEntries],
};
const newWorkshops = Array.from(this.state.financialworkshops || []);
const workshopIndex = newWorkshops.findIndex(item => item.id === updatedWorkshop.id);
if (workshopIndex > -1) {
newWorkshops[workshopIndex] = updatedWorkshop;
this.setState({
financialworkshops: newWorkshops,
selectedfinancialworkshop: updatedWorkshop,
});
} else {
this.setState({
selectedfinancialworkshop: updatedWorkshop,
});
}
saveToWorkshopAnswerEntry({
surveyId,
consultantId,
workshopId: selectedfinancialworkshop.id,
type: "financial",
}, [...selectedfinancialworkshop.answeredEntries]).then((res) => {
console.log("added to workshop entry", res)
}).catch(error => {
console.log('error saving entry');
});
// matrixWorkshopsRef
// .update({
// answeredEntries: [...selectedfinancialworkshop.answeredEntries],
// })
// .then(() => {
// console.log(`saved entry`);
// })
// .catch(error => {
// console.log('error saving entry');
// });
};
content_copyCOPY
Comments