Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

91
Visualizações
Efficient call of two PATCH functions in submit

I call two functions from a service in my submit function saveProfileContent() to save changed data via PATCH. This operation also works. Is it possible to make the two calls a bit more abstract, efficient and flexible? Do you have any ideas? I am curious about your contributions and ideas.

My Code:

// TS

**
   * To save entries in the ProfileContent
   */
  saveProfileContent() {
    this.submitted = true;

    // Stop here if form is invalid
    if (this.profileContentForm.invalid) {
      return { required: true };
    }

    const values = this.profileContentForm.value;
    console.log('Show values', values);
    const successText = 'Ihre Daten wurden erfolgreich gespeichert!';
    const errorText = 'Ihre Daten konnten nicht gespeichert werden!';
    this.profileContentAlertType = null;
    this.profileContentMessage = null;
    this.userAreaService.changeUserEntries(`${values.userId}`, values).subscribe(
      currentUserData => {
        console.log('You change the currentUserData', currentUserData);
        this.submitted = false;
        if (currentUserData.success) {
          this.profileContentAlertType = 'success';
          this.profileContentMessage = successText;
        } else {
          this.profileContentAlertType = 'error';
          this.profileContentMessage = errorText;
        }
      },
      error => {
        this.submitted = false;
        this.profileContentAlertType = 'error';
        this.profileContentMessage = errorText;
      });
    this.userAreaService.changeSetup(values).subscribe(
      currentMandantData => {
        console.log('You change the currentMandantData', currentMandantData);
        this.submitted = false;
        if (currentMandantData.success) {
          this.profileContentAlertType = 'success';
          this.profileContentMessage = successText;
        } else {
          this.profileContentAlertType = 'error';
          this.profileContentMessage = errorText;
        }
      },
      error => {
        this.submitted = false;
        this.profileContentAlertType = 'error';
        this.profileContentMessage = errorText;
      });
  }
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

looks good to me. although depending on constraints, it seems that there's an overlapping domains: data in user entry is most likely the same as the setup.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda