From 3c17a06c6b1e099a618957bf7c1ddf93e0244a22 Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期六, 05 八月 2023 18:00:53 +0800
Subject: [PATCH] Fixed: [弱掃] p17.2 Bad use of null-like value

---
 PAMapp/pages/questionnaire/_agentNo.vue |   98 +++++++++++++++++++++++++++++++++----------------
 1 files changed, 66 insertions(+), 32 deletions(-)

diff --git a/PAMapp/pages/questionnaire/_agentNo.vue b/PAMapp/pages/questionnaire/_agentNo.vue
index 2631fea..e8e39a8 100644
--- a/PAMapp/pages/questionnaire/_agentNo.vue
+++ b/PAMapp/pages/questionnaire/_agentNo.vue
@@ -67,7 +67,7 @@
     <div class="ques-container">
       <div class="pam-paragraph">
         <div class="mdTxt">
-            �閬岷������
+            �鈭圾�����
             <span class="hint text--bold">
                 (�銴)
             </span>
@@ -76,6 +76,12 @@
         <MultiSelectBtn class="mt-10"
           :mutiSelect.sync="myRequest.requirement"
           :options="requirementOptions" />
+      </div>
+      <div class="pam-paragraph">
+        <div class="mdTxt">隢株岷�撘�</div>
+        <SingleSelectBtn class="mt-10"
+           :singleSelected.sync="myRequest.consultationMethod"
+           :options="consultationMethodOptions" />
       </div>
       <div class="pam-paragraph">
         <div class="mdTxt">����批</div>
@@ -103,7 +109,7 @@
 
     <PopUpFrame :isOpen.sync="showDrawer">
       <div class="qaTextTitle mdTxt">
-        <strong>�閬岷������</strong>
+        <strong>�鈭圾�����</strong>
       </div>
       <div class="qa-dialog">
           <div v-for="(qaText,index) in quesAboutList" :key="index" >
@@ -166,8 +172,9 @@
 import { Gender } from '~/shared/models/enum/Gender';
 import { RegisterInfo } from '~/shared/models/registerInfo';
 import { AppointmentParams, AppointmentRequests } from '~/shared/models/appointment.model';
-import { UserReviewPlatformParams } from '~/shared/models/reviews.model';
 import { UserSetting } from '~/shared/models/account.model';
+import { SatisfactionType } from '~/shared/models/enum/satisfaction-type';
+import { UserReviewParams } from '~/shared/models/reviews.model';
 
   const roleStorage = namespace('localStorage');
   @Component
@@ -197,6 +204,17 @@
       {
         title:'憟單��',
         label:Gender.FEMALE,
+      }
+    ];
+
+    consultationMethodOptions = [
+      {
+        title: '蝺��',
+        label: 'online'
+      },
+      {
+        title: '蝺��',
+        label: 'offline'
       }
     ];
 
@@ -299,6 +317,7 @@
         selectTimesOptions: [],
       }],
       agentNo: '',
+      consultationMethod: '',
     };
 
     showDrawer= false;
@@ -335,7 +354,6 @@
     private setMyRequest(): void {
       const storageMyRequest = getRequestsFromStorage();
       const storageMyRequirement = this.recommendConsultantItem ? JSON.parse(this.recommendConsultantItem).requirements:[];
-      const contactTypePromise = accountSettingService.getUserAccountSetting();
 
       if (storageMyRequest) {
         this.myRequest = {
@@ -357,12 +375,15 @@
         removeRequestQuestionFromStorage();
       }
 
-      contactTypePromise.then((contactTypeDetail) => {
-            this.myRequest = {
-              ...this.myRequest,
-              ...contactTypeDetail
-            }
-      })
+      if (authService.isUserLogin()) {
+        accountSettingService.getUserAccountSetting().then((contactTypeDetail) => {
+              this.myRequest = {
+                ...this.myRequest,
+                ...contactTypeDetail
+              }
+        })
+      }
+
 
     }
 
@@ -399,20 +420,23 @@
 
     private getReservedData(appointmentInfo) {
       if (appointmentInfo) {
-        const hopeContactTime = appointmentInfo!.hopeContactTime.split("'")
-              .filter(item => item && item !== ',');
-        this.getAppointmentId(appointmentInfo);
-
-        return {
-            ...appointmentInfo,
-            hopeContactTime: hopeContactTime.map(item => {
+        const hopeContactTime = appointmentInfo!.hopeContactTime
+          ?  appointmentInfo!.hopeContactTime.split("'").filter(item => item && item !== ',').map(item => {
                 const info = item.split('��');
                 return {
                     selectWeekOptions: info[0].split(','),
                     selectTimesOptions: info[1].split(',')
                 }
-            }),
-            requirement: appointmentInfo.requirement.split(',')
+            })
+          :[{selectWeekOptions : [],selectTimesOptions: []}];
+        this.getAppointmentId(appointmentInfo);
+
+        return {
+            ...appointmentInfo,
+            hopeContactTime: hopeContactTime,
+            requirement: appointmentInfo.requirement
+                        ? appointmentInfo.requirement.split(',')
+                        : []
           }
       } else {
         return null;
@@ -428,21 +452,30 @@
 
     ////////////////////////////////////////////////////////////////////////////
 
-    sentDemand() {
+    async sentDemand() {
       if (this.isEditBtn) {
-        this.editAppointmentDemand();
+        await this.editAppointmentDemand();
       } else {
-        queryConsultantService.addFavoriteConsultant([this.$route.params.agentNo]).then(res => this.sentAppointmentDemand());
-      }
-       const editSettingInfo: UserSetting = {
-          name: this.myRequest.name,
-          phone: this.myRequest.phone,
-          email: this.myRequest.email,
+        // 雿輻 async/await 靘��甇交����蝯��
+        const addFavoriteAgentList = [{ agentNo: this.$route.params.agentNo, createdTime: new Date().toISOString() }];
+        const response = await queryConsultantService.addFavoriteConsultant(addFavoriteAgentList);
+
+        // 蝣箔�甇交����蝯�� null ��� undefined
+        if (response !== null) {
+          await this.sentAppointmentDemand();
+        } else {
+          throw new Error('queryConsultantService.addFavoriteConsultant returned null-like value.');
+        }
       }
 
-      accountSettingService.updateAccountSetting(editSettingInfo).then((_) => {
-          this.storageUserInfo(this.userInfo);
-      });
+      const editSettingInfo: UserSetting = {
+        name: this.myRequest.name,
+        phone: this.myRequest.phone,
+        email: this.myRequest.email,
+      };
+
+      await accountSettingService.updateAccountSetting(editSettingInfo);
+      this.storageUserInfo(this.userInfo);
     }
 
     private editAppointmentDemand() {
@@ -484,9 +517,10 @@
     }
 
     reviewPlatform(): void {
-      const reviewPlatformParams: UserReviewPlatformParams = {
+      const reviewPlatformParams: UserReviewParams = {
         appointmentId: this.appointmentId,
-        score: this.score
+        score: this.score,
+        type: SatisfactionType.SYSTEM
       };
       reviewsService.reviewPlatform(reviewPlatformParams).then((_) => {
         this.closeReservePopUp();

--
Gitblit v1.9.3