hasError prop was added

This commit is contained in:
Vladimir Khvan 2023-05-01 13:17:16 +05:00
parent 49edd01154
commit b0def70285

View File

@ -18,6 +18,8 @@ const TimeInput = styled.div`
display: flex;
border-color: ${(props) => (props.hasError ? "#f21c0e" : "#d0d5da")};
:focus {
border-color: #4781d1;
}
@ -31,7 +33,7 @@ const TimeInput = styled.div`
}
`;
export const TimePicker = ({ date, setDate, onChange, className }) => {
export const TimePicker = ({ date, setDate, onChange, className, hasError }) => {
const hoursInputRef = useRef(null);
const minutesInputRef = useRef(null);
const timeInputRef = useRef(null);
@ -117,7 +119,11 @@ export const TimePicker = ({ date, setDate, onChange, className }) => {
};
return (
<TimeInput ref={timeInputRef} onClick={focusHoursInput} className={className}>
<TimeInput
ref={timeInputRef}
onClick={focusHoursInput}
className={className}
hasError={hasError}>
<TextInput
withBorder={false}
forwardedRef={hoursInputRef}
@ -145,6 +151,7 @@ TimePicker.propTypes = {
/** Allow you to handle changing events of component */
onChange: PropTypes.func,
hasError: PropTypes.bool,
};
TimePicker.defaultProps = {
@ -152,4 +159,5 @@ TimePicker.defaultProps = {
setDate: () => {},
onChange: () => {},
className: "",
hasError: false,
};