Make order customer picker searchable and reload the list on open.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -39,7 +39,11 @@ export function useOrdersPage() {
|
||||
() => form.customerId.length > 0 && form.companyId.length > 0,
|
||||
)
|
||||
|
||||
const activeCustomers = computed(() => customers.value.filter((c) => c.isActive))
|
||||
const activeCustomers = computed(() => {
|
||||
const list = [...customers.value]
|
||||
list.sort((a, b) => Number(b.isActive) - Number(a.isActive) || a.name.localeCompare(b.name, 'fa'))
|
||||
return list
|
||||
})
|
||||
|
||||
function applyCustomer(customerId: string) {
|
||||
const customer = customers.value.find((c) => c.id === customerId)
|
||||
@@ -48,6 +52,14 @@ export function useOrdersPage() {
|
||||
form.customerPhone = customer?.phone ?? ''
|
||||
}
|
||||
|
||||
async function loadCustomers() {
|
||||
try {
|
||||
customers.value = await customersApi.list()
|
||||
} catch (err) {
|
||||
toast.error(err instanceof ApiError ? err.message : 'بارگذاری مشتریان انجام نشد.')
|
||||
}
|
||||
}
|
||||
|
||||
const filteredOrders = computed(() => {
|
||||
let list = orderList.value
|
||||
if (activeTab.value !== 'all') {
|
||||
@@ -200,6 +212,7 @@ export function useOrdersPage() {
|
||||
Object.assign(form, emptyForm())
|
||||
formError.value = ''
|
||||
showAddModal.value = true
|
||||
void loadCustomers()
|
||||
}
|
||||
|
||||
function closeAddModal() {
|
||||
@@ -241,6 +254,7 @@ export function useOrdersPage() {
|
||||
customers,
|
||||
activeCustomers,
|
||||
applyCustomer,
|
||||
loadCustomers,
|
||||
orderList,
|
||||
activeTab,
|
||||
selectedOrderId,
|
||||
|
||||
Reference in New Issue
Block a user