From fa1409d205479e9943f7b7db96a4b56ff1d29d7d Mon Sep 17 00:00:00 2001 From: Michael Hunteman Date: Wed, 28 Feb 2024 18:20:38 -0800 Subject: Resolve type errors --- src/apiSlice.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/apiSlice.ts') 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({ query: () => '/guests', providesTags: ['Guests'] }), - updateGuest: builder.mutation({ + updateGuest: builder.mutation({ query: guest => ({ url: `/guests/${guest.id}`, method: 'PATCH', -- cgit v1.2.3