-
Notifications
You must be signed in to change notification settings - Fork 4
86b7h2jgh - Fix: add asterisks to mandatory fields on add new item form #743
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
src/i18n/en.json
Outdated
| "standard_rate": "Standard rate", | ||
| "onsite_rate": "On site rate", | ||
| "default_quantity": "Default quantity", | ||
| "name": "Name *", |
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.
@niko-exo i do thnk that i would be better to update the fields like
https://github.com/fntechgit/summit-admin/blob/cf8c1749e92a5c08b60bf5803010a63e9417e5d0/src/components/mui/formik-inputs/mui-formik-textfield.js to support the required attr instead of change labels
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've removed the asterisks and modified the text field to have the same logic as te datepicker.
| early_bird_rate: decimalValidation(), | ||
| standard_rate: decimalValidation(), | ||
| onsite_rate: decimalValidation(), | ||
| early_bird_rate: decimalValidation().required( |
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.
@niko-exo please rebase against main and review
we already addd required to decimal validation
| onsite_rate: decimalValidation().required( | ||
| T.translate("validation.required") | ||
| ), | ||
| default_quantity: numberValidation() |
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.
@niko-exo also please check this
default_quantity: positiveNumberValidation(),
quantity_limit_per_sponsor: positiveNumberValidation(),
quantity_limit_per_show: positiveNumberValidation(),
meta_fields: formMetafieldsValidation()
smarcet
left a comment
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.
@niko-exo please review comments
9f6d2bd to
8c05d2f
Compare
|
Branch rebased |
📝 WalkthroughWalkthroughAdded a Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
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.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@src/i18n/en.json`:
- Around line 2579-2583: Remove the trailing asterisks from the base keys
sponsor_form_item_list.name, sponsor_form_item_list.early_bird_rate,
sponsor_form_item_list.standard_rate, sponsor_form_item_list.onsite_rate, and
sponsor_form_item_list.default_quantity and add those asterisks to the
corresponding edit form keys: sponsor_form_item_list.edit_item.name,
sponsor_form_item_list.edit_item.early_bird_rate,
sponsor_form_item_list.edit_item.standard_rate,
sponsor_form_item_list.edit_item.onsite_rate, and
sponsor_form_item_list.edit_item.default_quantity so the add/edit form uses the
translated labels with asterisks while the table headers remain plain.
In
`@src/pages/sponsors/sponsor-form-item-list-page/components/sponsor-form-item-form.js`:
- Around line 76-80: positiveNumberValidation() in utils/yup.js is missing
.required(), so fields using it (default_quantity, quantity_limit_per_sponsor,
quantity_limit_per_show) are allowed empty despite UI requiring them; update
positiveNumberValidation() to include .required() (like decimalValidation()
does) and keep the existing positive/number constraints so those three form
fields are validated as required and non-negative integers.
src/i18n/en.json
Outdated
| "name": "Name *", | ||
| "early_bird_rate": "Early bird rate *", | ||
| "standard_rate": "Standard rate *", | ||
| "onsite_rate": "On site rate *", | ||
| "default_quantity": "Default quantity *", |
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.
🧩 Analysis chain
🏁 Script executed:
rg -n -C2 'sponsor_form_item_list\.(name|early_bird_rate|standard_rate|onsite_rate|default_quantity)\b' -g '!**/node_modules/**'Repository: fntechgit/summit-admin
Length of output: 2285
🏁 Script executed:
rg -n -C2 'sponsor_form_item_list\.edit_item\.(name|early_bird_rate|standard_rate|onsite_rate|default_quantity)\b' -g '!**/node_modules/**'Repository: fntechgit/summit-admin
Length of output: 3203
Update asterisks to the correct translation keys for the add/edit form.
The asterisks were added to sponsor_form_item_list.* (table column headers), but the add/edit form uses sponsor_form_item_list.edit_item.* keys instead. The asterisks will not appear in the form. Move them to:
sponsor_form_item_list.edit_item.namesponsor_form_item_list.edit_item.early_bird_ratesponsor_form_item_list.edit_item.standard_ratesponsor_form_item_list.edit_item.onsite_ratesponsor_form_item_list.edit_item.default_quantity
Remove asterisks from the base keys (lines 2579-2583) since they are used only for table headers.
🤖 Prompt for AI Agents
In `@src/i18n/en.json` around lines 2579 - 2583, Remove the trailing asterisks
from the base keys sponsor_form_item_list.name,
sponsor_form_item_list.early_bird_rate, sponsor_form_item_list.standard_rate,
sponsor_form_item_list.onsite_rate, and sponsor_form_item_list.default_quantity
and add those asterisks to the corresponding edit form keys:
sponsor_form_item_list.edit_item.name,
sponsor_form_item_list.edit_item.early_bird_rate,
sponsor_form_item_list.edit_item.standard_rate,
sponsor_form_item_list.edit_item.onsite_rate, and
sponsor_form_item_list.edit_item.default_quantity so the add/edit form uses the
translated labels with asterisks while the table headers remain plain.
| name="name" | ||
| label={T.translate("sponsor_form_item_list.edit_item.name")} | ||
| fullWidth | ||
| required | ||
| /> |
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.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Find yup utility files
find src -type f \( -name '*yup*' -o -name '*validation*' \) | head -20Repository: fntechgit/summit-admin
Length of output: 82
🏁 Script executed:
cat -n src/utils/yup.jsRepository: fntechgit/summit-admin
Length of output: 6358
🏁 Script executed:
cat -n src/pages/sponsors/sponsor-form-item-list-page/components/sponsor-form-item-form.js | head -200Repository: fntechgit/summit-admin
Length of output: 7438
Only positiveNumberValidation() lacks required enforcement; decimalValidation() already has it.
The form uses noValidate, so native HTML5 checks are disabled. However, the issue is narrower than stated: decimalValidation() (line 45-54 in utils/yup.js) already includes .required() on line 50, so early_bird_rate, standard_rate, and onsite_rate are properly validated.
The actual problem is positiveNumberValidation() (line 90-93 in utils/yup.js) does not include .required(). This means default_quantity (line 152), quantity_limit_per_sponsor, and quantity_limit_per_show can pass validation even when empty, despite the UI marking them required or accepting empty values.
Required fix
export const positiveNumberValidation = () =>
numberValidation()
.integer(T.translate("validation.integer"))
- .min(0, T.translate("validation.number_positive"));
+ .required(T.translate("validation.required"))
+ .min(0, T.translate("validation.number_positive"));🤖 Prompt for AI Agents
In
`@src/pages/sponsors/sponsor-form-item-list-page/components/sponsor-form-item-form.js`
around lines 76 - 80, positiveNumberValidation() in utils/yup.js is missing
.required(), so fields using it (default_quantity, quantity_limit_per_sponsor,
quantity_limit_per_show) are allowed empty despite UI requiring them; update
positiveNumberValidation() to include .required() (like decimalValidation()
does) and keep the existing positive/number constraints so those three form
fields are validated as required and non-negative integers.
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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/components/mui/formik-inputs/mui-formik-textfield.js`:
- Around line 6-10: The component builds finalLabel by concatenating required to
label, which can produce "undefined *" when label is missing; update the
MuiFormikTextField logic (around finalLabel) to guard for empty/undefined label
by using a safe default or conditional concat (e.g., only append " *" when label
is truthy, or derive finalLabel from label ?? '' and then append the required
marker), ensuring finalLabel never becomes "undefined *" while preserving
required behavior.
🧹 Nitpick comments (1)
src/components/mui/formik-inputs/mui-formik-textfield.js (1)
14-22: Add semanticrequiredtoTextField(a11y) and avoid double indicators.
Right nowrequiredonly affects the label string. Consider passingrequired={required}so the input is semantically required (ARIA/HTML). If you keep the manual" *"suffix, suppress MUI’s built‑in asterisk to avoid duplication.🛠️ Suggested tweak (verify MUI behavior)
<TextField name={name} label={finalLabel} + required={required} + InputLabelProps={{ required: false }} {...field}MuiFormikTextField.propTypes = { name: PropTypes.string.isRequired, label: PropTypes.string, - maxLength: PropTypes.number + maxLength: PropTypes.number, + required: PropTypes.bool };
|
Ready for review! |
| const [field, meta] = useField(name); | ||
| const currentLength = field.value?.length || 0; | ||
|
|
||
| const finalLabel = required ? `${label} *` : label; |
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.
@niko-exo label attribute is marked as not required
please add a check and set finalLabel as empty to avoid "* undefined"
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.
Fixed. Good catch!
| import { useField } from "formik"; | ||
|
|
||
| const MuiFormikTextField = ({ name, label, maxLength, ...props }) => { | ||
| const MuiFormikTextField = ({ name, label, maxLength, required, ...props }) => { |
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.
@niko-exo please add requred to prop types and define it with default value as false
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.
Added!
smarcet
left a comment
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.
@niko-exo please review comments
|
Ready for review! |
smarcet
left a comment
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.
LGTM
ref: https://app.clickup.com/t/86b7h2jgh
86b7h2jgh - Fix: add asterisks to mandatory fields on add new item form
Changelog
Links
86b7h2jgh - Add asterisks to mandatory fields
Evidence
2026-01-05_10-16-31.mp4
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.