diff --git a/mock-data/taskRequests/index.js b/mock-data/taskRequests/index.js index 85c23c03..2253c16e 100644 --- a/mock-data/taskRequests/index.js +++ b/mock-data/taskRequests/index.js @@ -338,27 +338,39 @@ const userInformation = { }, }; const superUserData = { - id: 'V4rqL1aDecNGoa1IxiCu', - incompleteUserDetails: false, - discordId: '12345', + id: 'XAF7rSUvk4p0d098qWYS', + profileURL: 'https://my.realdevsquad.com/identity', + discordJoinedAt: '2020-02-01T08:33:38.278000+00:00', roles: { archived: false, + in_discord: true, + member: true, super_user: true, + admin: true, }, - linkedin_id: 'kotesh', - last_name: 'Mudila', - yoe: '5', - github_display_name: 'kotesh Mudila', - company_name: 'Juniper networks ', - github_id: 'kotesh-arya', - designation: 'Front end engineer', - twitter_id: 'Codesh_', - first_name: 'Kotesh', - username: 'kotesh', + created_at: 1693166951852, + yoe: '8', + github_created_at: 1341655281000, + updated_at: 1693224375990, + company: 'Amazon', + twitter_id: 'ankushdharkar', + first_name: 'Ankush', + ' instagram_id': 'ankushdharkar', + website: 'NA', + incompleteUserDetails: false, + discordId: '154585730465660929', + linkedin_id: 'ankushdharkar', + last_name: 'Dharkar', picture: { - publicId: 'profile/w2XR9Gkid6Kg5xCJ5Elm/rzh3cwff7hh7srvg63mb', - url: 'https://res.cloudinary.com/realdevsquad/image/upload/v1692990078/profile/w2XR9Gkid6Kg5xCJ5Elm/rzh3cwff7hh7srvg63mb.png', + publicId: 'profile/XAF7rSUvk4p0d098qWYS/me40uk7taytbjaa67mhe', + url: 'https://res.cloudinary.com/realdevsquad/image/upload/v1692058952/profile/XAF7rSUvk4p0d098qWYS/me40uk7taytbjaa67mhe.jpg', }, + github_display_name: 'Ankush Dharkar', + company_name: 'Amazon', + github_id: 'ankushdharkar', + designation: 'SDE', + status: 'idle', + username: 'ankush', }; const defaultMockResponseHeaders = { status: 200, diff --git a/task-requests/details/index.html b/task-requests/details/index.html index 0ee09d10..7543e635 100644 --- a/task-requests/details/index.html +++ b/task-requests/details/index.html @@ -24,13 +24,13 @@ crossorigin="anonymous" referrerpolicy="no-referrer" > - +
diff --git a/task-requests/details/script.js b/task-requests/details/script.js index 63a2b367..b508a842 100644 --- a/task-requests/details/script.js +++ b/task-requests/details/script.js @@ -2,7 +2,7 @@ const API_BASE_URL = window.location.hostname === 'localhost' ? 'https://staging-api.realdevsquad.com' : window.API_BASE_URL; - +import { getIsSuperUser } from '../../applications/utils.js'; let taskRequest; let isSuperUser; @@ -18,31 +18,12 @@ const requestDetailContainer = document.getElementsByClassName('request-details'); const taskContainer = document.getElementById('task-details'); const toast = document.getElementById('toast_task_details'); -// const rejectButton = document.getElementById('reject-button'); const requestorsContainer = document.getElementById('requestors-details'); const taskRequestId = new URLSearchParams(window.location.search).get('id'); history.pushState({}, '', window.location.href); const errorMessage = 'The requested operation could not be completed. Please try again later.'; -async function getSelfUser() { - const res = await fetch(`${API_BASE_URL}/users/self`, { - method: 'GET', - credentials: 'include', - headers: { - 'Content-type': 'application/json', - }, - }); - - const self_user = await res.json(); - return self_user; -} - -async function checkUserIsSuperUser() { - const self_user = await getSelfUser(); - return self_user?.roles['super_user']; -} - function renderTaskRequestDetails(taskRequest) { taskRequestContainer.append( createCustomElement({ @@ -335,7 +316,7 @@ async function fetchTaskRequest() { } const renderGithubIssue = async () => { - converter = new showdown.Converter({ + const converter = new showdown.Converter({ tables: true, simplifiedAutoLink: true, tasklists: true, @@ -374,7 +355,7 @@ const renderGithubIssue = async () => { }), ); const body = DOMPurify.sanitize(res?.body ?? ''); - html = converter.makeHtml(body); + const html = converter.makeHtml(body); taskContainer.appendChild( createCustomElement({ tagName: 'div', @@ -472,7 +453,7 @@ const renderTaskRequest = async () => { taskContainer.classList.remove('hidden'); try { taskRequest = await fetchTaskRequest(); - isSuperUser = await checkUserIsSuperUser(); + isSuperUser = await getIsSuperUser(); taskRequestSkeleton.classList.add('hidden'); renderRejectButton(taskRequest); renderTaskRequestDetails(taskRequest); @@ -615,7 +596,7 @@ function populateModalContent(index) { ); if (userData?.markdownEnabled ?? false) { - converter = new showdown.Converter({ + const converter = new showdown.Converter({ tables: true, simplifiedAutoLink: true, tasklists: true, @@ -624,7 +605,7 @@ function populateModalContent(index) { openLinksInNewWindow: true, }); const sanitizedDescription = DOMPurify.sanitize(userData.description ?? ''); - html = converter.makeHtml(sanitizedDescription); + const html = converter.makeHtml(sanitizedDescription); descriptionValue.innerHTML = html; descriptionValue.className = 'requestor_description_details'; } else {