add town filter
This commit is contained in:
parent
ce61630350
commit
2b5fdb9e57
2 changed files with 35 additions and 7 deletions
|
|
@ -6,11 +6,13 @@ import { Button } from '@/components/ui/button'
|
||||||
defineProps<{
|
defineProps<{
|
||||||
category: string
|
category: string
|
||||||
search: string
|
search: string
|
||||||
|
town: string
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
'update:category': [value: string]
|
'update:category': [value: string]
|
||||||
'update:search': [value: string]
|
'update:search': [value: string]
|
||||||
|
'update:town': [value: string]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const categories = [
|
const categories = [
|
||||||
|
|
@ -23,6 +25,16 @@ const categories = [
|
||||||
{ id: 'lancha', label: 'Lanchas' },
|
{ id: 'lancha', label: 'Lanchas' },
|
||||||
{ id: 'other', label: 'Other' }
|
{ id: 'other', label: 'Other' }
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const towns = [
|
||||||
|
{ id: 'all', label: 'All Towns' },
|
||||||
|
{ id: 'San Marcos', label: 'San Marcos' },
|
||||||
|
{ id: 'Tzununa', label: 'Tzununa' },
|
||||||
|
{ id: 'San Pablo', label: 'San Pablo' },
|
||||||
|
{ id: 'San Pedro', label: 'San Pedro' },
|
||||||
|
{ id: 'Panajachel', label: 'Panajachel' },
|
||||||
|
{ id: 'Jaibalito', label: 'Jaibalito' }
|
||||||
|
]
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -36,12 +48,22 @@ const categories = [
|
||||||
class="pl-10" placeholder="Search..." />
|
class="pl-10" placeholder="Search..." />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Category Filter -->
|
<div class="flex flex-col md:flex-row gap-2">
|
||||||
<div class="flex gap-2 overflow-x-auto pb-2 md:pb-0">
|
<!-- Category Filter -->
|
||||||
<Button v-for="cat in categories" :key="cat.id" @click="emit('update:category', cat.id)"
|
<div class="flex gap-2 overflow-x-auto pb-2 md:pb-0">
|
||||||
:variant="category === cat.id ? 'default' : 'secondary'" size="sm" class="rounded-full">
|
<Button v-for="cat in categories" :key="cat.id" @click="emit('update:category', cat.id)"
|
||||||
{{ cat.label }}
|
:variant="category === cat.id ? 'default' : 'secondary'" size="sm" class="rounded-full">
|
||||||
</Button>
|
{{ cat.label }}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Town Filter -->
|
||||||
|
<div class="flex gap-2 overflow-x-auto pb-2 md:pb-0">
|
||||||
|
<Button v-for="t in towns" :key="t.id" @click="emit('update:town', t.id)"
|
||||||
|
:variant="town === t.id ? 'default' : 'secondary'" size="sm" class="rounded-full">
|
||||||
|
{{ t.label }}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import { type DirectoryItem } from '@/types/directory'
|
||||||
import DirectoryFilter from './DirectoryFilter.vue'
|
import DirectoryFilter from './DirectoryFilter.vue'
|
||||||
|
|
||||||
const selectedCategory = ref<string>('all')
|
const selectedCategory = ref<string>('all')
|
||||||
|
const selectedTown = ref<string>('all')
|
||||||
const searchQuery = ref('')
|
const searchQuery = ref('')
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
|
|
@ -42,6 +43,11 @@ const filteredItems = computed(() => {
|
||||||
results = results.filter(item => item.category === selectedCategory.value)
|
results = results.filter(item => item.category === selectedCategory.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply town filter
|
||||||
|
if (selectedTown.value !== 'all') {
|
||||||
|
results = results.filter(item => item.town === selectedTown.value)
|
||||||
|
}
|
||||||
|
|
||||||
return results
|
return results
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -50,7 +56,7 @@ const filteredItems = computed(() => {
|
||||||
<div class="container mx-auto px-4 py-8">
|
<div class="container mx-auto px-4 py-8">
|
||||||
<!-- Filters -->
|
<!-- Filters -->
|
||||||
<div class="mb-8 space-y-4 md:space-y-0 md:flex md:items-center md:justify-between">
|
<div class="mb-8 space-y-4 md:space-y-0 md:flex md:items-center md:justify-between">
|
||||||
<DirectoryFilter v-model:category="selectedCategory" v-model:search="searchQuery" />
|
<DirectoryFilter v-model:category="selectedCategory" v-model:search="searchQuery" v-model:town="selectedTown" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Grid -->
|
<!-- Grid -->
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue