visus-plus/web-app/src/Api/appointmentsApi.js
andrei 827cfb413a feat: Обновление профиля и смена пароля пользователя
Добавлены модальные формы для редактирования профиля и смены пароля.
Обновлены API запросы для работы с данными пользователя.
2025-06-03 19:13:04 +05:00

43 lines
1.3 KiB
JavaScript

import {createApi} from "@reduxjs/toolkit/query/react";
import {baseQueryWithAuth} from "./baseQuery.js";
export const appointmentsApi = createApi({
reducerPath: 'appointmentsApi',
baseQuery: baseQueryWithAuth,
tagTypes: ['Appointment'],
endpoints: (builder) => ({
getAppointments: builder.query({
query: (doctor_id) => `/appointments/doctor/${doctor_id}/`,
providesTags: ['Appointment'],
refetchOnMountOrArgChange: 5,
}),
getByPatientId: builder.query({
query: (id) => `/appointments/patient/${id}/`,
providesTags: ['Appointment'],
refetchOnMountOrArgChange: 5,
}),
createAppointment: builder.mutation({
query: (data) => ({
url: '/appointments/',
method: 'POST',
body: data,
}),
invalidatesTags: ['Appointment'],
}),
updateAppointment: builder.mutation({
query: ({id, data}) => ({
url: `/appointments/${id}/`,
method: 'PUT',
body: data,
}),
invalidatesTags: ['Appointment'],
}),
}),
});
export const {
useGetAppointmentsQuery,
useGetByPatientIdQuery,
useCreateAppointmentMutation,
useUpdateAppointmentMutation,
} = appointmentsApi;