refactor(select-birth-place): simplify regency selection by removing pagination

Remove pagination and search functionality from regency selection as they're not needed in this context. Replace ComboboxPaginated with simpler Combobox component and adjust useRegencies composable options accordingly.
This commit is contained in:
Khafid Prayoga
2025-10-14 13:01:01 +07:00
parent bc286f16c8
commit ed9dcd9753
@@ -1,6 +1,6 @@
<script setup lang="ts">
import type { FormErrors } from '~/types/error'
import ComboboxPaginated from '~/components/pub/my-ui/combobox/combobox-paginated.vue'
import Combobox from '~/components/pub/my-ui/combobox/combobox.vue'
import FieldGroup from '~/components/pub/my-ui/form/field-group.vue'
import Field from '~/components/pub/my-ui/form/field.vue'
import Label from '~/components/pub/my-ui/form/label.vue'
@@ -25,17 +25,11 @@ const {
fieldGroupClass,
} = props
// Gunakan composable untuk mengelola data regencies
const {
fetchRegencies,
regencyOptions,
isLoading,
error,
paginationMeta,
nextPage,
prevPage,
setSearch,
} = useRegencies({ enablePagination: true, pageSize: 10,enableSearch:true })
// Gunakan composable untuk mengelola data regencies (tanpa pagination & tanpa province code)
const { fetchRegencies, regencyOptions, isLoading, error } = useRegencies({
enablePagination: false,
enableSearch: false,
})
// Computed untuk menentukan placeholder berdasarkan state
const dynamicPlaceholder = computed(() => {
@@ -52,10 +46,6 @@ const isFieldDisabled = computed(() => {
onMounted(() => {
fetchRegencies()
})
function onSearchChange(query: string) {
setSearch(query)
}
</script>
<template>
@@ -67,17 +57,14 @@ function onSearchChange(query: string) {
<FormField v-slot="{ componentField }" :name="fieldName">
<FormItem>
<FormControl>
<ComboboxPaginated :id="fieldName" v-bind="componentField" :items="regencyOptions"
:placeholder="dynamicPlaceholder" :is-disabled="isFieldDisabled" search-placeholder="Cari tempat lahir..."
<Combobox
:id="fieldName"
v-bind="componentField"
:items="regencyOptions"
:placeholder="dynamicPlaceholder"
:is-disabled="isFieldDisabled"
search-placeholder="Cari tempat lahir..."
empty-message="Tempat lahir tidak ditemukan"
:page="paginationMeta.page"
:total-page="paginationMeta.totalPage"
:has-next="paginationMeta.hasNext"
:has-prev="paginationMeta.hasPrev"
:is-loading="isLoading"
@update:searchText="onSearchChange"
@next="nextPage()"
@prev="prevPage()"
/>
</FormControl>
<FormMessage />