handleChangeScoringSetting

PHOTO EMBED

Thu Sep 19 2024 12:13:20 GMT+0000 (Coordinated Universal Time)

Saved by @alfred.roshan

  handleChangeScoringSetting = newScoringSetting => {
    const { surveyId, currentSurveyId, consultantId, scoringSetting } = this.state;

    // const matrixWorkshopsRef = firebase
    //   .firestore()
    //   .collection(consultantId ? 'portfolio-surveys-consultants' : 'surveys')
    //   .doc(surveyId ? surveyId : currentSurveyId);

    if (scoringSetting !== newScoringSetting) {
      this.setState({
        scoringSetting: newScoringSetting,
      });

      const body = {
        scoringSettings: newScoringSetting,
      };

      updateConsultantsOrSurveyProperty({
        surveyId,
        consultantId,
        property: "scoringSettings"
      }, body).then((res) => {
        console.log(`Updated scoring setting`, res);
      }).catch((err) => {
        console.log("Error updating scoring setting", err)
      })

      // matrixWorkshopsRef
      //   .update({
      //     scoringSetting: newScoringSetting,
      //   })
      //   .then(() => {
      //     console.log(`Updated scoring setting`);
      //   })
      //   .catch(error => {
      //     console.log('Updated scoring setting');
      //   });
    }
  };
content_copyCOPY