-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
83 lines (81 loc) · 3.39 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Cuvelit</title>
<link href="main.css" rel="stylesheet" />
</head>
<body>
<div id="jobs-container" class="container mx-auto px-4"></div>
<script>
document.addEventListener("DOMContentLoaded", function () {
fetch("https://api.cuvette.tech/api/v1/externaljobs")
.then((response) => response.json())
.then((data) => {
const jobsContainer = document.getElementById("jobs-container");
data.data.forEach((job) => {
const createdAt = new Date(job.createdAt);
const updatedAt = new Date(job.updatedAt);
const now = new Date();
const timeSinceCreation = getTimeSince(createdAt, now);
const timeSinceUpdate = getTimeSince(updatedAt, now);
const jobElement = `
<div class="rounded-lg border bg-card text-card-foreground shadow-sm w-full md:max-w-4xl mx-auto mb-4">
<div class="space-y-4 md:space-y-0 md:flex md:items-center md:justify-between md:px-6 py-6">
<div class="flex items-center">
<img alt="Company Logo" class="max-w-10 max-h-10 md:max-w-12 md:max-h-12 mr-3" src="${job.imageUrl}">
<h3 class="text-2xl font-semibold leading-none tracking-tight">${job.title}</h3>
</div>
<div class="flex flex-col items-center justify-center">
<a class="inline-block px-6 py-3 text-sm font-medium text-white bg-blue-500 rounded-md" href="${job.redirectLink}" target="_blank">Apply Now</a>
<div class="mt-4 text-sm font-medium"> Applied: ${job.count}</div>
</div>
</div>
<div class="p-6">
<dl class="grid grid-cols-1 md:grid-cols-2 gap-4 text-sm">
<div class="font-medium">Company Name</div>
<div>${job.companyName}</div>
<div class="font-medium">Location</div>
<div>${job.location}</div>
<div class="font-medium">Type</div>
<div>${job.type}</div>
<div class="font-medium">Salary</div>
<div>${job.salary}</div>
<div class="font-medium">Required Experience</div>
<div>${job.requiredExperience}</div>
<div class="font-medium">Skills</div>
<div>${job.skills}</div>
<div class="font-medium">Created At</div>
<div>${job.createdAt} (${timeSinceCreation})</div>
<div class="font-medium">Updated At</div>
<div>${job.updatedAt} (${timeSinceUpdate})</div>
</dl>
</div>
</div>
`;
jobsContainer.insertAdjacentHTML("beforeend", jobElement);
});
})
.catch((error) => console.error("Error fetching jobs:", error));
});
function getTimeSince(previousDate, now) {
const timeDifference = now - previousDate;
const days = Math.floor(timeDifference / (1000 * 60 * 60 * 24));
const hours = Math.floor(
(timeDifference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)
);
const minutes = Math.floor(
(timeDifference % (1000 * 60 * 60)) / (1000 * 60)
);
if (days > 0) {
return `${days} days ago`;
} else if (hours > 0) {
return `${hours} hours ago`;
} else {
return `${minutes} minutes ago`;
}
}
</script>
</body>
</html>