sccoreui 3.9.6 → 3.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -18,52 +18,65 @@ const DatePicker = (props) => {
|
|
|
18
18
|
const [fromDateFormate, setFromDateFormate] = (0, react_1.useState)(formattedDate);
|
|
19
19
|
const [toDateFormate, setToDateFormate] = (0, react_1.useState)('-');
|
|
20
20
|
const [propsState, setPropsState] = (0, react_1.useState)({});
|
|
21
|
+
// const defaultDate = new Date(2023, 0, 1);
|
|
21
22
|
let dateFromTo = [];
|
|
22
23
|
const selecteDateOption = (dateType) => {
|
|
23
|
-
dateFromTo.push(today);
|
|
24
24
|
switch (dateType) {
|
|
25
25
|
case 'Today':
|
|
26
|
+
dateFromTo.push(today);
|
|
26
27
|
// Default date
|
|
27
28
|
break;
|
|
28
29
|
case 'Yesterday':
|
|
30
|
+
dateFromTo.push(today);
|
|
29
31
|
const yesterdayFromToday = new Date(today);
|
|
30
32
|
yesterdayFromToday.setDate(today.getDate() - 1);
|
|
31
33
|
dateFromTo.unshift(yesterdayFromToday);
|
|
32
34
|
break;
|
|
33
35
|
case 'This week': {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
const startWeek = new Date(today);
|
|
37
|
+
const endWeek = new Date(today);
|
|
38
|
+
startWeek.setDate(today.getDate() - today.getDay());
|
|
39
|
+
endWeek.setDate(today.getDate() + (6 - today.getDay()));
|
|
40
|
+
dateFromTo.push(startWeek);
|
|
41
|
+
dateFromTo.push(endWeek);
|
|
37
42
|
break;
|
|
38
43
|
}
|
|
39
44
|
case 'Last week': {
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
const startWeek = new Date(today);
|
|
46
|
+
const endWeek = new Date(today);
|
|
47
|
+
startWeek.setDate(today.getDate() - today.getDay() - 7);
|
|
48
|
+
endWeek.setDate(today.getDate() - today.getDay() - 1);
|
|
49
|
+
dateFromTo.push(startWeek);
|
|
50
|
+
dateFromTo.push(endWeek);
|
|
43
51
|
break;
|
|
44
52
|
}
|
|
45
53
|
case 'This month':
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
dateFromTo.push(
|
|
54
|
+
const startMonth = new Date(today.getFullYear(), today.getMonth(), 1);
|
|
55
|
+
const endMonth = new Date(today.getFullYear(), today.getMonth() + 1, 0);
|
|
56
|
+
dateFromTo.push(startMonth);
|
|
57
|
+
dateFromTo.push(endMonth);
|
|
49
58
|
break;
|
|
50
59
|
case 'Last month':
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
dateFromTo.
|
|
60
|
+
const startLastMonth = new Date(today.getFullYear(), today.getMonth() - 1, 1);
|
|
61
|
+
const endLastMonth = new Date(today.getFullYear(), today.getMonth(), 0);
|
|
62
|
+
dateFromTo.push(startLastMonth);
|
|
63
|
+
dateFromTo.push(endLastMonth);
|
|
54
64
|
break;
|
|
55
65
|
case 'This year':
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
dateFromTo.push(
|
|
66
|
+
const startOfYear = new Date(today.getFullYear(), 0, 1); // January 1st of the current year
|
|
67
|
+
const endOfYear = new Date(today.getFullYear(), 11, 31); // December 31st of the current year
|
|
68
|
+
dateFromTo.push(startOfYear);
|
|
69
|
+
dateFromTo.push(endOfYear);
|
|
59
70
|
break;
|
|
60
71
|
case 'Last year':
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
dateFromTo.
|
|
72
|
+
const startOfLastYear = new Date(today.getFullYear() - 1, 0, 1); // January 1st of the last year
|
|
73
|
+
const endOfLastYear = new Date(today.getFullYear() - 1, 11, 31); // December 31st of the last year
|
|
74
|
+
dateFromTo.push(startOfLastYear);
|
|
75
|
+
dateFromTo.push(endOfLastYear);
|
|
64
76
|
break;
|
|
65
77
|
case 'Custom':
|
|
66
78
|
// Default date
|
|
79
|
+
dateFromTo.push(today);
|
|
67
80
|
break;
|
|
68
81
|
}
|
|
69
82
|
setFromDate(dateFromTo);
|
|
@@ -4,6 +4,6 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
4
4
|
const formik_1 = require("formik");
|
|
5
5
|
const FormComponent = (props) => {
|
|
6
6
|
const { values, validations, children, validateOnChange, validateOnBlur, className, onSubmit } = props;
|
|
7
|
-
return ((0, jsx_runtime_1.jsx)(formik_1.Formik, Object.assign({ initialValues: values, validationSchema: validations, validateOnChange: validateOnChange, validateOnBlur: validateOnBlur, onSubmit: (values) => onSubmit(values) }, { children: ({ errors, touched, isValid, values, actions, resetForm, setFieldValue, handleSubmit, setFieldTouched }) => ((0, jsx_runtime_1.jsx)(formik_1.Form, Object.assign({ className: className }, { children: children({ errors, touched, isValid, values, actions, resetForm, handleSubmit, setFieldValue, setFieldTouched }) }))) })));
|
|
7
|
+
return ((0, jsx_runtime_1.jsx)(formik_1.Formik, Object.assign({ initialValues: values, validationSchema: validations, validateOnChange: validateOnChange, validateOnBlur: validateOnBlur, onSubmit: (values) => onSubmit(values) }, { children: ({ errors, touched, isValid, values, actions, resetForm, setFieldValue, handleSubmit, setFieldTouched, dirty }) => ((0, jsx_runtime_1.jsx)(formik_1.Form, Object.assign({ className: className }, { children: children({ errors, touched, isValid, values, actions, resetForm, handleSubmit, setFieldValue, setFieldTouched, dirty }) }))) })));
|
|
8
8
|
};
|
|
9
9
|
exports.default = FormComponent;
|