summaryrefslogtreecommitdiff
path: root/client/src/apiSlice.ts
diff options
context:
space:
mode:
authorMichael Hunteman <michael@huntm.net>2024-07-09 18:24:15 -0700
committerMichael Hunteman <michael@huntm.net>2024-07-09 18:24:44 -0700
commita6b1fa31e890b51b043c4211b14cd4be29ed6fba (patch)
tree66a1fbc182fc3f9ed746958e2854d8a337782983 /client/src/apiSlice.ts
parent03ca04fdb738cc151d775b76e1bc38aec792521a (diff)
Add success and error alerts
Diffstat (limited to 'client/src/apiSlice.ts')
-rw-r--r--client/src/apiSlice.ts67
1 files changed, 0 insertions, 67 deletions
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<PartyGuest>;
-}
-
-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<void, void>({
- query: () => 'guest',
- providesTags: ['Guest'],
- }),
- updateGuest: builder.mutation<Guest, Guest>({
- query: (guest) => ({
- url: `guest/${guest?.id}`,
- method: 'PUT',
- body: guest,
- providesTags: ['Guest'],
- }),
- }),
- login: builder.mutation<LoginResponse, LoginRequest>({
- query: (credentials) => ({
- url: 'guest/login',
- method: 'POST',
- body: credentials,
- }),
- }),
- }),
-});
-
-export const { useGetGuestsQuery, useUpdateGuestMutation, useLoginMutation } =
- apiSlice;