Skip to content

Commit

Permalink
Fiverr-Client:Manueltaveras cyclic-software#1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Great-CrazyVolt committed Jan 7, 2024
1 parent 4a525cf commit ad77e5b
Show file tree
Hide file tree
Showing 11 changed files with 211 additions and 135 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Node artifact files
node_modules/
frontend/node_modules/
frontend/
18 changes: 17 additions & 1 deletion controllers/attendance.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ const markAttendance = async (req, res) => {
}
}

const deleteAttendance = async (req, res) => {
try {
const { id } = req.body
const response = await attendanceModel.findOneAndDelete({ employeeID: id })
const update = await employeeModel.findByIdAndUpdate(id , { columnId: 'justComeIn' })

if (response && update) {
res.status(200).send("Removed Successfully")
}
} catch (error) {
console.log(error)
res.status(400).send(error)
}
}

module.exports = {
markAttendance
markAttendance,
deleteAttendance
}
20 changes: 10 additions & 10 deletions frontend/.firebase/hosting.YnVpbGQ.cache
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
asset-manifest.json,1704346213494,683dda928baf100aa526aa94b41ed91a9a2279c5cd5df10d1d72839fa68e9a11
asset-manifest.json,1704532836837,6029a135b59635b8f2d77b8c1d05bec3416e2deb7d33245efdd0a4220abf58e5
favicon.ico,1703916380428,27edce7be5922cf0bef7d4136f69b5bfbdd5bf8c13c7b026f71187d41a00aa7d
index.html,1704346213494,0a7af72373355552aec7537a38ebca3941681255f6ab51200dddadaeb2245a62
index.html,1704532836837,5b3698b6466e82f127687b4cb291bb8b4f8ed69de3d1e7a2e9e7148b30ee0899
logo192.png,1703916385621,79e2b749561016bc8af300ea19f48347ceed3cb1a54f48ae456172eca45e08f0
logo512.png,1703916385770,212b102aa09e51b3b3e06647e81f7801a61333e171f6582e8124379aabccb41d
manifest.json,1703916384269,ee04fb47e525c67d8424ffe9b4d8a8a24e434504478afca4e0ca602146836d4c
robots.txt,1703916387913,bfe106a3fb878dc83461c86818bf74fc1bdc7f28538ba613cd3e775516ce8b49
logo512.png,1703916385770,212b102aa09e51b3b3e06647e81f7801a61333e171f6582e8124379aabccb41d
static/css/main.df6fdbff.css,1704346213498,5cdf51ab3b1b6834629dd176b078b004cd07590b3e139d6f86bb8654bcfed145
static/js/787.7f5a1603.chunk.js,1704346213498,d1c56c4ccee8cd01f41593669db64c2db2210dda0addaa9cce2349252ad51e57
static/css/main.df6fdbff.css.map,1704346213498,49ab3be7a7d9886fcb4b4bfeb7d559b9d37c3d582347bf867f43081bd6bd0328
static/js/main.3d825961.js.LICENSE.txt,1704346213498,1816694f55f8c926962178d808fa817fab63f3a889e740ddb54d628e529c6df5
static/js/787.7f5a1603.chunk.js.map,1704346213498,a1da92fe96f176f27e3a7602c0c9ff985ae8b29b3405b8b7c6b66158ebda95b6
static/js/main.3d825961.js,1704346213498,2a9497b1d92e8555988e3d772d333d07fb9f4248463f9edee8d2591a2cafce38
static/js/main.3d825961.js.map,1704346213498,e2144b6645cee11c4399a0695b3be952bd2bbc69a2a2213247985e958ffe1d86
static/css/main.4d33680a.css,1704532836843,e9909d931830d4d31e2770ab6384b69642c7e1139fa652175356527e67c4a74c
static/js/787.7f5a1603.chunk.js,1704532836842,d1c56c4ccee8cd01f41593669db64c2db2210dda0addaa9cce2349252ad51e57
static/css/main.4d33680a.css.map,1704532836842,3e12246c44fa04432ea3d0672d14cbcdc811bb2bd463a0b85962d95327f97f98
static/js/main.5269ce4a.js.LICENSE.txt,1704532836842,1816694f55f8c926962178d808fa817fab63f3a889e740ddb54d628e529c6df5
static/js/787.7f5a1603.chunk.js.map,1704532836843,a1da92fe96f176f27e3a7602c0c9ff985ae8b29b3405b8b7c6b66158ebda95b6
static/js/main.5269ce4a.js,1704532836843,41b44abd0187d449a1d2f7752010faf390c497bc0c819e28083d6115b8cd0fe6
static/js/main.5269ce4a.js.map,1704532836843,74f2acf1d4c789dd9644fef0d6b290edede69d71903c479d2cbf041524fe8517
18 changes: 3 additions & 15 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
import { useEffect, useState } from 'react';
import { Attendance, Supervisor, AddEmployee, Navbar } from './components'
import './App.css'
// import './App.css'

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

