-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathadd_members.js
71 lines (61 loc) · 2.23 KB
/
add_members.js
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
let form = document.querySelector("#team_members");
let userdata = JSON.parse(localStorage.getItem("userdata")) || [];
form.addEventListener("submit", (event) => {
event.preventDefault();
let data = {
name: document.querySelector("#name").value,
email: document.querySelector("#email").value,
notes: document.querySelector("#notes").value,
labor: document.querySelector("#labor").value,
bill: document.querySelector("#bill").value
}
if((data.name.length === 0) || (data.email.length === 0) || (data.notes.length === 0) || (data.labor.length === 0) || (data.bill.length === 0)){
alert("Fields cannot be empty");
} else {
if(ischecked() === true) {
userdata.push(data);
localStorage.setItem("userdata", JSON.stringify(userdata));
alert("Team member is created");
window.location.href = "team.html";
} else if (ischecked() === false) {
alert("Please Select a Role");
}
}
});
let ischecked = () => {
let check1 = document.getElementById("accept1");
let check2 = document.getElementById("accept2");
let check3 = document.getElementById("accept3");
let check4 = document.getElementById("accept4");
let value1 = check1.value;
let value2 = check2.value;
let value3 = check3.value;
if (((check1.checked) || (check2.checked) || (check3.checked)) === true) {
return true;
} else {
return false;
}
}
let userinfoas = JSON.parse(localStorage.getItem("userDetails"));
// setTimeout(() => {
let mainaccordin = document.getElementsByClassName("conBoxes");
for (i = 0; i < mainaccordin.length; i++) {
mainaccordin[i].addEventListener("click", function () {
this.classList.toggle("active");
// this.style.color ="blue"|| "black"
});
}
// }, 2000);
if (userinfoas === null) {
window.location.href = "../signup.html";
} else {
let nameprofile = document.getElementById("name-profile");
nameprofile.innerText = userinfoas["fullname"];
}
let profile = () => {
window.location.href = "../profile.html";
};
let profileSignout = () => {
localStorage.removeItem("userDetails");
window.location.href = "../signup.html";
};