From 5e5560b558ff818546c94135bebf334be770c920 Mon Sep 17 00:00:00 2001 From: Michael Hunteman Date: Sat, 9 Mar 2024 15:13:45 -0800 Subject: Add carousel --- src/apiSlice.ts | 51 ++++++++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 27 deletions(-) (limited to 'src/apiSlice.ts') diff --git a/src/apiSlice.ts b/src/apiSlice.ts index 6a1196b..f337fdd 100644 --- a/src/apiSlice.ts +++ b/src/apiSlice.ts @@ -1,23 +1,23 @@ import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'; -import { RootState } from './store' +import { RootState } from './store'; export interface LoginRequest { - firstName: string - lastName: string + firstName: string; + lastName: string; } export interface LoginResponse { - guest: Guest - token: string + guest: Guest; + token: string; } export interface Guest { - id: number - firstName: string - lastName: string - attendance: string - email: string - message: string + id: number; + firstName: string; + lastName: string; + attendance: string; + email: string; + message: string; } export const apiSlice = createApi({ @@ -30,34 +30,31 @@ export const apiSlice = createApi({ headers.set('authorization', `Bearer ${token}`); } return headers; - } + }, }), tagTypes: ['Guests'], - endpoints: builder => ({ + endpoints: (builder) => ({ getGuests: builder.query({ query: () => '/guests', - providesTags: ['Guests'] + providesTags: ['Guests'], }), updateGuest: builder.mutation({ - query: guest => ({ + query: (guest) => ({ url: `/guests/${guest?.id}`, method: 'PATCH', body: guest, - providesTags: ['Guests'] - }) + providesTags: ['Guests'], + }), }), login: builder.mutation({ - query: credentials => ({ + query: (credentials) => ({ url: '/guest-login', method: 'POST', - body: credentials - }) - }) - }) + body: credentials, + }), + }), + }), }); -export const { - useGetGuestsQuery, - useUpdateGuestMutation, - useLoginMutation -} = apiSlice; +export const { useGetGuestsQuery, useUpdateGuestMutation, useLoginMutation } = + apiSlice; -- cgit v1.2.3