Skip to content
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

correctly handle required add-ons #266

Merged
merged 1 commit into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
const level = watch('level')

useEffect(() => {
const subscription = watch((value, { name, type }) => {

Check warning on line 37 in src/components/funnels/funnels/register/steps/ticket/level/addons/addon.tsx

View workflow job for this annotation

GitHub Actions / build-and-test

Arrow function has a complexity of 13. Maximum allowed is 10

Check warning on line 37 in src/components/funnels/funnels/register/steps/ticket/level/addons/addon.tsx

View workflow job for this annotation

GitHub Actions / build-and-test

Arrow function has too many statements (11). Maximum allowed is 10
if (resetOnLevelChange && name === 'level' && type === 'change') {
const levelValue = value.level as Exclude<typeof value.level, undefined>

setValue(`addons.${addon.id}.selected`, isIncluded(levelValue) && !isUnavailable(levelValue) || addon.default)
setValue(`addons.${addon.id}.selected`, (isIncluded(levelValue) || isRequired(levelValue)) && !isUnavailable(levelValue) || addon.default)
}

if (name) {
Expand Down Expand Up @@ -67,7 +67,7 @@
label={addon.id}
description={addon.id}
price={isIncluded(level) ? 0 : addon.price}
disabled={isIncluded(level) || isRequired(level)}
disabled={isIncluded(level) || isRequired(level) || addon.id === 'stage-pass'}
{...register(`addons.${addon.id}.selected`)}
>
{Object.entries(addon.options).map(([id, option]) =>
Expand Down
3 changes: 3 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ const configEf = {
type: ['day'],
},
hidden: false,
resetOn: {
levelChange: true,
},
},
'tshirt': {
price: 20,
Expand Down
Loading