refactor(composables): update API query params and improve code style
- Standardize parameter naming with hyphens instead of underscores - Remove page size limit and enable no-limit flag for all region queries - Improve arrow function syntax consistency and formatting
This commit is contained in:
@@ -73,9 +73,9 @@ export function useDistricts(regencyCode: Ref<string | undefined> | string | und
|
||||
|
||||
try {
|
||||
const response = await districtService.getList({
|
||||
'page-size': '50',
|
||||
sort: 'name:asc',
|
||||
regency_code: code,
|
||||
'regency-code': code,
|
||||
'page-no-limit': true,
|
||||
})
|
||||
|
||||
if (response.success) {
|
||||
|
||||
@@ -13,11 +13,11 @@ const error = ref<string | null>(null)
|
||||
export function useProvinces() {
|
||||
// Computed untuk format SelectItem
|
||||
const provinceOptions = computed<SelectItem[]>(() => {
|
||||
return provincesCache.value.map(province => ({
|
||||
return provincesCache.value.map((province) => ({
|
||||
label: toTitleCase(province.name),
|
||||
value: province.code,
|
||||
// code: province.code,
|
||||
searchValue: `${province.code} ${province.name}`.trim() // Untuk search internal combobox
|
||||
searchValue: `${province.code} ${province.name}`.trim(), // Untuk search internal combobox
|
||||
}))
|
||||
})
|
||||
|
||||
@@ -38,8 +38,8 @@ export function useProvinces() {
|
||||
|
||||
try {
|
||||
const response = await provinceService.getList({
|
||||
'page-no-limit': '1',
|
||||
'sort': 'name:asc'
|
||||
'page-no-limit': true,
|
||||
sort: 'name:asc',
|
||||
})
|
||||
|
||||
if (response.success) {
|
||||
@@ -59,14 +59,12 @@ export function useProvinces() {
|
||||
|
||||
// Function untuk mencari province berdasarkan code
|
||||
function getProvinceByCode(code: string): Province | undefined {
|
||||
return provincesCache.value.find(province => province.code === code)
|
||||
return provincesCache.value.find((province) => province.code === code)
|
||||
}
|
||||
|
||||
// Function untuk mencari province berdasarkan name
|
||||
function getProvinceByName(name: string): Province | undefined {
|
||||
return provincesCache.value.find(province =>
|
||||
province.name.toLowerCase() === name.toLowerCase()
|
||||
)
|
||||
return provincesCache.value.find((province) => province.name.toLowerCase() === name.toLowerCase())
|
||||
}
|
||||
|
||||
// Function untuk clear cache (jika diperlukan)
|
||||
|
||||
@@ -74,9 +74,9 @@ export function useRegencies(provinceCode: Ref<string | undefined> | string | un
|
||||
|
||||
try {
|
||||
const response = await regencyService.getList({
|
||||
'page-size': '50',
|
||||
sort: 'name:asc',
|
||||
province_code: code,
|
||||
'page-no-limit': true,
|
||||
'province-code': code,
|
||||
})
|
||||
|
||||
if (response.success) {
|
||||
|
||||
@@ -74,9 +74,9 @@ export function useVillages(districtCode: Ref<string | undefined> | string | und
|
||||
|
||||
try {
|
||||
const response = await villageService.getList({
|
||||
'page-size': '50',
|
||||
sort: 'name:asc',
|
||||
district_code: code,
|
||||
'district-code': code,
|
||||
'page-no-limit': true,
|
||||
})
|
||||
|
||||
if (response.success) {
|
||||
|
||||
Reference in New Issue
Block a user