forked from AidanLau10/joblyFrontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewapplication.html
173 lines (147 loc) · 4.66 KB
/
viewapplication.html
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
161
162
163
164
165
166
167
168
169
170
171
172
---
layout: base
permalink: /viewapplication/
---
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Job Details</title>
<style>
.card {
border: 1px solid #ccc;
border-radius: 5px;
padding: 20px;
margin-bottom: 20px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.card-title {
font-size: 1.25rem;
margin-bottom: 10px;
align-items: center;
}
.back-arrow {
cursor: pointer;
margin-right: 10px;
}
.back-arrow svg {
fill: #007bff;
width: 20px;
height: 20px;
transition: transform 0.3s ease;
}
.back-arrow svg:hover {
transform: translateX(-3px);
}
.card-text {
margin-bottom: 5px;
}
.btn {
display: inline-block;
font-weight: 400;
color: #212529;
text-align: center;
vertical-align: middle;
cursor: pointer;
border: 1px solid transparent;
padding: 0.375rem 0.75rem;
font-size: 1rem;
line-height: 1.5;
border-radius: 0.25rem;
background-color: #007bff;
border-color: #007bff;
color: #fff;
text-decoration: none;
}
.btn-primary {
background-color: #007bff;
border-color: #007bff;
}
.btn-primary:hover {
background-color: #0056b3;
border-color: #0056b3;
}
.btn-primary:focus {
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.5);
outline: none;
}
.dynamiccount {
float: right;
text-align: right;
}
</style>
</head>
<body>
<div id="results" class="card-container"></div>
<script>
let urlParams = new URLSearchParams(window.location.search);
let jobid = urlParams.get('jobid');
let userid = urlParams.get('userid');
// prepare HTML result container for new output
const resultContainer = document.getElementById("results");
// prepare fetch options
//const displayJobDetailsUrl = 'https://jobly.stu.nighthawkcodingsociety.com/api/job/?id=' + jobdetails;
const viewApplicationUrl = "http://127.0.0.1:8064/api/job/viewapplication?jobid=" + jobid + '&userid=' + userid;
const viewApplicationHeader = {
method: 'GET', // *GET, POST, PUT, DELETE, etc.
mode: 'cors', // no-cors, *cors, same-origin
cache: 'default', // *default, no-cache, reload, force-cache, only-if-cached
credentials: 'include',
headers: {
'Content-Type': 'application/json'
// 'Content-Type': 'application/x-www-form-urlencoded',
},
};
// fetch the API
fetch(viewApplicationUrl, viewApplicationHeader)
.then(response => {
// Error handling
if (response.status !== 200) {
const errorMsg = 'Database response error: ' + response.status;
console.log(errorMsg);
const errorCard = document.createElement("div");
errorCard.classList.add("card");
errorCard.innerHTML = `<div class="card-body">${errorMsg}</div>`;
resultContainer.appendChild(errorCard);
return;
}
response.json().then(data => {
// Render job details
renderJobDetails(data);
});
})
.catch(err => {
// Error handling
console.error(err);
const errorCard = document.createElement("div");
errorCard.classList.add("card");
errorCard.innerHTML = `<div class="card-body">${err}</div>`;
resultContainer.appendChild(errorCard);
});
function renderJobDetails(data) {
// Create a card
const card = document.createElement("div");
card.classList.add("card");
// Populate card with job details and editable input fields
card.innerHTML = `
<div class="card-body">
<h5 class="card-title">
<span class="back-arrow" onclick="goBack()">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M20 11H7.41l5.3-5.29a1 1 0 1 0-1.42-1.42l-7 7a1 1 0 0 0 0 1.42l7 7a1 1 0 0 0 1.42-1.42L7.41 13H20a1 1 0 0 0 0-2z"/></svg>
</span>
</h5>
</div>
<p class="card-text"><strong>Email:</strong> <input type="text" id="email" value="${data.email}" /></p>
<p class="card-text"><strong>Address:</strong> <input type="text" id="address" value="${data.address}" /></p>
<p class="card-text"><strong>What separates you from others?</strong> <textarea id="separationFactor">${data.separationFactor}</textarea></p>
`;
// Append card to container
resultContainer.appendChild(card);
}
function goBack() {
window.history.back();
}
</script>
</body>
</html>