Skip to content

Commit b392270

Browse files
authored
New UI for profile update requests page (#843)
* New UI for profile update requests page * Error handeling * Handle API behind feature flag * Style changes * Refactor filenames * Refactored some code * Renamed * Refactored css and added css variables
1 parent d1726ed commit b392270

18 files changed

+1631
-1
lines changed

index.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
Create Goals
8787
</a>
8888
<a class="action-button" href="/task/index.html"> Create Tasks </a>
89-
<a class="action-button" href="/profile/index.html"> Profile </a>
89+
<a class="action-button" href="/profile"> Profile Diff </a>
9090
<a
9191
id="discord-user-link"
9292
class="action-button"
@@ -129,6 +129,13 @@
129129
<a class="action-button" href="/identity-service-logs/index.html"
130130
>Identity Service Logs</a
131131
>
132+
<a
133+
class="action-button element-display-remove"
134+
href="/profile-diffs"
135+
id="profile-update-requests"
136+
>
137+
Profile Update Requests
138+
</a>
132139
<a
133140
class="action-button element-display-remove"
134141
href="/feed/index.html"
Lines changed: 3 additions & 0 deletions
Loading

profile-diff-details/constants.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const YEARS_OF_EXPERIENCE = 'yoe';
2+
3+
const fieldDisplayName = Object.freeze({
4+
first_name: 'First name',
5+
last_name: 'Last name',
6+
designation: 'Role',
7+
company: 'Company',
8+
yoe: 'Years of experience',
9+
email: 'Email',
10+
phone: 'Phone no.',
11+
linkedin_id: 'Linkedin',
12+
github_id: 'Github',
13+
twitter_id: 'Twitter',
14+
instagram_id: 'Instagram',
15+
website: 'Website',
16+
});
17+
18+
const Status = Object.freeze({
19+
APPROVED: 'APPROVED',
20+
PENDING: 'PENDING',
21+
NOT_APPROVED: 'NOT APPROVED',
22+
});

profile-diff-details/index.html

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<link rel="stylesheet" href="/profile-diff-details/style.css" />
7+
<link
8+
rel="stylesheet"
9+
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
10+
/>
11+
<title>Profile Diff</title>
12+
</head>
13+
14+
<body>
15+
<header class="header">
16+
<a class="back" href="/profile-diffs/">
17+
<img src="assets/left-arrow.svg" class="back__icon" alt="Back" />
18+
</a>
19+
Request Details
20+
</header>
21+
<div id="toast" class="hidden"></div>
22+
<div class="container"></div>
23+
24+
<script src="/helpers/loadENV.js"></script>
25+
<script src="/utils.js"></script>
26+
27+
<script src="/profile-diff-details/constants.js"></script>
28+
<script src="/profile-diff-details/profileDiffDetails.utils.js"></script>
29+
<script src="/profile-diff-details/profileDiffDetails.apiCalls.js"></script>
30+
<script src="/profile-diff-details/script.js"></script>
31+
</body>
32+
</html>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const getProfileDiff = async (id) => {
2+
try {
3+
const finalUrl = `${API_BASE_URL}/profileDiffs/${id}`;
4+
const res = await fetch(finalUrl, {
5+
credentials: 'include',
6+
method: 'GET',
7+
headers: {
8+
'Content-type': 'application/json',
9+
},
10+
});
11+
if (res.status === 401) {
12+
return { notAuthorized: true };
13+
}
14+
if (res.status === 404) {
15+
return { profileDiffExist: false };
16+
}
17+
return { profileDiffExist: true, ...(await res.json()).profileDiff };
18+
} catch (err) {
19+
throw err;
20+
}
21+
};
22+
23+
const fetchUser = async (userId) => {
24+
try {
25+
const userResponse = await fetch(`${API_BASE_URL}/users?id=${userId}`, {
26+
method: 'GET',
27+
credentials: 'include',
28+
headers: {
29+
'Content-type': 'application/json',
30+
},
31+
});
32+
if (userResponse.status === 404) {
33+
return { userExist: false };
34+
}
35+
const { user } = await userResponse.json();
36+
return { ...user, userExist: true };
37+
} catch (err) {
38+
throw err;
39+
}
40+
};
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
function getUserDataItem(data, itemName) {
2+
const item = data[itemName];
3+
4+
if (item || (itemName === YEARS_OF_EXPERIENCE && item === 0)) {
5+
return item;
6+
}
7+
8+
return '';
9+
}
10+
11+
function checkDifferentValues(primaryData, secondaryData) {
12+
const diffValues = new Set();
13+
14+
for (const listItem in primaryData) {
15+
const oldValue = getUserDataItem(primaryData, listItem);
16+
const newValue = getUserDataItem(secondaryData, listItem);
17+
const isValueEqual = String(oldValue).trim() === String(newValue).trim();
18+
19+
if (!isValueEqual) {
20+
diffValues.add(listItem);
21+
}
22+
}
23+
24+
return diffValues;
25+
}
26+
27+
function wantedData(data) {
28+
const {
29+
id,
30+
first_name,
31+
last_name,
32+
email,
33+
phone,
34+
yoe,
35+
company,
36+
designation,
37+
github_id,
38+
linkedin_id,
39+
twitter_id,
40+
instagram_id,
41+
website,
42+
} = data;
43+
return {
44+
id,
45+
first_name,
46+
last_name,
47+
email,
48+
phone,
49+
yoe,
50+
company,
51+
designation,
52+
github_id,
53+
linkedin_id,
54+
twitter_id,
55+
instagram_id,
56+
website,
57+
};
58+
}

0 commit comments

Comments
 (0)