confirmdeleteworkshop = async () => { const { surveyId, currentSurveyId, consultantId, workshops, workshopdata } = this.state; this.setState({ showdeleteworkshopmodal: false, loading: true, }); try { // Delete workshop if already present if (workshopdata && workshopdata.id) { // await firebase // .firestore() // .collection(consultantId ? 'portfolio-surveys-consultants' : 'surveys') // .doc(surveyId ? surveyId : currentSurveyId) // .collection('workshops') // .doc(workshopdata.id) // .delete() // .then(() => { // this.handleAddAuditLog( // 'delete', // this.state.assessmentType, // 'Assessment', // `${this.state.user.name} deleted the worksheet of ${workshopdata['Name of Person']} (${workshopdata.id})`, // 'worksheet', // ); // }); // Delete existing workshop const response = await removeWorkshop("workshop", { surveyId: surveyId, consultantId: consultantId, workshopId: workshopdata.id, }); this.handleAddAuditLog( 'delete', this.state.assessmentType, 'Assessment', `${this.state.user.name} deleted the worksheet of ${workshopdata['Name of Person']} (${workshopdata.id})`, 'worksheet', ); const deleteIndex = workshops.findIndex(item => item.id == workshopdata.id); workshops.splice(deleteIndex, 1); this.setState({ loading: false, workshopdata: {}, workshops: [...workshops], }); } } catch (ex) { console.log(ex.message); this.setState({ loading: false, workshopdata: {}, }); } };
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