Sniberb
Sniberb
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
Works wonders!
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
export const getFilteredOptions = (level, selections, availableLevels, properties) => {
const index = availableLevels.indexOf(level);
const filters = availableLevels.slice(0, index);

const filteredLevels = properties.filter(property =>
filters.every(filter => !selections[filter] || property[filter] === selections[filter]),
);

const uniqueOptions = [...new Set(filteredLevels.map(property => property[level]))];

return mapForSelect(uniqueOptions);
};
export const getFilteredOptions = (level, selections, availableLevels, properties) => {
const index = availableLevels.indexOf(level);
const filters = availableLevels.slice(0, index);

const filteredLevels = properties.filter(property =>
filters.every(filter => !selections[filter] || property[filter] === selections[filter]),
);

const uniqueOptions = [...new Set(filteredLevels.map(property => property[level]))];

return mapForSelect(uniqueOptions);
};
const availableLevels = ['entrance', 'block', 'stair', 'floor', 'door'].filter(level => properties.some(property => property[level]));

const selections = {
entrance: selectedEntrance,
block: selectedBlock,
stair: selectedStair,
floor: selectedFloor,
};
const entrances = availableLevels.includes('entrance') ? getFilteredOptions('entrance', selections) : [];
const blocks = availableLevels.includes('block') ? getFilteredOptions('block', selections) : [];
const stairs = availableLevels.includes('stair') ? getFilteredOptions('stair', selections) : [];
const floors = availableLevels.includes('floor') ? getFilteredOptions('floor', selections) : [];
const doors = availableLevels.includes('door') ? getFilteredOptions('door', selections) : [];
const availableLevels = ['entrance', 'block', 'stair', 'floor', 'door'].filter(level => properties.some(property => property[level]));

const selections = {
entrance: selectedEntrance,
block: selectedBlock,
stair: selectedStair,
floor: selectedFloor,
};
const entrances = availableLevels.includes('entrance') ? getFilteredOptions('entrance', selections) : [];
const blocks = availableLevels.includes('block') ? getFilteredOptions('block', selections) : [];
const stairs = availableLevels.includes('stair') ? getFilteredOptions('stair', selections) : [];
const floors = availableLevels.includes('floor') ? getFilteredOptions('floor', selections) : [];
const doors = availableLevels.includes('door') ? getFilteredOptions('door', selections) : [];
I ended up doing this
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
thanks for the guidance
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
No description
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
No description
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
I selected the 2nd floor, and then all the other options dissappear
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
No description
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
Tried this and it works! It does filter everything with what's available, but if you want to change any input, it only shows the selected option
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
Im checking it, thanks for the help btw, really appreciated
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
I dont get how it separates the available Stairs for the selected block for example
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
it all goes back to one array
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
how do you use that tho
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
In this order: Block, Stair, Floor, Door; the user is allowed to select any option. If there are no Blocks, then the frist input starts at Stair, if there are no Stairs but there are blocks, then it goes as Block, Floor, Door: More examples: - Block, Stair, Floor, Door - Stair, Floor, Door - Floor Door - Block, Floor, Door
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
A building may not have any blocks, and just floors and stairs
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
That if any of the props are missing, the code will stop working as im using direct comparisons on the .filter()
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
Do you need me to explain something further?
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
You can select any block as its the first input you use, but then you can only select the Stairs that are available for that block
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
At first, only the Block input is allowed, and you can select any block available from the array. Then they will stop being disabled in order
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
The objects look like this:
{
"stair": "3",
"floor": "1",
"door": "A",
"entrance": "",
"block": "2"
}
{
"stair": "3",
"floor": "1",
"door": "A",
"entrance": "",
"block": "2"
}
35 replies