From 469ab0f3b33a86b090034932abaad23483886121 Mon Sep 17 00:00:00 2001 From: KarimAldeen Date: Thu, 28 Mar 2024 14:44:49 +0300 Subject: [PATCH] #33 --- src/Components/Ui/StaticsCard/StaticCard.tsx | 2 +- src/Components/ValidationField/View/Date.tsx | 57 ++++++------ src/Hooks/useNavigateOnSuccess.ts | 2 +- src/Layout/Dashboard/SelectField.tsx | 67 ++++++-------- src/Layout/Dashboard/SelectWSearchField.tsx | 52 +++++++++++ src/Layout/Dashboard/ViewPage.tsx | 20 ++++- src/Layout/app/NotFoundPage.tsx | 2 +- src/Pages/Products/ProductsPage.tsx | 2 +- src/Pages/Users/Page.tsx | 38 ++++---- src/Pages/Users/ui/AddButtonNotification.tsx | 27 ++++++ src/Pages/order/Edit/EditForm.tsx | 5 +- src/Pages/order/Edit/formUtil.ts | 16 ---- src/Pages/order/{Edit => }/EditPage.tsx | 31 +++++-- src/Pages/order/OrderPage.tsx | 45 ++++++---- src/Pages/order/Products/ProductsPage.tsx | 44 +++++++++ src/Pages/order/Products/useTableColumns.tsx | 49 ++++++++++ src/Pages/order/Select.js | 51 ----------- src/Pages/order/View/ViewForm.tsx | 50 +++++++++++ src/Pages/order/form/formUtils.js | 61 ------------- src/Pages/order/ui/CustomDateRange.tsx | 27 ++++++ src/Pages/order/useTableColumns.tsx | 9 +- src/Pages/order/view-one/Order.js | 90 ------------------- src/Pages/order/view-one/OrderForm.js | 39 -------- .../order/view-one/OrderForm.module.scss | 36 -------- src/Pages/order/view-one/OrderStatus.js | 31 ------- .../order/view-one/StatusOrderController.js | 80 ----------------- src/Pages/order/view-one/index.css | 20 ----- src/Pages/order/view-one/useTableColumns.js | 59 ------------ src/Routes.tsx | 11 +-- src/Styles/AppStyle/Import.scss | 1 + src/Styles/Layout/FillterSection.scss | 18 ++++ src/Styles/Layout/Layout.scss | 10 ++- src/api/order.ts | 2 +- src/translate/text | 4 +- 34 files changed, 438 insertions(+), 620 deletions(-) create mode 100644 src/Layout/Dashboard/SelectWSearchField.tsx create mode 100644 src/Pages/Users/ui/AddButtonNotification.tsx rename src/Pages/order/{Edit => }/EditPage.tsx (63%) create mode 100644 src/Pages/order/Products/ProductsPage.tsx create mode 100644 src/Pages/order/Products/useTableColumns.tsx delete mode 100644 src/Pages/order/Select.js create mode 100644 src/Pages/order/View/ViewForm.tsx delete mode 100644 src/Pages/order/form/formUtils.js create mode 100644 src/Pages/order/ui/CustomDateRange.tsx delete mode 100644 src/Pages/order/view-one/Order.js delete mode 100644 src/Pages/order/view-one/OrderForm.js delete mode 100644 src/Pages/order/view-one/OrderForm.module.scss delete mode 100644 src/Pages/order/view-one/OrderStatus.js delete mode 100644 src/Pages/order/view-one/StatusOrderController.js delete mode 100644 src/Pages/order/view-one/index.css delete mode 100644 src/Pages/order/view-one/useTableColumns.js create mode 100644 src/Styles/Layout/FillterSection.scss 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 ( +
+