onSubmit()

in genai-for-marketing/frontend/src/app/campaign-form/campaign-form.component.ts [36:73]


  onSubmit() {
    let obj = {
      "campaign_name": this.campaignForm.controls["name"].value,
      "theme": this.campaignForm.controls["theme"].value,
      "brief": {
        "gender_select_theme": this.campaignForm.controls["gender"].value,
        "age_select_theme": this.campaignForm.controls["ageGroup"].value,
        "objective_select_theme": this.campaignForm.controls["goal"].value,
        "competitor_select_theme": this.campaignForm.controls["competitor"].value
      }
    }
    if (this.campaignForm.controls["theme"].value === 'Another theme...') {
      obj = {
        "campaign_name": this.campaignForm.controls["name"].value,
        "theme": this.campaignForm.controls["otherTheme"].value,
        "brief": {
          "gender_select_theme": this.campaignForm.controls["gender"].value,
          "age_select_theme": this.campaignForm.controls["ageGroup"].value,
          "objective_select_theme": this.campaignForm.controls["goal"].value,
          "competitor_select_theme": this.campaignForm.controls["competitor"].value
        }
      }
    }
    if (this.campaignForm.valid) {
      this.showProgress = true;
      this.campaignServ.createCampaign(obj, this.userId).subscribe((res: any) => {
        this.docPreviewUrl = `https://docs.google.com/file/d/${res?.workspace_assets?.doc_id}/preview`;
        const checkbox = document.getElementById(
          'loader',
        ) as HTMLInputElement | null;

        if (checkbox != null) {
          checkbox.checked = true;
        }
        this.clear()
      });
    }
  }