Skip to content

Commit ad77e5b

Browse files
Fiverr-Client:Manueltaveras cyclic-software#1.2
1 parent 4a525cf commit ad77e5b

File tree

11 files changed

+211
-135
lines changed

11 files changed

+211
-135
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Node artifact files
22
node_modules/
3-
frontend/node_modules/
3+
frontend/

controllers/attendance.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@ const markAttendance = async (req, res) => {
2323
}
2424
}
2525

26+
const deleteAttendance = async (req, res) => {
27+
try {
28+
const { id } = req.body
29+
const response = await attendanceModel.findOneAndDelete({ employeeID: id })
30+
const update = await employeeModel.findByIdAndUpdate(id , { columnId: 'justComeIn' })
31+
32+
if (response && update) {
33+
res.status(200).send("Removed Successfully")
34+
}
35+
} catch (error) {
36+
console.log(error)
37+
res.status(400).send(error)
38+
}
39+
}
40+
2641
module.exports = {
27-
markAttendance
42+
markAttendance,
43+
deleteAttendance
2844
}
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
asset-manifest.json,1704346213494,683dda928baf100aa526aa94b41ed91a9a2279c5cd5df10d1d72839fa68e9a11
1+
asset-manifest.json,1704532836837,6029a135b59635b8f2d77b8c1d05bec3416e2deb7d33245efdd0a4220abf58e5
22
favicon.ico,1703916380428,27edce7be5922cf0bef7d4136f69b5bfbdd5bf8c13c7b026f71187d41a00aa7d
3-
index.html,1704346213494,0a7af72373355552aec7537a38ebca3941681255f6ab51200dddadaeb2245a62
3+
index.html,1704532836837,5b3698b6466e82f127687b4cb291bb8b4f8ed69de3d1e7a2e9e7148b30ee0899
44
logo192.png,1703916385621,79e2b749561016bc8af300ea19f48347ceed3cb1a54f48ae456172eca45e08f0
5+
logo512.png,1703916385770,212b102aa09e51b3b3e06647e81f7801a61333e171f6582e8124379aabccb41d
56
manifest.json,1703916384269,ee04fb47e525c67d8424ffe9b4d8a8a24e434504478afca4e0ca602146836d4c
67
robots.txt,1703916387913,bfe106a3fb878dc83461c86818bf74fc1bdc7f28538ba613cd3e775516ce8b49
7-
logo512.png,1703916385770,212b102aa09e51b3b3e06647e81f7801a61333e171f6582e8124379aabccb41d
8-
static/css/main.df6fdbff.css,1704346213498,5cdf51ab3b1b6834629dd176b078b004cd07590b3e139d6f86bb8654bcfed145
9-
static/js/787.7f5a1603.chunk.js,1704346213498,d1c56c4ccee8cd01f41593669db64c2db2210dda0addaa9cce2349252ad51e57
10-
static/css/main.df6fdbff.css.map,1704346213498,49ab3be7a7d9886fcb4b4bfeb7d559b9d37c3d582347bf867f43081bd6bd0328
11-
static/js/main.3d825961.js.LICENSE.txt,1704346213498,1816694f55f8c926962178d808fa817fab63f3a889e740ddb54d628e529c6df5
12-
static/js/787.7f5a1603.chunk.js.map,1704346213498,a1da92fe96f176f27e3a7602c0c9ff985ae8b29b3405b8b7c6b66158ebda95b6
13-
static/js/main.3d825961.js,1704346213498,2a9497b1d92e8555988e3d772d333d07fb9f4248463f9edee8d2591a2cafce38
14-
static/js/main.3d825961.js.map,1704346213498,e2144b6645cee11c4399a0695b3be952bd2bbc69a2a2213247985e958ffe1d86
8+
static/css/main.4d33680a.css,1704532836843,e9909d931830d4d31e2770ab6384b69642c7e1139fa652175356527e67c4a74c
9+
static/js/787.7f5a1603.chunk.js,1704532836842,d1c56c4ccee8cd01f41593669db64c2db2210dda0addaa9cce2349252ad51e57
10+
static/css/main.4d33680a.css.map,1704532836842,3e12246c44fa04432ea3d0672d14cbcdc811bb2bd463a0b85962d95327f97f98
11+
static/js/main.5269ce4a.js.LICENSE.txt,1704532836842,1816694f55f8c926962178d808fa817fab63f3a889e740ddb54d628e529c6df5
12+
static/js/787.7f5a1603.chunk.js.map,1704532836843,a1da92fe96f176f27e3a7602c0c9ff985ae8b29b3405b8b7c6b66158ebda95b6
13+
static/js/main.5269ce4a.js,1704532836843,41b44abd0187d449a1d2f7752010faf390c497bc0c819e28083d6115b8cd0fe6
14+
static/js/main.5269ce4a.js.map,1704532836843,74f2acf1d4c789dd9644fef0d6b290edede69d71903c479d2cbf041524fe8517

