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 customersData = await customersResponse.json();
|
||||||
const customersMap = customersData.customerMap || {};
|
const customersMap = customersData.customerMap || {};
|
||||||
|
|
||||||
// Collect unique trial customer names
|
// Collect unique trial customer names - only include valid customer names
|
||||||
const trialCustomerNames = new Set();
|
const trialCustomerNames = new Set();
|
||||||
trialPeriods.forEach(period => {
|
trialPeriods.forEach(period => {
|
||||||
// Check if customerId is in map, otherwise use customerId directly as name
|
// Only add if customerId exists in map (valid customer)
|
||||||
const customerName = customersMap[period.customerId] || period.customerId;
|
const customerName = customersMap[period.customerId];
|
||||||
if (customerName) {
|
if (customerName) {
|
||||||
trialCustomerNames.add(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
|
// Update total customers to include trial customers
|
||||||
|
|||||||
@ -343,26 +343,22 @@ 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)
|
seenNames := make(map[string]bool)
|
||||||
var customerNames []string
|
var customerNames []string
|
||||||
|
|
||||||
for customerID := range customerIDs {
|
for customerID := range customerIDs {
|
||||||
// Try to get customer name from customer storage
|
// Try to get customer name from customer storage
|
||||||
var customerName string
|
|
||||||
customer, err := h.customerStorage.GetCustomerByID(customerID)
|
customer, err := h.customerStorage.GetCustomerByID(customerID)
|
||||||
if err == nil && customer != nil && customer.CustomerName != "" {
|
if err == nil && customer != nil && customer.CustomerName != "" {
|
||||||
customerName = customer.CustomerName
|
customerName := customer.CustomerName
|
||||||
} else {
|
// Add to list if not seen before
|
||||||
// If customer not found, use customer ID as name
|
if !seenNames[customerName] {
|
||||||
customerName = customerID
|
customerNames = append(customerNames, customerName)
|
||||||
}
|
seenNames[customerName] = true
|
||||||
|
}
|
||||||
// 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")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user