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/features/auth/GuestLogin.tsx | 19 ++++--------------- src/features/auth/authSlice.ts | 7 +++++-- 2 files changed, 9 insertions(+), 17 deletions(-) (limited to 'src/features') diff --git a/src/features/auth/GuestLogin.tsx b/src/features/auth/GuestLogin.tsx index 2100a94..8585e61 100644 --- a/src/features/auth/GuestLogin.tsx +++ b/src/features/auth/GuestLogin.tsx @@ -1,12 +1,9 @@ -import { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { useDispatch } from 'react-redux'; -import { Button, Grid, Paper, TextField, Typography } from '@mui/material'; +import { Button, Stack, TextField, Typography } from '@mui/material'; import { useForm } from 'react-hook-form'; - import { setCredentials } from './authSlice'; -import { useLoginMutation } from '../../apiSlice'; -import type { LoginRequest } from './authSlice'; +import { useLoginMutation, LoginRequest } from '../../apiSlice'; function GuestLogin() { const dispatch = useDispatch(); @@ -33,34 +30,26 @@ function GuestLogin() { return (
- - + Guest Login - - - - - - - - +
); } diff --git a/src/features/auth/authSlice.ts b/src/features/auth/authSlice.ts index 9716131..04be93f 100644 --- a/src/features/auth/authSlice.ts +++ b/src/features/auth/authSlice.ts @@ -1,18 +1,21 @@ import { createSlice } from '@reduxjs/toolkit'; import type { RootState } from '../../store'; +import { User } from '../../apiSlice'; type AuthState = { user: User | null + id: number | null token: string | null } const authSlice = createSlice({ name: 'auth', - initialState: { user: null, token: null } as AuthState, + initialState: { user: null, token: null, id: null } as AuthState, reducers: { setCredentials: (state, action) => { - const { user, token } = action.payload; + const { user, token, id } = action.payload; state.user = user; + state.id = id; state.token = token; } } -- cgit v1.2.3