From a6b1fa31e890b51b043c4211b14cd4be29ed6fba Mon Sep 17 00:00:00 2001 From: Michael Hunteman Date: Tue, 9 Jul 2024 18:24:15 -0700 Subject: Add success and error alerts --- client/src/apiSlice.ts | 67 -------------------------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 client/src/apiSlice.ts (limited to 'client/src/apiSlice.ts') diff --git a/client/src/apiSlice.ts b/client/src/apiSlice.ts deleted file mode 100644 index 038615f..0000000 --- a/client/src/apiSlice.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'; -import type { RootState } from './store'; - -export interface LoginRequest { - firstName: string; - lastName: string; -} - -export interface LoginResponse { - guest: Guest; - token: string; -} - -export interface Guest { - id: number; - firstName: string; - lastName: string; - attendance: string; - email: string; - message: string; - partySize: number; - partyList: Array; -} - -export interface PartyGuest { - firstName: string; - lastName: string; -} - -export const apiSlice = createApi({ - reducerPath: 'api', - baseQuery: fetchBaseQuery({ - baseUrl: 'http://192.168.1.41:8080/', - prepareHeaders: (headers, { getState }) => { - const token = (getState() as RootState).auth.token; - if (token) { - headers.set('authorization', `${token}`); - } - return headers; - }, - }), - tagTypes: ['Guest'], - endpoints: (builder) => ({ - getGuests: builder.query({ - query: () => 'guest', - providesTags: ['Guest'], - }), - updateGuest: builder.mutation({ - query: (guest) => ({ - url: `guest/${guest?.id}`, - method: 'PUT', - body: guest, - providesTags: ['Guest'], - }), - }), - login: builder.mutation({ - query: (credentials) => ({ - url: 'guest/login', - method: 'POST', - body: credentials, - }), - }), - }), -}); - -export const { useGetGuestsQuery, useUpdateGuestMutation, useLoginMutation } = - apiSlice; -- cgit v1.2.3