forked from frappe/lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJobDetail.vue
More file actions
261 lines (248 loc) · 6.13 KB
/
JobDetail.vue
File metadata and controls
261 lines (248 loc) · 6.13 KB
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<template>
<div class="">
<header
class="sticky top-0 z-10 flex items-center justify-between border-b bg-surface-white px-3 py-2.5 sm:px-5"
>
<Breadcrumbs
class="h-7"
:items="[
{
label: __('Jobs'),
route: { name: 'Jobs' },
},
{
label: job.data?.job_title,
route: { name: 'JobDetail', params: { job: job.data?.name } },
},
]"
/>
<div
v-if="user.data?.name && !readOnlyMode"
class="flex items-center space-x-2"
>
<router-link
v-if="canManageJob && applicationCount.data > 0"
:to="{
name: 'JobApplications',
params: { job: job.data?.name },
}"
>
<Button variant="subtle">
{{ __('View Applications') }}
</Button>
</router-link>
<router-link
v-if="canManageJob"
:to="{
name: 'JobForm',
params: { jobName: job.data?.name },
}"
>
<Button>
<template #prefix>
<Pencil class="h-4 w-4 stroke-1.5" />
</template>
{{ __('Edit') }}
</Button>
</router-link>
<Button @click="redirectToWebsite(job.data?.company_website)">
<template #prefix>
<SquareArrowOutUpRight class="h-4 w-4 stroke-1.5" />
</template>
{{ __('Visit Website') }}
</Button>
<Button
v-if="!jobApplication.data?.length"
variant="solid"
@click="openApplicationModal()"
>
<template #prefix>
<SendHorizonal class="h-4 w-4" />
</template>
{{ __('Apply') }}
</Button>
<Badge v-else variant="subtle" theme="green" size="lg">
<template #prefix>
<Check class="h-4 w-4" />
</template>
{{ __('You have applied') }}
</Badge>
</div>
<div v-else-if="!readOnlyMode">
<Button @click="redirectToLogin(job.data?.name)">
<span>
{{ __('Login to apply') }}
</span>
</Button>
</div>
</header>
<div v-if="job.data" class="max-w-3xl mx-auto pt-5">
<div class="p-4">
<div class="space-y-5 mb-12">
<div class="flex">
<img
:src="job.data.company_logo"
class="size-10 rounded-lg object-contain cursor-pointer mr-4"
:alt="job.data.company_name"
@click="redirectToWebsite(job.data.company_website)"
/>
<div class="">
<div class="text-2xl text-ink-gray-9 font-semibold mb-1">
{{ job.data.job_title }}
</div>
<div class="text-sm text-ink-gray-5 font-semibold">
{{ job.data.company_name }} - {{ job.data.location }},
{{ job.data.country }}
</div>
</div>
</div>
<div class="space-x-2">
<Badge size="lg">
<template #prefix>
<CalendarDays class="size-3 stroke-2 text-ink-gray-7" />
</template>
{{ dayjs(job.data.creation).fromNow() }}
</Badge>
<Badge size="lg">
<template #prefix>
<ClipboardType class="size-3 stroke-2 text-ink-gray-7" />
</template>
{{ job.data.type }}
</Badge>
<Badge v-if="job.data?.work_mode" size="lg">
<template #prefix>
<BriefcaseBusiness class="size-3 stroke-2 text-ink-gray-7" />
</template>
{{ job.data.work_mode }}
</Badge>
<Badge v-if="applicationCount.data" size="lg">
<template #prefix>
<SquareUserRound class="size-3 stroke-2 text-ink-gray-7" />
</template>
{{ applicationCount.data }}
{{
applicationCount.data == 1 ? __('applicant') : __('applicants')
}}
</Badge>
</div>
</div>
<div class="flex items-center justify-between">
<div class="bg-surface-gray-2 h-px m-1 w-1/2"></div>
<div>
<FileText class="size-3 stroke-1 text-ink-gray-5" />
</div>
<div class="bg-surface-gray-2 h-px m-1 w-1/2"></div>
</div>
<p
v-html="job.data.description"
class="ProseMirror prose prose-table:table-fixed prose-td:p-2 prose-th:p-2 prose-td:border prose-th:border prose-td:border-outline-gray-2 prose-th:border-outline-gray-2 prose-td:relative prose-th:relative prose-th:bg-surface-gray-2 prose-sm max-w-none !whitespace-normal mt-12"
></p>
</div>
<JobApplicationModal
v-model="showApplicationModal"
v-model:application="jobApplication"
:job="job.data.name"
/>
</div>
</div>
</template>
<script setup>
import {
Badge,
Button,
Breadcrumbs,
createResource,
usePageMeta,
} from 'frappe-ui'
import { inject, ref, computed } from 'vue'
import { sessionStore } from '../stores/session'
import JobApplicationModal from '@/components/Modals/JobApplicationModal.vue'
import {
Check,
SendHorizonal,
Pencil,
CalendarDays,
SquareUserRound,
SquareArrowOutUpRight,
FileText,
ClipboardType,
BriefcaseBusiness,
Users,
} from 'lucide-vue-next'
const user = inject('$user')
const dayjs = inject('$dayjs')
const { brand } = sessionStore()
const showApplicationModal = ref(false)
const readOnlyMode = window.read_only_mode
const props = defineProps({
job: {
type: String,
required: true,
},
})
const job = createResource({
url: 'lms.lms.api.get_job_details',
params: {
job: props.job,
},
cache: ['job', props.job],
auto: true,
onSuccess: (data) => {
if (user.data?.name) {
jobApplication.submit()
}
applicationCount.submit()
},
})
const jobApplication = createResource({
url: 'frappe.client.get_list',
makeParams(values) {
return {
doctype: 'LMS Job Application',
filters: {
job: job.data?.name,
user: user.data?.name,
},
}
},
})
const applicationCount = createResource({
url: 'frappe.client.get_count',
makeParams(values) {
return {
doctype: 'LMS Job Application',
filters: {
job: job.data?.name,
},
}
},
})
const openApplicationModal = () => {
showApplicationModal.value = true
}
const redirectToLogin = (job) => {
window.location.href = `/login?redirect-to=/job-openings/${job}`
}
const redirectToWebsite = (url) => {
window.open(url, '_blank')
}
const canManageJob = computed(() => {
if (!user.data?.name || !job.data) return false
return user.data.name === job.data.owner || user.data?.is_moderator
})
usePageMeta(() => {
return {
title: job.data?.job_title,
icon: brand.favicon,
}
})
</script>
<style>
p {
margin-bottom: 0.5rem !important;
line-height: 1.5;
}
p span {
line-height: 1.5;
}
</style>