From 57cfdb542e73e7ceb83b1bd2ae73fe6715cfacad Mon Sep 17 00:00:00 2001 From: Abdullah Waheed Date: Wed, 3 Aug 2022 17:50:15 +0500 Subject: [PATCH 1/4] refactor: removed InputText deprecation form DateTimeField --- .gitignore | 1 + src/components/DateTimeField/index.jsx | 61 ++++++++++++++------------ 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index 1b6f8502b..a7978280f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ module.config.js dist/ .idea +.vscode \ No newline at end of file diff --git a/src/components/DateTimeField/index.jsx b/src/components/DateTimeField/index.jsx index 7f3c8f9f7..217adb995 100644 --- a/src/components/DateTimeField/index.jsx +++ b/src/components/DateTimeField/index.jsx @@ -1,7 +1,7 @@ import React from 'react'; import moment from 'moment'; import PropTypes from 'prop-types'; -import { InputText } from '@edx/paragon'; +import { Form } from '@edx/paragon'; import { getDateWithDashes, getDateWithSlashes, @@ -84,45 +84,50 @@ class DateTimeField extends React.Component { return (
- + - )} - placeholder={placeholder} - pattern={pattern} - maxLength={maxLength} - required={required} - disabled={disabled} - onChange={e => this.updateDate(e)} - min={minDate} - onInvalid={onInvalid} - /> + + this.updateDate(event.target.value)} + min={minDate} + onInvalid={onInvalid} + /> +
- + - )} - placeholder="HH:mm" - required={required} - disabled={disabled} - onChange={e => this.updateTime(e)} - /> + + this.updateDate(event.target.value)} + /> +
); @@ -157,7 +162,7 @@ DateTimeField.defaultProps = { utcTimeZone: false, maxLength: '', type: '', - pattern: '', + pattern: 'dd/mm/yyyy', placeholder: '', }; From ba768fe314270ccf8b581124907f04db5fffb346 Mon Sep 17 00:00:00 2001 From: Abdullah Waheed Date: Wed, 3 Aug 2022 17:58:33 +0500 Subject: [PATCH 2/4] refactor: removed InputText deprecation form RenderInputTextField --- src/components/RenderInputTextField/index.jsx | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/components/RenderInputTextField/index.jsx b/src/components/RenderInputTextField/index.jsx index cea91bf8f..d5aa0945e 100644 --- a/src/components/RenderInputTextField/index.jsx +++ b/src/components/RenderInputTextField/index.jsx @@ -1,6 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { InputText } from '@edx/paragon'; +import { Form } from '@edx/paragon'; const RenderInputTextField = ({ input, @@ -15,21 +15,28 @@ const RenderInputTextField = ({ pattern, meta: { touched, error }, }) => ( - + + + {label} + + + {!(touched && error) && ( + + {error} + + )} + ); RenderInputTextField.defaultProps = { From 28a95b17a152b9358b94f04963e29bc0aa7be5dc Mon Sep 17 00:00:00 2001 From: Abdullah Waheed Date: Wed, 3 Aug 2022 18:05:34 +0500 Subject: [PATCH 3/4] refactor: removed InputSelect deprecation form RenderInputTextField --- src/components/RenderInputTextField/index.jsx | 4 +- src/components/RenderSelectField/index.jsx | 37 ++++++++++++------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/components/RenderInputTextField/index.jsx b/src/components/RenderInputTextField/index.jsx index d5aa0945e..4b4c03f63 100644 --- a/src/components/RenderInputTextField/index.jsx +++ b/src/components/RenderInputTextField/index.jsx @@ -15,7 +15,7 @@ const RenderInputTextField = ({ pattern, meta: { touched, error }, }) => ( - + {label} @@ -31,7 +31,7 @@ const RenderInputTextField = ({ disabled={disabled} required={required} /> - {!(touched && error) && ( + {touched && error && ( {error} diff --git a/src/components/RenderSelectField/index.jsx b/src/components/RenderSelectField/index.jsx index cc8b8d49a..555f50f88 100644 --- a/src/components/RenderSelectField/index.jsx +++ b/src/components/RenderSelectField/index.jsx @@ -1,6 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { InputSelect } from '@edx/paragon'; +import { Form } from '@edx/paragon'; const RenderSelectField = ({ input, @@ -12,18 +12,29 @@ const RenderSelectField = ({ meta: { touched, error }, options, }) => ( - + + + {label} + + + {options.map(option => ( + + ))} + {touched && error && ( + + {error} + + )} + + ); RenderSelectField.defaultProps = { From ce2f4da873249b49e1dfe01ac488b74203524819 Mon Sep 17 00:00:00 2001 From: Abdullah Waheed Date: Thu, 4 Aug 2022 12:21:21 +0500 Subject: [PATCH 4/4] fix: fixed unit tests --- .../RenderInputTextField.test.jsx.snap | 100 ++++++++++-------- .../RenderSelectField.test.jsx.snap | 53 +++++----- 2 files changed, 81 insertions(+), 72 deletions(-) diff --git a/src/components/RenderInputTextField/__snapshots__/RenderInputTextField.test.jsx.snap b/src/components/RenderInputTextField/__snapshots__/RenderInputTextField.test.jsx.snap index e789ccedc..5a877c0de 100644 --- a/src/components/RenderInputTextField/__snapshots__/RenderInputTextField.test.jsx.snap +++ b/src/components/RenderInputTextField/__snapshots__/RenderInputTextField.test.jsx.snap @@ -1,53 +1,61 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`RenderInputTextField renders html for number type 1`] = ` - +
+ + + TestLabel + + + +
`; exports[`RenderInputTextField renders html for text 1`] = ` - +
+ + + TestLabel + + + +
`; diff --git a/src/components/RenderSelectField/__snapshots__/RenderSelectField.test.jsx.snap b/src/components/RenderSelectField/__snapshots__/RenderSelectField.test.jsx.snap index acb4ff126..7a6ea5448 100644 --- a/src/components/RenderSelectField/__snapshots__/RenderSelectField.test.jsx.snap +++ b/src/components/RenderSelectField/__snapshots__/RenderSelectField.test.jsx.snap @@ -1,30 +1,31 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`RenderSelectField renders html for select field 1`] = ` - +
+ + + TestLabel + + + + +
`;