better group distribution partner in Tickets
This commit is contained in:
parent
de73bc9211
commit
ffc5b12410
|
|
@ -78,9 +78,26 @@ function TicketList() {
|
|||
.catch(() => {});
|
||||
}, []);
|
||||
|
||||
// Group partner names that differ only by case / whitespace so the same
|
||||
// partner does not appear as multiple dropdown entries (e.g. "Breu AG" vs
|
||||
// "Breu Ag"). Normalize for matching, but show one canonical label per group.
|
||||
const normalizePartner = (p: string) =>
|
||||
p.trim().replace(/\s+/g, ' ').toLowerCase();
|
||||
|
||||
const partnerOptions = Array.from(
|
||||
new Set(tickets.map((t) => t.distributionPartner).filter((p) => p && p.trim() !== ''))
|
||||
).sort();
|
||||
tickets
|
||||
.map((t) => t.distributionPartner)
|
||||
.filter((p) => p && p.trim() !== '')
|
||||
.reduce((map, p) => {
|
||||
const key = normalizePartner(p);
|
||||
const display = p.trim().replace(/\s+/g, ' ');
|
||||
const current = map.get(key);
|
||||
// One canonical label per group; pick the alphabetically first spelling.
|
||||
if (!current || display.localeCompare(current) < 0) map.set(key, display);
|
||||
return map;
|
||||
}, new Map<string, string>())
|
||||
.values()
|
||||
).sort((a, b) => a.localeCompare(b));
|
||||
|
||||
const assigneeOptions = adminUsers
|
||||
.filter((u) => {
|
||||
|
|
@ -99,7 +116,9 @@ function TicketList() {
|
|||
t.subject.toLowerCase().includes(search.toLowerCase()) ||
|
||||
t.installationName.toLowerCase().includes(search.toLowerCase());
|
||||
const matchesStatus = statusFilter.length === 0 || statusFilter.includes(t.status);
|
||||
const matchesPartner = partnerFilter === '' || t.distributionPartner === partnerFilter;
|
||||
const matchesPartner =
|
||||
partnerFilter === '' ||
|
||||
normalizePartner(t.distributionPartner ?? '') === normalizePartner(partnerFilter);
|
||||
const matchesAssignee =
|
||||
assigneeFilter === '' ||
|
||||
(assigneeFilter === '__unassigned__'
|
||||
|
|
|
|||
Loading…
Reference in New Issue