-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateTask.jsx
More file actions
108 lines (94 loc) · 4.36 KB
/
CreateTask.jsx
File metadata and controls
108 lines (94 loc) · 4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import React from 'react'
import { useState } from 'react'
import { AuthContext } from '../../context/AuthProvider'
import { useContext } from 'react'
const CreateTask = () => {
const [userData,setUserData]= useContext(AuthContext)
const [taskTitle, setTaskTitle] = useState('')
const [taskDescription, setTaskDescription] = useState('')
const [taskDate, setTaskDate] = useState('')
const [assignTo, setAssignTo] = useState('')
const [category, setCategory] = useState('')
const [newTask, setNewTask] = useState([])
const submitHandler=(e)=>{
e.preventDefault()
setNewTask({taskTitle,taskDate,category,taskDescription,active:false,newTask:true,failed:false,completed:false})
const data=userData
data.forEach(function(elem){
if(assignTo==elem.firstname){
elem.tasks.push(newTask)
elem.taskCounts.newTask=elem.taskCounts.newTask+1
}
})
setUserData(data)
console.log(data)
setTaskTitle('')
setCategory('')
setAssignTo('')
setTaskDate('')
setTaskDescription('')
}
return (
<div className='p-5 bg-[#1c1c1c] mt-5 rounded'>
<form
onSubmit={(e)=>{
submitHandler(e)
}} className='flex flex-wrap items-start justify-between w-full'
>
<div className='w-1/2'>
<div>
<h3 className='text-sm text-gray-300 mb-0.5'>task title</h3>
<input
value={taskTitle}
onChange={(e)=>{
setTaskTitle(e.target.value)
}}
className='text-sm py-1 px-2 w-4/5 rounded outline-none bg-transparent border-[1px] border-gray-400 mb-4' type="text" placeholder='Make a UI design'
/>
</div>
<div>
<h3 className='text-sm text-gray-300 mb-0.5'>Date</h3>
<input
value={taskDate}
onChange={(e)=>{
setTaskDate(e.target.value)
}}
className='text-sm py-1 px-2 w-4/5 rounded outline-none bg-transparent border-[1px] border-gray-400 mb-4' type="date" placeholder='Enter Date'
/>
</div>
<div>
<h3 className='text-sm text-gray-300 mb-0.5'>Assign to.</h3>
<input
value={assignTo}
onChange={(e)=>{
setAssignTo(e.target.value)
}}
className='text-sm py-1 px-2 w-4/5 rounded outline-none bg-transparent border-[1px] border-gray-400 mb-4' type="text" placeholder='Employee Name'
/>
</div>
<div>
<h3 className='text-sm text-gray-300 mb-0.5'>Category</h3>
<input
value={category}
onChange={(e)=>{
setCategory(e.target.value)
}}
className='text-sm py-1 px-2 w-4/5 rounded outline-none bg-transparent border-[1px] border-gray-400 mb-4' type="text" placeholder='design,dev, etc.'
/>
</div>
</div>
<div className='w-2/5 flex flex-col items-start'>
<h3 className='text-sm text-gray-300 mb-0.5'>Description</h3>
<textarea
value={taskDescription}
onChange={(e)=>{
setTaskDescription(e.target.value)
}}
className='w-full h-44 text-sm py-2 px-4 rounded outline-none bg-transparent border-[1px] border-gray-400' name="" id=""></textarea>
<button className='bg-emerald-500 py-3 hover:bg-emerald-600 px-5 rounded text-sm mt-4 w-full'>Create Task</button>
</div>
</form>
</div>
)
}
export default CreateTask