Skip to content

Commit

Permalink
Merge pull request #1113 from iamejaaz/search-functionality-in-jobs
Browse files Browse the repository at this point in the history
feat: search functionality in jobs
  • Loading branch information
pateljannat authored Nov 15, 2024
2 parents 629c237 + 61e13aa commit dfb22c8
Showing 1 changed file with 57 additions and 6 deletions.
63 changes: 57 additions & 6 deletions frontend/src/pages/Jobs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,22 @@
class="h-7"
:items="[{ label: __('Jobs'), route: { name: 'Jobs' } }]"
/>
<div class="flex">
<div class="flex space-x-2">
<div class="w-40 md:w-44">
<FormControl
v-model="jobType"
type="select"
:options="jobTypes"
:placeholder="__('Type')"
/>
</div>
<div class="w-28 md:w-36">
<FormControl type="text" placeholder="Search" v-model="searchQuery">
<template #prefix>
<Search class="w-4 h-4 stroke-1.5 text-gray-600" name="search" />
</template>
</FormControl>
</div>
<router-link
v-if="user.data?.name"
:to="{
Expand All @@ -26,9 +41,9 @@
</router-link>
</div>
</header>
<div v-if="jobs.data?.length">
<div v-if="jobsList?.length">
<div class="divide-y lg:w-3/4 mx-auto p-5">
<div v-for="job in jobs.data">
<div v-for="job in jobsList">
<router-link
:to="{
name: 'JobDetail',
Expand All @@ -47,13 +62,22 @@
</div>
</template>
<script setup>
import { Button, Breadcrumbs, createResource } from 'frappe-ui'
import { Plus } from 'lucide-vue-next'
import { inject, computed } from 'vue'
import { Button, Breadcrumbs, createResource, FormControl } from 'frappe-ui'
import { Plus, Search } from 'lucide-vue-next'
import { inject, computed, ref, onMounted } from 'vue'
import JobCard from '@/components/JobCard.vue'
import { updateDocumentTitle } from '@/utils'
const user = inject('$user')
const jobType = ref(null)
const searchQuery = ref('')
onMounted(() => {
let queries = new URLSearchParams(location.search)
if (queries.has('type')) {
jobType.value = queries.get('type')
}
})
const jobs = createResource({
url: 'lms.lms.api.get_job_opportunities',
Expand All @@ -68,5 +92,32 @@ const pageMeta = computed(() => {
}
})
const jobsList = computed(() => {
let jobData = jobs.data
if (jobType.value && jobType.value != '') {
jobData = jobData.filter((job) => job.type == jobType.value)
}
if (searchQuery.value) {
let query = searchQuery.value.toLowerCase()
jobData = jobData.filter(
(job) =>
job.job_title.toLowerCase().includes(query) ||
job.company_name.toLowerCase().includes(query) ||
job.location.toLowerCase().includes(query)
)
}
return jobData
})
const jobTypes = computed(() => {
return [
'',
{ label: __('Full Time'), value: 'Full Time' },
{ label: __('Part Time'), value: 'Part Time' },
{ label: __('Contract'), value: 'Contract' },
{ label: __('Freelance'), value: 'Freelance' },
]
})
updateDocumentTitle(pageMeta)
</script>

0 comments on commit dfb22c8

Please sign in to comment.