| | |
| | | } |
| | | |
| | | // 顧問瀏覽自己所有的預約單紀錄觸發API |
| | | private viewAllAppointment(): void { |
| | | http.post('/consultant/record/allAppointmentsView').then(); |
| | | private async viewAllAppointment(): Promise<void> { |
| | | try { |
| | | const response = await http.post('/consultant/record/allAppointmentsView'); |
| | | if (response !== null) { |
| | | } else { |
| | | throw new Error('http.post returned null-like value.'); |
| | | } |
| | | } catch (error) { |
| | | console.error('An error occurred while viewing all appointments:', error); |
| | | throw error; |
| | | } |
| | | } |
| | | |
| | | // 讀取預約單時觸發,紀錄讀取預約單時間 |
| | |
| | | async createMemo(memoInfo: createdMemoInfo): Promise<AppointmentMemoInfo> { |
| | | try { |
| | | const response = await http.post('/appointment/memo/create', memoInfo); |
| | | if (response !== null) { |
| | | return response.data; |
| | | } else { |
| | | // 弱掃 test2: 改為判斷 !response |
| | | if (!response) { |
| | | throw new Error('http.post returned null-like value.'); |
| | | } else { |
| | | return response.data; |
| | | } |
| | | } catch (error) { |
| | | // 可以在此處處理錯誤或回傳預設值 |
| | |
| | | * @returns 回傳結案結果 |
| | | */ |
| | | async closeAppointment(appointmentInfo: ToDoneAppointment | ToCloseAppointment) { |
| | | // 弱掃Test5: 重新包裝為 promise |
| | | try { |
| | | const response = await http.post(`/appointment/close`, appointmentInfo); |
| | | if (response !== null) { |
| | | return response.data; |
| | | } else { |
| | | const responsePromise = new Promise((resolve, reject) => { |
| | | if (response !== null) { |
| | | resolve(response.data); |
| | | } else { |
| | | reject('http.post returned null-like value.'); |
| | | } |
| | | }); |
| | | if (!response) { |
| | | throw new Error('http.post returned null-like value.'); |
| | | } else { |
| | | return responsePromise.then(res => res); |
| | | } |
| | | } catch (error) { |
| | | // 可以在此處處理錯誤或回傳預設值 |
| | |
| | | |
| | | // 約訪通知 API |
| | | async informAppointment(appointmentInformation: ToInformAppointment) { |
| | | return http.post(`/notice/send`, appointmentInformation).then((res) => res.data); |
| | | try { |
| | | const response = await http.post(`/notice/send`, appointmentInformation); |
| | | if (response !== null) { |
| | | return response.data; |
| | | } else { |
| | | throw new Error('http.post returned null-like value.'); |
| | | } |
| | | } catch (error) { |
| | | console.error('An error occurred while informing appointment:', error); |
| | | // 可以在此處處理錯誤或回傳預設值 |
| | | throw error; |
| | | } |
| | | } |
| | | |
| | | |
| | | // 新增約訪記錄 |
| | | async createInterviewRecord(interviewRecordInfo: InterviewRecordInfo) { |
| | | return http.post('/interview_record/create', interviewRecordInfo).then(res => res.data); |
| | | try { |
| | | const response = await http.post('/interview_record/create', interviewRecordInfo); |
| | | if (response !== null) { |
| | | return response.data; |
| | | } else { |
| | | throw new Error('http.post returned null-like value.'); |
| | | } |
| | | } catch (error) { |
| | | console.error('An error occurred while creating interview record:', error); |
| | | // 可以在此處處理錯誤或回傳預設值 |
| | | throw error; |
| | | } |
| | | } |
| | | |
| | | // 修改約訪記錄 |