function App() {
const [employeeDetails, setEmployeeDetails] = useState([])

const handleEmployeeAttendance = (data) => {

setEmployeeDetails(
[ // with a new array
...employeeDetails, // that contains all the old items
data // and one new item at the end
]
)
}

return (
<Router>
<Navbar />
<Routes>
<Route path="/" element={<Attendance handleEmployeeAttendance={handleEmployeeAttendance} />} />
<Route path="/supervisor" element={<Supervisor employeeDetails={employeeDetails} />} />
<Route path="/" element={<Attendance />} />
<Route path="/supervisor" element={<Supervisor />} />
<Route path="/addEmployee" element={<AddEmployee />} />
</Routes>

Expand Down
237 changes: 156 additions & 81 deletions frontend/src/components/AddEmployee.js

Large diffs are not rendered by default.

18 changes: 5 additions & 13 deletions frontend/src/components/Attendance.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react'
import axios from 'axios'
import Details from './Details'

const Attendance = ({ handleEmployeeAttendance }) => {
const Attendance = () => {
const [id, setId] = useState(0)
const [employeeDetails, setEmployeeDetails] = useState({})

Expand All @@ -14,22 +14,14 @@ const Attendance = ({ handleEmployeeAttendance }) => {
const response = await axios.post(API_URL, {
employeeID: id,
})

const data = response.data
const updatedData = {
...data,
columnId: "justComeIn",
id: data._id,
content: data.skills,
}
console.log(updatedData)
handleEmployeeAttendance(updatedData)

setEmployeeDetails(data)
}

return (
<div className="flex flex-col items-center space-y-10 mt-10">
<div className=" bg-gray-100 flex flex-col items-center space-y-10 pt-10">
<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">
<form class="space-y-6" action="#">
<h5 class="text-xl font-medium text-gray-900 dark:text-white">Employee Attendance</h5>
Expand All @@ -56,9 +48,9 @@ const Attendance = ({ handleEmployeeAttendance }) => {
</form>
</div>

<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'>
<div className='w-full max-w-sm sm:p-6 md:p-8'>
<div className=''>
{employeeDetails ? <Details {...employeeDetails} /> : <div className='text-white'> No Data Found </div>}
{employeeDetails ? <Details {...employeeDetails} /> : <div className='text-white bg-black p-3 text-lg'> No Data Found </div>}
</div>
</div>
</div>
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const Navbar = () => {
<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">
<div class="max-w-screen-xl flex flex-wrap items-center justify-between mx-auto p-4">
<Link to='/' class="flex items-center space-x-3 rtl:space-x-reverse">
<span class="self-center text-2xl font-semibold whitespace-nowrap dark:text-white">CrazyVolt</span>
<span class="self-center text-2xl font-semibold whitespace-nowrap dark:text-white">PMS</span>
</Link>
<div class="flex md:order-2 space-x-3 md:space-x-0 rtl:space-x-reverse">
<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>
Expand All @@ -19,6 +19,9 @@ const Navbar = () => {
</div>
<div class="items-center justify-between hidden w-full md:flex md:w-auto md:order-1" id="navbar-sticky">
<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">
<li>
<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>
</li>
<li>
<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>
</li>
Expand Down
22 changes: 12 additions & 10 deletions frontend/src/components/Supervisor.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ const defaultTasks = [

const GetPresentEmployeesURL = 'http://localhost:8000/employee/getPresentEmployees'
const UpdateEmployeeColumnURL = 'http://localhost:8000/employee/updateEmployeeColumn'
const deleteAttendanceURL = 'http://localhost:8000/attendance/deleteAttendance'

const Supervisor = () => {

Expand All @@ -124,7 +125,7 @@ const Supervisor = () => {
})
setTasks(empDetails)
})
.catch(e => console.log(e))
// .catch(e => console.log(e))
}, [])


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

function deleteTask(id) {
axios.post(deleteAttendanceURL, { id })
const newTasks = tasks.filter((task) => task.id !== id);
setTasks(newTasks);
}
Expand Down Expand Up @@ -189,7 +191,7 @@ const Supervisor = () => {
function onDragStart(event) {
if (event.active.data.current?.type === "Column") {
setActiveColumn(event.active.data.current.column);
console.log(event.active.data.current.column)
// console.log(event.active.data.current.column)
return;
}

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

console.log("DRAG END");
// console.log("DRAG END");

setColumns((columns) => {
const activeColumnIndex = columns.findIndex((col) => col.id === activeId);
Expand Down Expand Up @@ -261,20 +263,20 @@ const Supervisor = () => {
if (isActiveATask && isOverAColumn) {
setTasks((tasks) => {
const activeIndex = tasks.findIndex((t) => t.id === activeId);
console.log(tasks[activeIndex])

const { _id } = tasks[activeIndex]

const data = {
columnId: overId,
id: _id
}

axios.post(UpdateEmployeeColumnURL, data)
.then((res) => console.log(res.data))
.catch(e => console.log(e))
// .then((res) => console.log(res.data))
// .catch(e => console.log(e))

tasks[activeIndex].columnId = overId;
console.log("DROPPING TASK OVER COLUMN", { activeIndex });
// console.log("DROPPING TASK OVER COLUMN", { activeIndex });
return arrayMove(tasks, activeIndex, activeIndex);
});
}
Expand All @@ -294,7 +296,7 @@ const Supervisor = () => {
)

return (
<div className='m-auto flex min-h-screen w-full items-center overflow-x-auto overflow-y-hidden px-[40px]'>
<div className='bg-gray-100 m-auto flex min-h-screen w-full items-center overflow-x-auto overflow-y-hidden px-[40px]'>
<DndContext
sensors={sensors}
onDragStart={onDragStart}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/TaskCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useSortable } from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities";

const TaskCard = ({ task, deleteTask, updateTask }) => {
console.log(task)
// console.log(task)
const [mouseIsOver, setMouseIsOver] = useState(false);
// const [editMode, setEditMode] = useState(true);
const {
Expand Down
1 change: 0 additions & 1 deletion model/employee.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const { Schema, model } = require('mongoose')
const employeeSchema = new Schema({
employeeID: {
type: String,
// ref: "attendance",
required: true
},

Expand Down
3 changes: 2 additions & 1 deletion routes/attendance.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/* eslint-disable no-unused-vars */
/* eslint-disable no-undef */
const { Router } = require('express')
const { markAttendance } = require('../controllers/attendance')
const { markAttendance, deleteAttendance } = require('../controllers/attendance')

const router = Router()

router.post('/markAttendance', markAttendance)
router.post('/deleteAttendance', deleteAttendance)


module.exports = router

0 comments on commit ad77e5b

Please sign in to comment.