diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ee5498ba3..7d5637d04 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,7 +25,7 @@ repos: language: system types: [text] stages: [commit, push, manual] - - id: ruff + - id: ruff-check args: [check, --fix] files: ^spiffworkflow-backend/ name: ruff @@ -36,7 +36,7 @@ repos: # this is also specified in spiffworkflow-backend/pyproject.toml but we run pre-commit # with all-files which ignores that exclude: "/migrations/" - - id: ruff + - id: ruff-format args: [format] files: ^spiffworkflow-backend/ name: ruff diff --git a/spiffworkflow-frontend/src/config.tsx b/spiffworkflow-frontend/src/config.tsx index dd0c9c229..0833d0559 100644 --- a/spiffworkflow-frontend/src/config.tsx +++ b/spiffworkflow-frontend/src/config.tsx @@ -98,7 +98,7 @@ const supportedDateFormatTypes = { dd: '01', }; const unsupportedFormatTypes = splitDateFormat.filter( - (x) => !Object.keys(supportedDateFormatTypes).includes(x) + (x) => !Object.keys(supportedDateFormatTypes).includes(x), ); const formattedSupportedDateTypes: string[] = []; Object.entries(supportedDateFormatTypes).forEach(([key, value]) => { @@ -107,8 +107,8 @@ Object.entries(supportedDateFormatTypes).forEach(([key, value]) => { if (unsupportedFormatTypes.length > 0) { throw new Error( `Given SPIFFWORKFLOW_FRONTEND_RUNTIME_CONFIG_DATE_FORMAT is not supported. Given: ${generalDateFormat} with invalid options: ${unsupportedFormatTypes.join( - ', ' - )}. Valid options are: ${formattedSupportedDateTypes.join(', ')}` + ', ', + )}. Valid options are: ${formattedSupportedDateTypes.join(', ')}`, ); } const carbonDateFormat = generalDateFormat diff --git a/spiffworkflow-frontend/src/rjsf/custom_widgets/DateRangePicker/DateRangePickerWidget.tsx b/spiffworkflow-frontend/src/rjsf/custom_widgets/DateRangePicker/DateRangePickerWidget.tsx index abf3c52df..ad401c7dc 100644 --- a/spiffworkflow-frontend/src/rjsf/custom_widgets/DateRangePicker/DateRangePickerWidget.tsx +++ b/spiffworkflow-frontend/src/rjsf/custom_widgets/DateRangePicker/DateRangePickerWidget.tsx @@ -7,6 +7,7 @@ import { } from '../../../config'; import { getCommonAttributes } from '../../helpers'; import DateAndTimeService from '../../../services/DateAndTimeService'; +import { useDebouncedCallback } from 'use-debounce'; interface widgetArgs { id: string; @@ -42,20 +43,20 @@ export default function DateRangePickerWidget({ label, schema, uiSchema, - rawErrors + rawErrors, ); const onChangeLocal = useCallback( (dateRange: Date[]) => { let dateRangeString; const startDate = DateAndTimeService.convertDateObjectToFormattedString( - dateRange[0] + dateRange[0], ); if (startDate) { const startDateYMD = DateAndTimeService.dateStringToYMDFormat(startDate); const endDate = DateAndTimeService.convertDateObjectToFormattedString( - dateRange[1] + dateRange[1], ); dateRangeString = startDateYMD; if (endDate) { @@ -65,7 +66,7 @@ export default function DateRangePickerWidget({ } onChange(dateRangeString); }, - [onChange] + [onChange], ); let dateValue: (Date | null)[] | null = value; @@ -85,6 +86,17 @@ export default function DateRangePickerWidget({ dateValue = [startDate, endDate]; } + const addDebouncedOnChangeDate = useDebouncedCallback( + (fullObject: React.ChangeEvent) => { + fullObject.target.value = + DateAndTimeService.attemptToConvertUnknownDateStringFormatToKnownFormat( + fullObject.target.value, + ); + }, + // delay in ms + 100, + ); + return ( );