Skip to content
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
19 changes: 16 additions & 3 deletions src/components/mui/formik-inputs/mui-formik-textfield.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,27 @@ import PropTypes from "prop-types";
import { Box, TextField, Typography } from "@mui/material";
import { useField } from "formik";

const MuiFormikTextField = ({ name, label, maxLength, ...props }) => {
const MuiFormikTextField = ({
name,
label,
maxLength,
required = false,
...props
}) => {
const [field, meta] = useField(name);
const currentLength = field.value?.length || 0;

let finalLabel = "";

if (label) {
finalLabel = required ? `${label} *` : label;
}

return (
<Box>
<TextField
name={name}
label={label}
label={finalLabel}
{...field}
onBlur={field.onBlur}
margin="normal"
Expand All @@ -37,7 +49,8 @@ const MuiFormikTextField = ({ name, label, maxLength, ...props }) => {
MuiFormikTextField.propTypes = {
name: PropTypes.string.isRequired,
label: PropTypes.string,
maxLength: PropTypes.number
maxLength: PropTypes.number,
required: PropTypes.bool
};

export default MuiFormikTextField;
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const SponsorFormItemForm = ({ initialValues, onSubmit }) => {
name="name"
label={T.translate("sponsor_form_item_list.edit_item.name")}
fullWidth
required
/>
Comment on lines 76 to 80
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find yup utility files
find src -type f \( -name '*yup*' -o -name '*validation*' \) | head -20

Repository: fntechgit/summit-admin

Length of output: 82


🏁 Script executed:

cat -n src/utils/yup.js

Repository: 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 -200

Repository: 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.

</Grid2>
<Grid2 size={12}>
Expand All @@ -94,6 +95,7 @@ const SponsorFormItemForm = ({ initialValues, onSubmit }) => {
"sponsor_form_item_list.edit_item.early_bird_rate"
)}
fullWidth
required
/>
</Grid2>
<Grid2 size={4}>
Expand All @@ -103,6 +105,7 @@ const SponsorFormItemForm = ({ initialValues, onSubmit }) => {
"sponsor_form_item_list.edit_item.standard_rate"
)}
fullWidth
required
/>
</Grid2>
<Grid2 size={4}>
Expand All @@ -112,6 +115,7 @@ const SponsorFormItemForm = ({ initialValues, onSubmit }) => {
"sponsor_form_item_list.edit_item.onsite_rate"
)}
fullWidth
required
/>
</Grid2>
<Grid2 size={4}>
Expand Down Expand Up @@ -145,6 +149,7 @@ const SponsorFormItemForm = ({ initialValues, onSubmit }) => {
fullWidth
type="number"
inputProps={{ min: 0 }}
required
/>
</Grid2>
</Grid2>
Expand Down