diff --git a/src/Components/Ui/StaticsCard/StaticCard.tsx b/src/Components/Ui/StaticsCard/StaticCard.tsx index 03ebdef..bd5fddc 100644 --- a/src/Components/Ui/StaticsCard/StaticCard.tsx +++ b/src/Components/Ui/StaticsCard/StaticCard.tsx @@ -32,7 +32,7 @@ const StatisticsCard = (props :StatisticsCardProps) => { } = props; return ( - navigate(pathWhenClick , {replace:true})}> + navigate(pathWhenClick )}> { +const DateField = ({ name, label, picker = "date", isDisabled, props, onChange, placeholder, className, Format }: any) => { + + const { errorMsg, isError, t, formik } = useFormField(name, props); - const { errorMsg, isError, t, formik } = useFormField(name, props) const onCalendarChange = (value: any) => { - console.log(value,"value"); - formik.setFieldValue(name, value) - + formik.setFieldValue(name, value); }; - return ( + // Function to check if a date is valid + const isValidDate = (date: any) => { + return date && !isNaN(date.valueOf()) && dayjs(date).isValid(); + }; + + // Set a default invalid date if the provided defaultValue is invalid + const getDefaultDate = () => { + const defaultValue = formik.values[name]; + return isValidDate(defaultValue) ? defaultValue : null; // Set to null or any other default invalid date + }; + + return (
- - - - +
- ) + ); } -export default Date \ No newline at end of file +export default DateField; diff --git a/src/Hooks/useNavigateOnSuccess.ts b/src/Hooks/useNavigateOnSuccess.ts index 9196d86..2b012c3 100644 --- a/src/Hooks/useNavigateOnSuccess.ts +++ b/src/Hooks/useNavigateOnSuccess.ts @@ -11,7 +11,7 @@ function useNavigateOnSuccess(isSuccess :boolean , to_path:string , callbackAfte if (typeof callbackAfterSuccess === 'function') { callbackAfterSuccess() } - navigate(to_path , {replace:true}) + navigate(to_path ) } },[isSuccess]) diff --git a/src/Layout/Dashboard/SelectField.tsx b/src/Layout/Dashboard/SelectField.tsx index 65df8cb..0136367 100644 --- a/src/Layout/Dashboard/SelectField.tsx +++ b/src/Layout/Dashboard/SelectField.tsx @@ -3,50 +3,37 @@ import React, { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useLocation, useNavigate } from 'react-router-dom'; -const SelectField = ({ selectBy, submiteBy, lebel, option }: any) => { - const [searchQuery, setSearchQuery] = useState(''); - const location = useLocation(); - const navigate = useNavigate(); - const [t] = useTranslation(); +const SelectField = ({ selectBy, lebel, option }: any) => { + const [searchQuery, setSearchQuery] = useState(''); + const location = useLocation(); + const navigate = useNavigate(); + const [t] = useTranslation(); - useEffect(() => { - const searchParams = new URLSearchParams(location.search); - setSearchQuery(searchParams.get('search') || ''); - }, []); + useEffect(() => { + const searchParams = new URLSearchParams(location.search); + setSearchQuery(searchParams.get('search') || ''); + }, []); - const handleSearchChange = (value: any) => { - if (value || value !== "") { - navigate(`${location.pathname}?${selectBy}=${value}`, { replace: true }); - } else { - const params = new URLSearchParams(location.search); - params.delete(selectBy ?? "search"); - navigate(`${location.pathname}?${params.toString()}`, { replace: true }); + + const handleSelectChange = (value: any) => { + if (value) { + console.log(`${location.pathname}?${selectBy}=${value}`); + navigate(`${location.pathname}?${selectBy}=${value}`, { replace: true }); + } } - }; - const handleSelectChange = (value: any) => { - if (value) { - console.log(`${location.pathname}?${submiteBy}=${value}`); - - navigate(`${location.pathname}?${submiteBy}=${value}`, { replace: true }); - } -} - - return ( -
- +
+ ); }; export default React.memo(SelectField); diff --git a/src/Layout/Dashboard/SelectWSearchField.tsx b/src/Layout/Dashboard/SelectWSearchField.tsx new file mode 100644 index 0000000..702870d --- /dev/null +++ b/src/Layout/Dashboard/SelectWSearchField.tsx @@ -0,0 +1,52 @@ +import { Select } from 'antd'; +import React, { useEffect, useState } from 'react'; +import { useTranslation } from 'react-i18next'; +import { useLocation, useNavigate } from 'react-router-dom'; + +const SelectWSearchField = ({ selectBy, submiteBy, lebel, option }: any) => { + const [searchQuery, setSearchQuery] = useState(''); + const location = useLocation(); + const navigate = useNavigate(); + const [t] = useTranslation(); + + useEffect(() => { + const searchParams = new URLSearchParams(location.search); + setSearchQuery(searchParams.get('search') || ''); + }, []); + + const handleSearchChange = (value: any) => { + if (value || value !== "") { + navigate(`${location.pathname}?${selectBy}=${value}`, { replace: true }); + } else { + const params = new URLSearchParams(location.search); + params.delete(selectBy ?? "search"); + navigate(`${location.pathname}?${params.toString()}`, { replace: true }); + } + }; + + const handleSelectChange = (value: any) => { + if (value) { + console.log(`${location.pathname}?${submiteBy}=${value}`); + + navigate(`${location.pathname}?${submiteBy}=${value}`, { replace: true }); + } +} + + return ( +
+