Files
nobat724_front/services/response.js
T
hamedandClaude Opus 4.8 7d65239615 feat(doctor): wire rich rating/review UI to multi-dimensional API
Connect the existing doctor-page review UI to the rebuilt backend contract
(see clinicpro feat/rating-multidimensional).

- page.js fetches the rating aggregate alongside comments and passes
  rateAggregate down to the chart (point / satisfaction / 5 dimensions).
- Submit form sends the five dimensions with doctor_uuid; comment/reply
  send {doctor_uuid, comment, parent}; 401/403 ERR_RATING_NOT_ELIGIBLE
  surface friendly guidance.
- Like/dislike call POST /like/{uuid} with value and update from the
  response; replies render nested.
- ModalAnswer gates the submit button on GET /rate/{uuid}/eligibility.
- services/response.js: getRateEligibility, postCommentsLike(uuid, value),
  drop unused patchDoctorRate. Fix hardcoded modal title; empty-state for
  no comments. Remove orphaned AnswerField.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-16 00:26:20 +03:30

146 lines
5.2 KiB
JavaScript

import { removeTokenHead } from "@/helper";
import api from "./api";
export const request = {
sendCode: (mobile, captcha_token) =>
api.post(
"api/v1/user/send-code",
{
mobile,
captcha_token,
},
removeTokenHead
),
getToken: (grant_type, client_id, client_secret, uuid, code, scope = "nobat724") => {
const formData = new URLSearchParams();
formData.append("grant_type", grant_type);
formData.append("client_id", client_id);
formData.append("client_secret", client_secret);
formData.append("uuid", uuid);
formData.append("code", code);
formData.append("scope", scope);
return api.post("oauth/token", formData, {
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Authorization: "",
},
});
},
postRefreshToken: (formData) => {
return api.post("oauth/token", formData, {
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Authorization: "",
},
});
},
getUserProfile: (uuid) => api.get(`/api/v1/user-profile/${uuid}`, { requireAuth: true }),
postUserProfile: (data) => api.post("api/v1/user-profile", data, { requireAuth: true }),
patchUserProfile: (data, uuid) =>
api.patch(`api/v1/user-profile/${uuid}`, data, { requireAuth: true }),
getUserInfo: (headers) => api.get("oauth/userinfo", { ...headers, requireAuth: true }),
getInsuranceType: () =>
api.get(`api/v1/insurances?type=basic`, { requireAuth: true }),
getSupplementaryInsurance: () =>
api.get(`api/v1/insurances?type=supplementary`, { requireAuth: true }),
getDoctors: (params) =>
api.get("api/v1/doctors", {
params,
headers: {
Authorization: "",
},
}),
getAppointmentWeeklySchedule: (uuid) =>
api.get(`api/v1/appointment-settings/weekly-schedule/${uuid}`),
postAppointmentWeeklySchedule: () =>
api.post("api/v1/appointment-settings/weekly-schedule/"),
patchAppointmentWeeklySchedule: (uuid) =>
api.patch(`api/v1/appointment-settings/weekly-schedule/${uuid}`),
deleteAppointmentWeeklySchedule: (uuid) =>
api.delete(`api/v1/appointment-settings/weekly-schedule/${uuid}`),
getAppointmentSlots: (doctor_uuid, date) =>
api.get(
`api/v1/appointment-slots?doctor_uuid=${doctor_uuid}&date=${date}`,
removeTokenHead
),
getMonthAvailability: (doctor_uuid, year, month) =>
api.get(`api/v1/appointment-settings/month-availability/${doctor_uuid}`, {
params: { year, month },
...removeTokenHead,
}),
postAppointment: (data) => api.post(`api/v1/appointment`, data, { requireAuth: true }),
getMyAppointments: (params) => api.get(`api/v1/appointments/user`, { params, requireAuth: true }),
postAppointmentPayment: (data) =>
api.post(`api/v1/payment/appointment`, data, { requireAuth: true }),
getPaymentConfig: () => api.get(`api/v1/payment/config`, { requireAuth: true }),
getPayment: (uuid) => api.get(`api/v1/payment/${uuid}`, { requireAuth: true }),
getMyPayments: (params) => api.get(`api/v1/my/payments`, { params, requireAuth: true }),
postDoctor: (data) => api.post("api/v1/doctor", data),
postImageUpload: (data) =>
api.post("file/upload/clinic_pro/doctor/field_image", data, {
headers: {
"Content-Type": "application/octet-stream",
"Content-Disposition": `file; filename="${data.name}"`,
"X-CSRF-Token": "",
},
}),
getDoctorServices: () =>
api.get("api/v1/categorys/doctor_services", removeTokenHead),
postDoctorComment: (data) => api.post("api/v1/comment", data, { requireAuth: true }),
getDoctorRate: (uuid) => api.get(`api/v1/rate/${uuid}`),
getRateEligibility: (uuid) =>
api.get(`api/v1/rate/${uuid}/eligibility`, { requireAuth: true }),
getDoctorComments: (uuid) => api.get(`api/v1/comments/${uuid}`),
postDoctorRate: (data) => api.post("api/v1/rate", data, { requireAuth: true }),
postCommentsLike: (commentUuid, value) =>
api.post(`api/v1/like/${commentUuid}`, { value }, { requireAuth: true }),
getClinicList: (params) =>
api.get("/api/v1/clinics", {
params,
headers: {
Authorization: "",
},
}),
getDoctorAddress: (location_id) =>
api.get(`api/v1/clinic-pro/doctor-address/${location_id}`, removeTokenHead),
getBlogs: (params) =>
api.get("api/v1/blogs", {
params,
headers: {
Authorization: "",
},
}),
getBlogTags: (params) =>
api.get("api/v1/categorys/tag", {
params,
headers: {
Authorization: "",
},
}),
getTopBlogs: () =>
api.get("api/v1/blogs/top", {
headers: {
Authorization: "",
},
}),
getSingleBlog: (uuid) =>
api.get(`api/v1/blog/${uuid}`, {
headers: {
Authorization: "",
},
}),
getRepresentationInfo: (uuid) =>
api.get(`api/v1/representation/${uuid}`, { requireAuth: true }),
getRepresentationDashboardMonthly: (uuid, year, month) =>
api.get(`api/v1/representation/${uuid}/dashboard/monthly`, {
params: { year, month },
requireAuth: true,
}),
getRepresentationDashboardYearly: (uuid, year) =>
api.get(`api/v1/representation/${uuid}/dashboard/yearly`, {
params: { year },
requireAuth: true,
}),
};