From 12917cd900deb541d18686a3a02b7721c2591da9 Mon Sep 17 00:00:00 2001 From: hamed <15238-genius.ha@users.noreply.drupalcode.org> Date: Mon, 15 Jun 2026 23:07:20 +0330 Subject: [PATCH] fix(doctor): correct rating/comment API paths to real backend routes Doctor page logged a 404 on GET /api/v1/clinicpro/rate/{uuid}. The frontend used a stale Drupal-era `clinicpro/` prefix; the Symfony API exposes these under /api/v1 directly. - response.js: rate/comments/like wrappers point to real routes (rate/{uuid}, comments/{uuid}, POST rate, POST comment, POST like/{commentUuid}); patch maps to POST upsert; writes use requireAuth. Add getDoctorComments wrapper. - doctor page: fetch comments from comments/{doctor.uuid} (was clinicpro/comments/{doctor.id}) and unwrap double-nested data. - ItemUser: postCommentsLike sends commentUuid for the toggle endpoint. Co-Authored-By: Claude Opus 4.8 --- app/component/comment/ItemUser.js | 7 +------ app/doctor/[slug]/page.js | 4 ++-- services/response.js | 13 +++++++------ 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/app/component/comment/ItemUser.js b/app/component/comment/ItemUser.js index b8087a2..84b422d 100644 --- a/app/component/comment/ItemUser.js +++ b/app/component/comment/ItemUser.js @@ -22,13 +22,8 @@ function ItemUser({ update, setUpdate, data }) { if (type === "like") setLoadingLike(true); else setLoadingDislike(true); - const body = { - comment_id: data.id, - like: type === "like" ? 1 : 0, - }; - try { - const res = await request.postCommentsLike(body); + const res = await request.postCommentsLike(data.uuid ?? data.id); } catch (err) { // err } finally { diff --git a/app/doctor/[slug]/page.js b/app/doctor/[slug]/page.js index a3efc2e..aac2221 100644 --- a/app/doctor/[slug]/page.js +++ b/app/doctor/[slug]/page.js @@ -52,9 +52,9 @@ async function Doctor({ params }) { doctor = resDoctor.data?.data?.data; if (doctor) { const resComments = await axiosInstance.get( - `${API_URL}/api/v1/clinicpro/comments/${doctor.id}` + `${API_URL}/api/v1/comments/${doctor.uuid}` ); - comments = resComments?.data?.data; + comments = resComments?.data?.data?.data; } } catch (error) {} diff --git a/services/response.js b/services/response.js index f76f076..b4a3d4c 100644 --- a/services/response.js +++ b/services/response.js @@ -87,12 +87,13 @@ export const request = { }), getDoctorServices: () => api.get("api/v1/categorys/doctor_services", removeTokenHead), - postDoctorComment: (data) => api.post("api/v1/clinicpro/comment", data), - getDoctorRate: (uuid) => api.get(`api/v1/clinicpro/rate/${uuid}`), - postDoctorRate: (data) => api.post("api/v1/clinicpro/rate", data), - patchDoctorRate: (data, uuid) => - api.patch(`api/v1/clinicpro/rate/${uuid}`, data), - postCommentsLike: (data) => api.post("/api/v1/clinicpro/like", data), + postDoctorComment: (data) => api.post("api/v1/comment", data, { requireAuth: true }), + getDoctorRate: (uuid) => api.get(`api/v1/rate/${uuid}`), + getDoctorComments: (uuid) => api.get(`api/v1/comments/${uuid}`), + postDoctorRate: (data) => api.post("api/v1/rate", data, { requireAuth: true }), + patchDoctorRate: (data) => api.post("api/v1/rate", data, { requireAuth: true }), + postCommentsLike: (commentUuid) => + api.post(`api/v1/like/${commentUuid}`, null, { requireAuth: true }), getClinicList: (params) => api.get("/api/v1/clinics", { params,