summaryrefslogtreecommitdiff
path: root/src/features/auth
diff options
context:
space:
mode:
authorMichael Hunteman <michael@huntm.net>2024-05-17 15:20:30 -0700
committerMichael Hunteman <michael@huntm.net>2024-05-17 15:20:30 -0700
commit7103019890960e793deefb64987a09b33be60b42 (patch)
treec1c9402aa250c68b2cbe13d62598232bbf20b1e2 /src/features/auth
parentfc5c111bcfe296bec82e1cf9fdb88fc80fb24f89 (diff)
Add golang server
Diffstat (limited to 'src/features/auth')
-rw-r--r--src/features/auth/GuestLogin.tsx79
-rw-r--r--src/features/auth/authSlice.ts26
2 files changed, 0 insertions, 105 deletions
diff --git a/src/features/auth/GuestLogin.tsx b/src/features/auth/GuestLogin.tsx
deleted file mode 100644
index 4da7e45..0000000
--- a/src/features/auth/GuestLogin.tsx
+++ /dev/null
@@ -1,79 +0,0 @@
-import React from 'react';
-import { useNavigate } from 'react-router-dom';
-import { useDispatch } from 'react-redux';
-import { Button, Container, TextField, Typography } from '@mui/material';
-import { useForm } from 'react-hook-form';
-import { setCredentials } from './authSlice';
-import { useLoginMutation } from '../../apiSlice';
-import type { LoginRequest } from '../../apiSlice';
-
-function GuestLogin() {
- const dispatch = useDispatch();
- const navigate = useNavigate();
- const [login] = useLoginMutation();
-
- const {
- register,
- handleSubmit,
- formState: { errors },
- } = useForm<LoginRequest>({
- defaultValues: {
- firstName: '',
- lastName: '',
- },
- });
-
- const onSubmit = async (data: LoginRequest) => {
- try {
- dispatch(setCredentials(await login(data).unwrap()));
- navigate('/rsvp');
- } catch (e) {
- console.log(e);
- }
- };
-
- return (
- <Container
- component="form"
- maxWidth="xs"
- noValidate
- onSubmit={handleSubmit(onSubmit)}
- >
- <div
- style={{
- marginTop: 80,
- display: 'flex',
- flexDirection: 'column',
- alignItems: 'center',
- }}
- >
- <Typography variant="h6">Guest Login</Typography>
- <TextField
- label="First Name"
- variant="outlined"
- margin="normal"
- fullWidth
- error={!!errors.firstName}
- helperText={errors.firstName?.message}
- required
- {...register('firstName', { required: 'This field is required' })}
- />
- <TextField
- label="Last Name"
- variant="outlined"
- margin="normal"
- fullWidth
- error={!!errors.lastName}
- helperText={errors.lastName?.message}
- required
- {...register('lastName', { required: 'This field is required' })}
- />
- <Button type="submit" variant="contained" fullWidth sx={{ mt: 2 }}>
- Log in
- </Button>
- </div>
- </Container>
- );
-}
-
-export default GuestLogin;
diff --git a/src/features/auth/authSlice.ts b/src/features/auth/authSlice.ts
deleted file mode 100644
index bff2bdd..0000000
--- a/src/features/auth/authSlice.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { createSlice } from '@reduxjs/toolkit';
-import type { RootState } from '../../store';
-import type { Guest } from '../../apiSlice';
-
-type AuthState = {
- guest?: Guest;
- token?: string;
-};
-
-const authSlice = createSlice({
- name: 'auth',
- initialState: { guest: undefined, token: undefined } as AuthState,
- reducers: {
- setCredentials: (state, action) => {
- const { guest, token } = action.payload;
- state.guest = guest;
- state.token = token;
- },
- },
-});
-
-export const { setCredentials } = authSlice.actions;
-
-export default authSlice.reducer;
-
-export const selectCurrentGuest = (state: RootState) => state.auth.guest;