design changes
This commit is contained in:
24
frontend/app/src/slice/QueueApi.ts
Normal file
24
frontend/app/src/slice/QueueApi.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
|
||||
import { baseUrl } from "../config/baseUrl";
|
||||
import { RootState } from "../config/store";
|
||||
|
||||
export const QueueApi = createApi({
|
||||
reducerPath: "QueueApi",
|
||||
baseQuery: fetchBaseQuery({
|
||||
baseUrl: `${baseUrl}/queue`,
|
||||
prepareHeaders: (headers, { getState }) => {
|
||||
const token = (getState() as RootState).auth.token;
|
||||
if (token) {
|
||||
headers.set("authorization", `Bearer ${token}`);
|
||||
}
|
||||
return headers;
|
||||
},
|
||||
}),
|
||||
endpoints: (builder) => ({
|
||||
getQueues: builder.query({
|
||||
query: () => "/",
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
||||
export const { useGetQueuesQuery } = QueueApi;
|
||||
Reference in New Issue
Block a user