fix_followup
This commit is contained in:
parent
d7d1872db6
commit
da118f41f9
@ -278,11 +278,18 @@ func (h *FollowUpHandler) GetCustomerList(w http.ResponseWriter, r *http.Request
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Deduplicate by customer name - only show each unique customer name once in dropdown
|
// Deduplicate by customer name - only show each unique customer name once in dropdown
|
||||||
// Use a map to track which customer names we've already added
|
// But also create a complete mapping of all customer IDs to names
|
||||||
seenNames := make(map[string]bool)
|
seenNames := make(map[string]bool)
|
||||||
var customerList []CustomerInfo
|
customerMap := make(map[string]string) // All ID -> Name mappings
|
||||||
|
var customerList []CustomerInfo // Deduplicated list for dropdown
|
||||||
|
|
||||||
for _, customer := range customers {
|
for _, customer := range customers {
|
||||||
if customer.CustomerName != "" && !seenNames[customer.CustomerName] {
|
if customer.CustomerName != "" {
|
||||||
|
// Add to complete mapping (all records)
|
||||||
|
customerMap[customer.ID] = customer.CustomerName
|
||||||
|
|
||||||
|
// Add to deduplicated list (only first occurrence of each name)
|
||||||
|
if !seenNames[customer.CustomerName] {
|
||||||
customerList = append(customerList, CustomerInfo{
|
customerList = append(customerList, CustomerInfo{
|
||||||
ID: customer.ID,
|
ID: customer.ID,
|
||||||
CustomerName: customer.CustomerName,
|
CustomerName: customer.CustomerName,
|
||||||
@ -291,11 +298,14 @@ func (h *FollowUpHandler) GetCustomerList(w http.ResponseWriter, r *http.Request
|
|||||||
fmt.Printf("DEBUG: Added customer: ID=%s, Name=%s\n", customer.ID, customer.CustomerName)
|
fmt.Printf("DEBUG: Added customer: ID=%s, Name=%s\n", customer.ID, customer.CustomerName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Printf("DEBUG: Total customer list items: %d\n", len(customerList))
|
fmt.Printf("DEBUG: Total unique customer list items: %d\n", len(customerList))
|
||||||
|
fmt.Printf("DEBUG: Total customer ID mappings: %d\n", len(customerMap))
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
json.NewEncoder(w).Encode(map[string]interface{}{
|
||||||
"customers": customerList,
|
"customers": customerList, // Deduplicated list for dropdown
|
||||||
|
"customerMap": customerMap, // Complete ID->Name mapping for display
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user