async changeLanguage()

in frontend/src/app/customer-service-agent/case-history/case-history.component.ts [128:152]


  async changeLanguage() {
    this.agentLanguage = this.languageControl.value?.value || "en";
    this.showTranslationForm = false;
    this.messages = await Promise.all(this.messages.map(async (message: ChatMessage) => {
      if (message.language != this.agentLanguage) {
        const translateRes: any = await firstValueFrom(this.customerServiceAgentService.translateText(message.text, this.agentLanguage))
        message.text = translateRes.output_text;
      }
      return message;
    }));
    this.cases = await Promise.all(this.caseHistory.map(async (conversation: Conversation) => {
      if (conversation.summary) {
        const translateResSummary: any = await firstValueFrom(this.customerServiceAgentService.translateText(conversation.summary, this.agentLanguage))
        conversation.summary = translateResSummary.output_text;
      }
      if (conversation.title) {
        const translateResTitle: any = await firstValueFrom(this.customerServiceAgentService.translateText(conversation.title, this.agentLanguage))
        conversation.title = translateResTitle.output_text;
      }

      return conversation;
    }));


  }