feat: weights per attribute UI (#18109)

* wip attribut weights

* edit sheet and display in table

* add shrink so badges dont split

* push changes to support weights on csv export

* fix typing issue

* type error

* fall back to 100 weight

---------

Co-authored-by: Udit Takkar <[email protected]>
This commit is contained in:
sean-brydonandUdit Takkar authored and GitHub committed 2024-12-12 11:54:10 +00:00
1 parent b6d6b7cdb4
commit ee3c08918a
18 files changed
+190 -67

No files matched your search

+13 -5
View File
@@ -121,9 +121,12 @@ export const generateCsvRawForMembersTable = (
if (!acc[attr.attributeId]) {
acc[attr.attributeId] = [];
}
acc[attr.attributeId].push(attr.value);
acc[attr.attributeId].push({
value: attr.value,
weight: attr.weight ?? undefined,
});
return acc;
}, {} as Record<string, string[]>);
}, {} as Record<string, { value: string; weight: number | undefined }[]>);
const requiredColumns = [
email, // Members column
@@ -133,9 +136,14 @@ export const generateCsvRawForMembersTable = (
];
// Add attribute columns
const attributeColumns = ATTRIBUTE_IDS.map((attrId) =>
attributeMap[attrId] ? sanitizeValue(attributeMap[attrId].join(",")) : ""
);
const attributeColumns = ATTRIBUTE_IDS.map((attrId) => {
const attributes = attributeMap[attrId];
if (!attributes?.length) return "";
return sanitizeValue(
attributes.map((attr) => (attr.weight ? `${attr.value} (${attr.weight}%)` : attr.value)).join(",")
);
});
return [...requiredColumns, ...attributeColumns];
});