summaryrefslogtreecommitdiff
path: root/src/apiSlice.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/apiSlice.ts')
-rw-r--r--src/apiSlice.ts17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/apiSlice.ts b/src/apiSlice.ts
index fde9fff..ab46822 100644
--- a/src/apiSlice.ts
+++ b/src/apiSlice.ts
@@ -1,9 +1,10 @@
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react';
-import { setCredentials, logOut } from './features/auth/authSlice';
+import { RootState } from './store'
export interface User {
firstName: string
lastName: string
+ id: number
}
export interface UserResponse {
@@ -16,10 +17,18 @@ export interface LoginRequest {
lastName: string
}
+export interface Guest {
+ id: number
+ attendance: string
+ mealPreference: string
+ dietaryRestrictions: string
+ plusOne: string
+ marriageAdvice: string
+}
+
export const apiSlice = createApi({
reducerPath: 'api',
baseQuery: fetchBaseQuery({
- // baseUrl: 'http://localhost:3000',
baseUrl: '/',
prepareHeaders: (headers, { getState }) => {
const token = (getState() as RootState).auth.token;
@@ -31,11 +40,11 @@ export const apiSlice = createApi({
}),
tagTypes: ['Guests'],
endpoints: builder => ({
- getGuests: builder.query({
+ getGuests: builder.query<void, void>({
query: () => '/guests',
providesTags: ['Guests']
}),
- updateGuest: builder.mutation({
+ updateGuest: builder.mutation<Guest, Guest>({
query: guest => ({
url: `/guests/${guest.id}`,
method: 'PATCH',