Make order customer picker searchable and reload the list on open.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-11 18:17:56 +02:00
co-authored by Cursor
parent 5d70002345
commit 9d76af8963
3 changed files with 105 additions and 13 deletions
+15 -1
View File
@@ -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,