fix_trial
This commit is contained in:
parent
21a2d41b10
commit
af769258d2
@ -1096,14 +1096,15 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
const customersData = await customersResponse.json();
|
||||
const customersMap = customersData.customerMap || {};
|
||||
|
||||
// Collect unique trial customer names
|
||||
// Collect unique trial customer names - only include valid customer names
|
||||
const trialCustomerNames = new Set();
|
||||
trialPeriods.forEach(period => {
|
||||
// Check if customerId is in map, otherwise use customerId directly as name
|
||||
const customerName = customersMap[period.customerId] || period.customerId;
|
||||
// Only add if customerId exists in map (valid customer)
|
||||
const customerName = customersMap[period.customerId];
|
||||
if (customerName) {
|
||||
trialCustomerNames.add(customerName);
|
||||
}
|
||||
// If customerId not in map, skip it (deleted customer) - don't add UUID as name
|
||||
});
|
||||
|
||||
// Update total customers to include trial customers
|
||||
|
||||
@ -343,27 +343,23 @@ func (h *TrialPeriodHandler) GetTrialCustomerList(w http.ResponseWriter, r *http
|
||||
}
|
||||
}
|
||||
|
||||
// Get unique customer names
|
||||
// Get unique customer names (only include customers that exist in storage)
|
||||
seenNames := make(map[string]bool)
|
||||
var customerNames []string
|
||||
|
||||
for customerID := range customerIDs {
|
||||
// Try to get customer name from customer storage
|
||||
var customerName string
|
||||
customer, err := h.customerStorage.GetCustomerByID(customerID)
|
||||
if err == nil && customer != nil && customer.CustomerName != "" {
|
||||
customerName = customer.CustomerName
|
||||
} else {
|
||||
// If customer not found, use customer ID as name
|
||||
customerName = customerID
|
||||
}
|
||||
|
||||
customerName := customer.CustomerName
|
||||
// Add to list if not seen before
|
||||
if !seenNames[customerName] {
|
||||
customerNames = append(customerNames, customerName)
|
||||
seenNames[customerName] = true
|
||||
}
|
||||
}
|
||||
// Skip customers that don't exist in storage (don't show ID as name)
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user