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'); // }); };
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter