-
Notifications
You must be signed in to change notification settings - Fork 1
/
profile.js
160 lines (136 loc) · 4.75 KB
/
profile.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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
const initializeProfile = () => {
var info = localStorage.getItem('employeeDetails')
info = JSON.parse(info)
console.log(info.first_name)
// const info = {
// 'first_name': 'Mohamed',
// 'last_name': 'Asif',
// 'age': '20',
// 'designation': 'DevOps Engineer',
// 'emp_id': '8726487',
// 'dob': '10-09-2002',
// 'email': '[email protected]',
// 'attendance_percent': '86 %',
// }
const details = document.createElement('div')
details.classList.add('details')
var centerDiv = document.createElement('div')
centerDiv.classList.add('center')
centerDiv.classList.add('mb-20')
var container = document.createElement('div')
container.classList.add('flex-row')
container.classList.add('font-large')
var field = document.createElement('p')
field.classList.add('field')
field.textContent = "EID : "
var value = document.createElement('p')
value.textContent = info.emp_id
container.appendChild(field)
container.appendChild(value)
centerDiv.appendChild(container)
details.append(centerDiv)
const row = document.createElement('div')
row.classList.add('flex-row')
row.classList.add('center')
row.classList.add('gap-20')
var column = document.createElement('div')
column.classList.add('flex-column')
// Div
container = document.createElement('div')
// Field
field = document.createElement('p')
field.classList.add('field')
field.textContent = "First Name"
// Value
value = document.createElement('p')
value.classList.add('value')
value.textContent = info.first_name
container.appendChild(field)
container.appendChild(value)
column.appendChild(container)
// Div
container = document.createElement('div')
field = document.createElement('p')
field.classList.add('field')
field.textContent = "Last Name"
value = document.createElement('p')
value.classList.add('value')
value.textContent = info.last_name
container.appendChild(field)
container.appendChild(value)
column.appendChild(container)
container = document.createElement('div')
field = document.createElement('p')
field.classList.add('field')
field.textContent = "DOB"
value = document.createElement('p')
value.classList.add('value')
value.textContent = info.dob
container.appendChild(field)
container.appendChild(value)
column.appendChild(container)
// Next Column
const anotherColumn = document.createElement('div')
anotherColumn.classList.add('flex-column')
container = document.createElement('div')
field = document.createElement('p')
field.classList.add('field')
field.textContent = "Designation"
value = document.createElement('p')
value.classList.add('value')
value.textContent = info.designation
container.appendChild(field)
container.appendChild(value)
anotherColumn.appendChild(container)
container = document.createElement('div')
field = document.createElement('p')
field.classList.add('field')
field.textContent = "Age"
value = document.createElement('p')
value.classList.add('value')
value.textContent = info.age
container.appendChild(field)
container.appendChild(value)
anotherColumn.appendChild(container)
container = document.createElement('div')
field = document.createElement('p')
field.classList.add('field')
field.textContent = "Email"
value = document.createElement('p')
value.classList.add('value')
value.classList.add('w-270')
value.classList.add('mb-5')
value.textContent = info.email
container.appendChild(field)
container.appendChild(value)
anotherColumn.appendChild(container)
row.appendChild(column)
row.appendChild(anotherColumn)
details.appendChild(row)
// Attendance Percentage
centerDiv = document.createElement('div')
centerDiv.classList.add('center')
const attendanceDiv = document.createElement('div')
attendanceDiv.classList.add('flex-row')
attendanceDiv.classList.add('font-xxl')
attendanceDiv.classList.add('mt-40')
field = document.createElement('p')
field.classList.add('field')
field.textContent = "Attendance : "
value = document.createElement('p')
value.classList.add('value')
value.textContent = info.attendance_percent
attendanceDiv.appendChild(field)
attendanceDiv.appendChild(value)
centerDiv.append(attendanceDiv)
details.appendChild(centerDiv)
document.querySelector('.profile').appendChild(details)
}
const checkIfLoggedIn = () => {
const token = localStorage.getItem('token')
if (!token) {
window.location.href = './login.html'
}
}
checkIfLoggedIn()
initializeProfile()