Commit be4925c2 authored by Shiva Komirishetti's avatar Shiva Komirishetti

initail commit

parent ee6c4f37
...@@ -3,15 +3,21 @@ ...@@ -3,15 +3,21 @@
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@reduxjs/toolkit": "^2.2.1",
"@tailwindcss/ui": "^0.7.2",
"@testing-library/jest-dom": "^5.17.0", "@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0", "@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0", "@testing-library/user-event": "^13.5.0",
"axios": "^1.6.7",
"cors": "^2.8.5", "cors": "^2.8.5",
"express": "^4.18.3", "express": "^4.18.3",
"mongodb": "^6.5.0", "mongodb": "^6.5.0",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-redux": "^9.1.0",
"react-router-dom": "^6.22.3",
"react-scripts": "5.0.1", "react-scripts": "5.0.1",
"redux-thunk": "^3.1.0",
"web-vitals": "^2.1.4" "web-vitals": "^2.1.4"
}, },
"scripts": { "scripts": {
...@@ -19,7 +25,7 @@ ...@@ -19,7 +25,7 @@
"build": "react-scripts build", "build": "react-scripts build",
"test": "react-scripts test", "test": "react-scripts test",
"eject": "react-scripts eject", "eject": "react-scripts eject",
"server":"node --watch server.js" "server": "node --watch server.js"
}, },
"eslintConfig": { "eslintConfig": {
"extends": [ "extends": [
...@@ -38,5 +44,8 @@ ...@@ -38,5 +44,8 @@
"last 1 firefox version", "last 1 firefox version",
"last 1 safari version" "last 1 safari version"
] ]
},
"devDependencies": {
"tailwindcss": "^3.4.1"
} }
} }
import logo from './logo.svg'; import {BrowserRouter, Routes, Route} from 'react-router-dom';
import Home from "./pages/home";
import Dashboard from './pages/dashboard';
import './App.css'; import './App.css';
function App() { function App() {
return ( return (
<div className="App"> <BrowserRouter>
<header className="App-header"> <Routes>
<img src={logo} className="App-logo" alt="logo" /> <Route path='/' element={<Home />}/>
<p> <Route path=":id/dashboard" element={<Dashboard />}/>
Edit <code>src/App.js</code> and save to reload. </Routes>
</p> </BrowserRouter>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
); );
} }
......
@tailwind base;
@tailwind components;
@tailwind utilities;
body { body {
margin: 0; margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
......
...@@ -3,11 +3,15 @@ import ReactDOM from 'react-dom/client'; ...@@ -3,11 +3,15 @@ import ReactDOM from 'react-dom/client';
import './index.css'; import './index.css';
import App from './App'; import App from './App';
import reportWebVitals from './reportWebVitals'; import reportWebVitals from './reportWebVitals';
import { Provider } from 'react-redux';
import store from './redux/store';
const root = ReactDOM.createRoot(document.getElementById('root')); const root = ReactDOM.createRoot(document.getElementById('root'));
root.render( root.render(
<React.StrictMode> <React.StrictMode>
<App /> <Provider store={store}>
<App />
</Provider>
</React.StrictMode> </React.StrictMode>
); );
......
import React, { useEffect } from "react";
import { useParams } from "react-router-dom";
import { useDispatch, useSelector } from "react-redux";
import { fetchReportees, fetchUser } from "../../redux/reducers/reporteesSlice";
function Dashboard() {
const dispatch = useDispatch();
const reportees = useSelector((state) => state.reportees);
const user = reportees.user.reportees;
const { id } = useParams();
useEffect(() => {
if (user) {
const data = {
reportees: reportees.user.reportees,
sort: { type: "empId", order: 1 },
page: 1,
perPage: 10,
};
dispatch(fetchReportees(data));
}
}, []);
useEffect(() => {
dispatch(fetchUser(id));
}, []);
return <div>Dashboard Page</div>;
}
export default Dashboard;
import React, { useState } from "react";
import { useNavigate } from "react-router-dom";
function Home() {
const navigate = useNavigate();
const [id, setId] = useState(null);
const handleNavigate = () => {
navigate(`${id}/dashboard`);
};
return (
<div class="container py-10 px-10 mx-0 min-w-full h-screen flex items-center justify-center">
<div class="max-w-sm p-6 bg-white border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700 ">
<label
for="email"
class="block mb-2 text-sm font-medium text-gray-900 dark:text-white"
>
Employee Id
</label>
<input
type="text"
id="email"
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
placeholder=""
required
onChange={(e) => setId(e.target.value)}
/>
<button
class="bg-purple-900 text-white hover:bg-blue-400 font-bold py-2 px-4 mt-3 rounded"
onClick={handleNavigate}
disabled={!id}
>
Score Card
</button>
</div>
</div>
);
}
export default Home;
import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
import {base_url} from '../../utils/constants';
import axios from 'axios';
const initialState= {
user: {},
reportees: [],
loading: false,
error: null,
}
export const fetchUser = createAsyncThunk('getUser', async (id) => {
return await axios.get(`${base_url}/employee/${id}`)
.then(response => response.data);
});
export const fetchReportees = createAsyncThunk('getReportees', async (data) => {
return await axios.post(`${base_url}/getreportees`, data)
.then(response => response.data);
});
const reporteesSlice = createSlice({
name: 'counter',
initialState,
reducers: {},
extraReducers: builder => {
builder.addCase(fetchReportees.pending, (state) => {
state.loading = true;
state.error="pending"
});
builder.addCase(fetchReportees.fulfilled, (state, action) => {
state.loading = false;
state.reportees = action.payload;
state.error = '';
});
builder.addCase(fetchReportees.rejected, (state, action) => {
state.loading = false;
state.reportees = [];
state.error = action.error || 'Something went wrong!';
});
// fetch user
builder.addCase(fetchUser.pending, (state) => {
state.loading = true;
state.error="pending"
});
builder.addCase(fetchUser.fulfilled, (state, action) => {
state.loading = false;
state.user = action.payload;
state.error = '';
});
builder.addCase(fetchUser.rejected, (state, action) => {
state.loading = false;
state.user = {};
state.error = action.error || 'Something went wrong!';
});
}
});
export const {} =
reporteesSlice.actions;
export default reporteesSlice.reducer;
import { combineReducers } from 'redux';
import reporteesReducer from './reporteesSlice';
const rootReducer = combineReducers({
reportees: reporteesReducer
});
export default rootReducer;
\ No newline at end of file
import { configureStore } from '@reduxjs/toolkit';
import rootReducer from './reducers/rootReducer';
const store = configureStore({
reducer: rootReducer,
});
export default store;
\ No newline at end of file
export const base_url = 'http://localhost:4000'
\ No newline at end of file
module.exports = {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
theme: {
fontSize: {
xs: ['12px', '16px'],
sm: ['14px', '20px'],
base: ['16px', '19.5px'],
lg: ['18px', '21.94px'],
xl: ['20px', '24.38px'],
'2xl': ['24px', '29.26px'],
'3xl': ['28px', '50px'],
'4xl': ['48px', '58px'],
'8xl': ['96px', '106px']
},
extend: {
fontFamily: {
palanquin: ['Palanquin', 'sans-serif'],
montserrat: ['Montserrat', 'sans-serif'],
},
colors: {
'primary': "#ECEEFF",
"coral-red": "#FF6452",
"slate-gray": "#6D6D6D",
"pale-blue": "#F5F6FF",
"white-400": "rgba(255, 255, 255, 0.80)"
},
boxShadow: {
'3xl': '0 10px 40px rgba(0, 0, 0, 0.1)'
},
backgroundImage: {
'hero': "url('assets/images/collection-background.svg')",
'card': "url('assets/images/thumbnail-background.svg')",
},
screens: {
"wide": "1440px"
}
},
},
plugins: [],
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment