fix format options to not add cat field. Fixes only categories getting applied to certain dropdowns
This commit is contained in:
@@ -192,13 +192,15 @@ export function formatCustomFieldOptions(
|
|||||||
// For a flat list, simply format the options based on the "name" property
|
// For a flat list, simply format the options based on the "name" property
|
||||||
return _formatOptions(data, { label: "name", flat: true });
|
return _formatOptions(data, { label: "name", flat: true });
|
||||||
} else {
|
} else {
|
||||||
|
console.log(data);
|
||||||
// Predefined categories for organizing the custom fields
|
// Predefined categories for organizing the custom fields
|
||||||
const categories = ["Client", "Site", "Agent"];
|
const categories = ["Client", "Site", "Agent"];
|
||||||
const options: Option[] = [];
|
const options: Option[] = [];
|
||||||
|
|
||||||
categories.forEach((cat) => {
|
categories.forEach((cat) => {
|
||||||
// Add a category header as an option
|
// Add a category header as an option
|
||||||
options.push({ category: cat, label: cat, value: cat }); // Assuming you want the category itself as an option
|
options.push({ category: cat, label: cat, value: cat });
|
||||||
|
console.log(cat);
|
||||||
|
|
||||||
// Filter and map the custom fields that match the current category
|
// Filter and map the custom fields that match the current category
|
||||||
const matchingFields = data
|
const matchingFields = data
|
||||||
@@ -206,7 +208,6 @@ export function formatCustomFieldOptions(
|
|||||||
.map((custom_field) => ({
|
.map((custom_field) => ({
|
||||||
label: custom_field.name,
|
label: custom_field.name,
|
||||||
value: custom_field.id,
|
value: custom_field.id,
|
||||||
category: cat, // Include the category in each option for clarity or further processing
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Sort the filtered custom fields by their labels and add them to the options
|
// Sort the filtered custom fields by their labels and add them to the options
|
||||||
@@ -219,6 +220,7 @@ export function formatCustomFieldOptions(
|
|||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatClientOptions(data: Client[], flat = false) {
|
export function formatClientOptions(data: Client[], flat = false) {
|
||||||
return _formatOptions(data, { label: "name", flat: flat });
|
return _formatOptions(data, { label: "name", flat: flat });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user