frontend/src/App.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,16 @@
1-
import { useEffect, useState } from 'react';
21
import { Attendance, Supervisor, AddEmployee, Navbar } from './components'
3-
import './App.css'
2+
// import './App.css'
43

54
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
65

76
function App() {
8-
const [employeeDetails, setEmployeeDetails] = useState([])
9-
10-
const handleEmployeeAttendance = (data) => {
11-
12-
setEmployeeDetails(
13-
[ // with a new array
14-
...employeeDetails, // that contains all the old items
15-
data // and one new item at the end
16-
]
17-
)
18-
}
197

208
return (
219
<Router>
2210
<Navbar />
2311
<Routes>
24-
<Route path="/" element={<Attendance handleEmployeeAttendance={handleEmployeeAttendance} />} />
25-
<Route path="/supervisor" element={<Supervisor employeeDetails={employeeDetails} />} />
12+
<Route path="/" element={<Attendance />} />
13+
<Route path="/supervisor" element={<Supervisor />} />
2614
<Route path="/addEmployee" element={<AddEmployee />} />
2715
</Routes>
2816

frontend/src/components/AddEmployee.js

Lines changed: 156 additions & 81 deletions
Large diffs are not rendered by default.

frontend/src/components/Attendance.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useState } from 'react'
22
import axios from 'axios'
33
import Details from './Details'
44

5-
const Attendance = ({ handleEmployeeAttendance }) => {
5+
const Attendance = () => {
66
const [id, setId] = useState(0)
77
const [employeeDetails, setEmployeeDetails] = useState({})
88

@@ -14,22 +14,14 @@ const Attendance = ({ handleEmployeeAttendance }) => {
1414
const response = await axios.post(API_URL, {
1515
employeeID: id,
1616
})
17-
17+
1818
const data = response.data
19-
const updatedData = {
20-
...data,
21-
columnId: "justComeIn",
22-
id: data._id,
23-
content: data.skills,
24-
}
25-
console.log(updatedData)
26-
handleEmployeeAttendance(updatedData)
2719

2820
setEmployeeDetails(data)
2921
}
3022

3123
return (
32-
<div className="flex flex-col items-center space-y-10 mt-10">
24+
<div className=" bg-gray-100 flex flex-col items-center space-y-10 pt-10">
3325
<div class="w-full max-w-sm p-4 bg-white border border-gray-200 rounded-lg shadow sm:p-6 md:p-8 dark:bg-gray-800 dark:border-gray-700">
3426
<form class="space-y-6" action="#">
3527
<h5 class="text-xl font-medium text-gray-900 dark:text-white">Employee Attendance</h5>
@@ -56,9 +48,9 @@ const Attendance = ({ handleEmployeeAttendance }) => {
5648
</form>
5749
</div>
5850

59-
<div className='w-full max-w-sm bg-white border border-gray-200 rounded-lg shadow sm:p-6 md:p-8 dark:bg-gray-800 dark:border-gray-700'>
51+
<div className='w-full max-w-sm sm:p-6 md:p-8'>
6052
<div className=''>
61-
{employeeDetails ? <Details {...employeeDetails} /> : <div className='text-white'> No Data Found </div>}
53+
{employeeDetails ? <Details {...employeeDetails} /> : <div className='text-white bg-black p-3 text-lg'> No Data Found </div>}
6254
</div>
6355
</div>
6456
</div>

frontend/src/components/Navbar.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const Navbar = () => {
66
<nav class="bg-white dark:bg-gray-900 w-full z-20 top-0 start-0 border-b border-gray-200 dark:border-gray-600">
77
<div class="max-w-screen-xl flex flex-wrap items-center justify-between mx-auto p-4">
88
<Link to='/' class="flex items-center space-x-3 rtl:space-x-reverse">
9-
<span class="self-center text-2xl font-semibold whitespace-nowrap dark:text-white">CrazyVolt</span>
9+
<span class="self-center text-2xl font-semibold whitespace-nowrap dark:text-white">PMS</span>
1010
</Link>
1111
<div class="flex md:order-2 space-x-3 md:space-x-0 rtl:space-x-reverse">
1212
<button type="button" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-4 py-2 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">Get started</button>
@@ -19,6 +19,9 @@ const Navbar = () => {
1919
</div>
2020
<div class="items-center justify-between hidden w-full md:flex md:w-auto md:order-1" id="navbar-sticky">
2121
<ul class="flex flex-col p-4 md:p-0 mt-4 font-medium border border-gray-100 rounded-lg bg-gray-50 md:space-x-8 rtl:space-x-reverse md:flex-row md:mt-0 md:border-0 md:bg-white dark:bg-gray-800 md:dark:bg-gray-900 dark:border-gray-700">
22+
<li>
23+
<Link to='/' class="block py-2 px-3 text-gray-900 rounded hover:bg-gray-100 md:hover:bg-transparent md:hover:text-blue-700 md:p-0 md:dark:hover:text-blue-500 dark:text-white dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent dark:border-gray-700">Attendance</Link>
24+
</li>
2225
<li>
2326
<Link to='/supervisor' class="block py-2 px-3 text-gray-900 rounded hover:bg-gray-100 md:hover:bg-transparent md:hover:text-blue-700 md:p-0 md:dark:hover:text-blue-500 dark:text-white dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent dark:border-gray-700">Supervisor</Link>
2427
</li>

frontend/src/components/Supervisor.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ const defaultTasks = [
103103

104104
const GetPresentEmployeesURL = 'http://localhost:8000/employee/getPresentEmployees'
105105
const UpdateEmployeeColumnURL = 'http://localhost:8000/employee/updateEmployeeColumn'
106+
const deleteAttendanceURL = 'http://localhost:8000/attendance/deleteAttendance'
106107

107108
const Supervisor = () => {
108109

@@ -124,7 +125,7 @@ const Supervisor = () => {
124125
})
125126
setTasks(empDetails)
126127
})
127-
.catch(e => console.log(e))
128+
// .catch(e => console.log(e))
128129
}, [])
129130

130131

@@ -147,6 +148,7 @@ const Supervisor = () => {
147148
}
148149

149150
function deleteTask(id) {
151+
axios.post(deleteAttendanceURL, { id })
150152
const newTasks = tasks.filter((task) => task.id !== id);
151153
setTasks(newTasks);
152154
}
@@ -189,7 +191,7 @@ const Supervisor = () => {
189191
function onDragStart(event) {
190192
if (event.active.data.current?.type === "Column") {
191193
setActiveColumn(event.active.data.current.column);
192-
console.log(event.active.data.current.column)
194+
// console.log(event.active.data.current.column)
193195
return;
194196
}
195197

@@ -214,7 +216,7 @@ const Supervisor = () => {
214216
const isActiveAColumn = active.data.current?.type === "Column";
215217
if (!isActiveAColumn) return;
216218

217-
console.log("DRAG END");
219+
// console.log("DRAG END");
218220

219221
setColumns((columns) => {
220222
const activeColumnIndex = columns.findIndex((col) => col.id === activeId);
@@ -261,20 +263,20 @@ const Supervisor = () => {
261263
if (isActiveATask && isOverAColumn) {
262264
setTasks((tasks) => {
263265
const activeIndex = tasks.findIndex((t) => t.id === activeId);
264-
console.log(tasks[activeIndex])
266+
265267
const { _id } = tasks[activeIndex]
266-
268+
267269
const data = {
268270
columnId: overId,
269271
id: _id
270272
}
271273

272274
axios.post(UpdateEmployeeColumnURL, data)
273-
.then((res) => console.log(res.data))
274-
.catch(e => console.log(e))
275-
275+
// .then((res) => console.log(res.data))
276+
// .catch(e => console.log(e))
277+
276278
tasks[activeIndex].columnId = overId;
277-
console.log("DROPPING TASK OVER COLUMN", { activeIndex });
279+
// console.log("DROPPING TASK OVER COLUMN", { activeIndex });
278280
return arrayMove(tasks, activeIndex, activeIndex);
279281
});
280282
}
@@ -294,7 +296,7 @@ const Supervisor = () => {
294296
)
295297

296298
return (
297-
<div className='m-auto flex min-h-screen w-full items-center overflow-x-auto overflow-y-hidden px-[40px]'>
299+
<div className='bg-gray-100 m-auto flex min-h-screen w-full items-center overflow-x-auto overflow-y-hidden px-[40px]'>
298300
<DndContext
299301
sensors={sensors}
300302
onDragStart={onDragStart}

frontend/src/components/TaskCard.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useSortable } from "@dnd-kit/sortable";
44
import { CSS } from "@dnd-kit/utilities";
55

66
const TaskCard = ({ task, deleteTask, updateTask }) => {
7-
console.log(task)
7+
// console.log(task)
88
const [mouseIsOver, setMouseIsOver] = useState(false);
99
// const [editMode, setEditMode] = useState(true);
1010
const {

model/employee.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const { Schema, model } = require('mongoose')
55
const employeeSchema = new Schema({
66
employeeID: {
77
type: String,
8-
// ref: "attendance",
98
required: true
109
},
1110

0 commit comments

Comments
 (0)