保誠-保戶業務員媒合平台
Tomas
2023-09-01 bce34327a0aa3d6ea8365423df9962c13f256ab4
PAMapp/shared/services/reviews.service.ts
@@ -1,12 +1,60 @@
import { http } from "./httpClient";
import { UserReviewsConsultantsParams } from "../models/reviews.model";
import { NotificationList, UserReviewPlatformRes, UserReviewParams } from "../models/reviews.model";
import { AppointmentLog } from "../models/appointment.model";
class ReviewsService {
  //客戶進行滿意度評分
  userReviewsConsultants(data: UserReviewsConsultantsParams) {
    return http.post('/satisfaction/create', data );
  //客戶進行滿意度評分(單筆)
  userReviewsConsultants(data: UserReviewParams) {
    return http.post('/satisfaction/score', data);
  }
  // 客戶進行滿意度(多筆)
  allUserReviewsConsultants(data: UserReviewParams[]) {
    return http.post('/satisfaction/score/all', data);
  }
  //取得所有評分紀錄
  async getMyReviewLog(): Promise<AppointmentLog[]> {
    return http.get('/satisfaction/getMySatisfaction').then(res => res.data);
  }
  /**
   * 顧問主動發送滿意度通知
   * @param appointmentId 預約的ID
   * @returns 回傳發送結果
   */
  async  sendSatisfactionToClient(appointmentId: number): Promise<any> {
    try {
      const response = await http.post(`/consultant/sendSatisfactionToClient/${appointmentId}`);
      // 弱掃TEST3: 判斷 response && response.data
      if (response) {
        return response && response.data;
      } else {
        throw new Error('http.post returned null-like value.');
      }
    } catch (error) {
      // 可以在此處處理錯誤或回傳預設值
      console.error('An error occurred while sending satisfaction to client:', error);
      throw error;
    }
  }
  // 通知小鈴鐺
  getMyPersonalNotification(): Promise<NotificationList[]> {
    return http.get('/personal_notification/getMyPersonalNotification').then(res => res.data);
  }
  // 目前登入者的所有小鈴鐺通知設定為已讀
  readAllMyNotification() {
    return http.post('/personal_notification/readAllMyNotification')
  }
  // 客戶填寫平台滿意度
  reviewPlatform(params: UserReviewParams): Promise<UserReviewPlatformRes> {
    return http.post('/satisfaction/score', params);
  }
}