From aa91c9ff86ea274ebc9dda4c2760450b621b9411 Mon Sep 17 00:00:00 2001 From: mohadeseh safari Date: Thu, 29 May 2025 21:01:09 -0400 Subject: [PATCH] Resolve Settings page Select component errors - Enhanced Select component to accept boolean values in PropTypes - Updated component documentation to reflect new type support - Added default value for showURL prop to prevent undefined value errors - Fixed two related issues: 1. Type mismatch error when passing boolean values 2. Required prop error during initial rendering --- client/src/Components/Inputs/Select/index.jsx | 8 ++++---- client/src/Pages/Settings/SettingsURL.jsx | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/src/Components/Inputs/Select/index.jsx b/client/src/Components/Inputs/Select/index.jsx index 927247d77..4eae2b057 100644 --- a/client/src/Components/Inputs/Select/index.jsx +++ b/client/src/Components/Inputs/Select/index.jsx @@ -12,9 +12,9 @@ import "./index.css"; * @param {string} props.placeholder - The label of the select element. * @param {string} props.placeholder - The placeholder text when no option is selected. * @param {boolean} props.isHidden - Whether the placeholder should be hidden. - * @param {string} props.value - The currently selected value. + * @param {(string | number | boolean)} props.value - The currently selected value. * @param {object[]} props.items - The array of items to populate in the select dropdown. - * @param {(string | number)} props.items._id - The unique identifier of each item. + * @param {(string | number | boolean)} props.items._id - The unique identifier of each item. * @param {string} props.items.name - The display name of each item. * @param {function} props.onChange - The function to handle onChange event. * @param {object} props.sx - The custom styles object for MUI Select component. @@ -161,10 +161,10 @@ Select.propTypes = { label: PropTypes.string, placeholder: PropTypes.string, isHidden: PropTypes.bool, - value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, + value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]).isRequired, items: PropTypes.arrayOf( PropTypes.shape({ - _id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, + _id: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]).isRequired, name: PropTypes.string.isRequired, }) ).isRequired, diff --git a/client/src/Pages/Settings/SettingsURL.jsx b/client/src/Pages/Settings/SettingsURL.jsx index 64804c903..168f223fe 100644 --- a/client/src/Pages/Settings/SettingsURL.jsx +++ b/client/src/Pages/Settings/SettingsURL.jsx @@ -9,7 +9,7 @@ import { useTheme } from "@emotion/react"; import { PropTypes } from "prop-types"; import { useTranslation } from "react-i18next"; -const SettingsURL = ({ HEADING_SX, handleChange, showURL }) => { +const SettingsURL = ({ HEADING_SX, handleChange, showURL = false }) => { const { t } = useTranslation(); const theme = useTheme(); return (