Hello,
I have a select input that I wanted to generate & control with logic because I want to show 3 options in one case (user has certain plan) and 2 options in another case.
I didn’t want to rely on DB/Backend to generate the options and at the same time the manual list didn’t offer me a way to show/hide options. Therefore, I used the following code which I hope you can find helpful if you want to control your options based on logic and not have to duplicate the input select.
// Define the condition
let condition = true; // Replace with your actual condition
// Define the two different lists
let list1 = [
{ label: 'BuyTest Label here', value: 'BuyTest' },
{ label: 'Buy Label here', value: 'Buy' },
{ label: 'Sales Label here', value: 'Sales' },
];
let list2 = [
{ label: 'BuyTest Label here', value: 'BuyTest' },
{ label: 'Sales Label here', value: 'Sales' },
];
// Use the condition to determine which list to return
return condition ? list1 : list2;