-
Couldn't load subscription status.
- Fork 1
OLO: headless form modifiers #413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… and enhance modifier selection handling
…t for improved rendering
…roup and modifiers to item details components
…nto headless-modifiers
| if (singleSelect) { | ||
| // Single select behavior: select the modifier, replacing any existing selection | ||
| selectedModifiers.set({ | ||
| ...currentSelectedModifiers, | ||
| [modifierGroupId]: [modifierId], | ||
| }); | ||
| } else { | ||
| // Multi-select behavior: toggle the modifier | ||
| if (isModifierSelected) { | ||
| // Remove the modifier if it exists | ||
| const updatedModifierIds = groupModifierIds.filter( | ||
| (id) => id !== modifierId, | ||
| ); | ||
| selectedModifiers.set({ | ||
| ...currentSelectedModifiers, | ||
| [modifierGroupId]: updatedModifierIds, | ||
| }); | ||
| } else { | ||
| // Add the modifier to the existing selection | ||
| selectedModifiers.set({ | ||
| ...currentSelectedModifiers, | ||
| [modifierGroupId]: [...groupModifierIds, modifierId], | ||
| }); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to complicated, I'd at least separate the modifierIds to update and the set(...)
something like
const modifierIds = getUpdatedModifiers();
selectedModifiers.set({
...currentSelectedModifiers,
[modifierGroupId]: modifierIds,
});
| // Get selected modifier IDs for this group | ||
| const groupId = modifierGroup._id; | ||
| const groupSelectedModifierIds = groupId | ||
| ? selectedModifiers[groupId] || [] | ||
| : []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it better to move the logic to the service
No description provided.