Add initial frontend-web setup with React, TypeScript, and Vite

- Created a new frontend-web project structure with essential files including package.json, tsconfig, and Vite configuration.
- Added ESLint and Prettier configurations for code quality.
- Implemented basic UI components (Button, Card, Input, Label) with Tailwind CSS for styling.
- Established Redux store with user authentication slice and typed hooks for state management.
- Included a sample App component demonstrating the use of UI components and Redux store.
- Set up .gitignore to exclude build artifacts and dependencies.
This commit is contained in:
2025-12-07 10:38:02 -05:00
commit f1f0032bca
25 changed files with 1346 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
import {useDispatch, useSelector} from 'react-redux';
import type {RootState, AppDispatch} from './store';
// Typed hooks - use these throughout the app instead of plain useDispatch/useSelector
export const useAppDispatch = useDispatch.withTypes<AppDispatch>();
export const useAppSelector = useSelector.withTypes<RootState>();

View File

@@ -0,0 +1,10 @@
// Store exports
export {store} from './store';
export type {RootState, AppDispatch} from './store';
// Hooks
export {useAppDispatch, useAppSelector} from './hooks';
// User slice exports
export {setLoading, setUser, clearUser, setError} from './slices/userSlice';
export type {User, UserState} from './slices/userSlice';

View File

@@ -0,0 +1,48 @@
import {createSlice, type PayloadAction} from '@reduxjs/toolkit';
export interface User {
id: string;
email: string;
name: string;
}
export interface UserState {
currentUser: User | null;
isAuthenticated: boolean;
isLoading: boolean;
error: string | null;
}
const initialState: UserState = {
currentUser: null,
isAuthenticated: false,
isLoading: false,
error: null
};
const userSlice = createSlice({
name: 'user',
initialState,
reducers: {
setLoading: (state, action: PayloadAction<boolean>) => {
state.isLoading = action.payload;
},
setUser: (state, action: PayloadAction<User>) => {
state.currentUser = action.payload;
state.isAuthenticated = true;
state.error = null;
},
clearUser: state => {
state.currentUser = null;
state.isAuthenticated = false;
state.error = null;
},
setError: (state, action: PayloadAction<string>) => {
state.error = action.payload;
state.isLoading = false;
}
}
});
export const {setLoading, setUser, clearUser, setError} = userSlice.actions;
export default userSlice.reducer;

View File

@@ -0,0 +1,11 @@
import {configureStore} from '@reduxjs/toolkit';
import userReducer from './slices/userSlice';
export const store = configureStore({
reducer: {
user: userReducer
}
});
export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;