mirror of
https://github.com/strapi/strapi.git
synced 2025-12-29 08:04:51 +00:00
Fix timestamps field
Signed-off-by: soupette <cyril@strapi.io>
This commit is contained in:
parent
86e9995c26
commit
9266b629d8
@ -1,72 +0,0 @@
|
||||
/**
|
||||
*
|
||||
* CominSoonInput
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { TextInput } from '@strapi/design-system/TextInput';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
const CominSoonInput = ({ description, intlLabel, labelAction, error, name, required }) => {
|
||||
const { formatMessage } = useIntl();
|
||||
const label = intlLabel.id
|
||||
? formatMessage(
|
||||
{ id: intlLabel.id, defaultMessage: intlLabel.defaultMessage },
|
||||
{ ...intlLabel.values }
|
||||
)
|
||||
: name;
|
||||
|
||||
const hint = description?.id
|
||||
? formatMessage(
|
||||
{ id: description.id, defaultMessage: description.defaultMessage },
|
||||
{ ...description.values }
|
||||
)
|
||||
: '';
|
||||
|
||||
const errorMessage = error ? formatMessage({ id: error, defaultMessage: error }) : '';
|
||||
|
||||
return (
|
||||
<TextInput
|
||||
disabled
|
||||
error={errorMessage}
|
||||
label={label}
|
||||
labelAction={labelAction}
|
||||
id={name}
|
||||
hint={hint}
|
||||
name={name}
|
||||
onChange={() => {}}
|
||||
placeholder="Coming soon"
|
||||
required={required}
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
CominSoonInput.defaultProps = {
|
||||
description: null,
|
||||
error: '',
|
||||
labelAction: undefined,
|
||||
required: false,
|
||||
};
|
||||
|
||||
CominSoonInput.propTypes = {
|
||||
description: PropTypes.shape({
|
||||
id: PropTypes.string.isRequired,
|
||||
defaultMessage: PropTypes.string.isRequired,
|
||||
values: PropTypes.object,
|
||||
}),
|
||||
error: PropTypes.string,
|
||||
intlLabel: PropTypes.shape({
|
||||
id: PropTypes.string.isRequired,
|
||||
defaultMessage: PropTypes.string.isRequired,
|
||||
values: PropTypes.object,
|
||||
}).isRequired,
|
||||
labelAction: PropTypes.element,
|
||||
name: PropTypes.string.isRequired,
|
||||
required: PropTypes.bool,
|
||||
};
|
||||
|
||||
export default CominSoonInput;
|
||||
@ -0,0 +1,46 @@
|
||||
/**
|
||||
*
|
||||
* NotSupported
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { TextInput } from '@strapi/design-system/TextInput';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
const NotSupported = ({ hint, label, labelAction, error, name, required }) => {
|
||||
return (
|
||||
<TextInput
|
||||
disabled
|
||||
error={error}
|
||||
label={label}
|
||||
labelAction={labelAction}
|
||||
id={name}
|
||||
hint={hint}
|
||||
name={name}
|
||||
onChange={() => {}}
|
||||
placeholder="Not supported"
|
||||
required={required}
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
NotSupported.defaultProps = {
|
||||
hint: null,
|
||||
error: undefined,
|
||||
labelAction: undefined,
|
||||
required: false,
|
||||
};
|
||||
|
||||
NotSupported.propTypes = {
|
||||
error: PropTypes.string,
|
||||
hint: PropTypes.string,
|
||||
label: PropTypes.string.isRequired,
|
||||
labelAction: PropTypes.element,
|
||||
name: PropTypes.string.isRequired,
|
||||
required: PropTypes.bool,
|
||||
};
|
||||
|
||||
export default NotSupported;
|
||||
@ -19,6 +19,7 @@ import { Icon } from '@strapi/design-system/Icon';
|
||||
import EyeStriked from '@strapi/icons/EyeStriked';
|
||||
import Eye from '@strapi/icons/Eye';
|
||||
import DateTimePicker from '../DateTimePicker';
|
||||
import NotSupported from './NotSupported';
|
||||
|
||||
const GenericInput = ({
|
||||
autoComplete,
|
||||
@ -197,7 +198,26 @@ const GenericInput = ({
|
||||
/>
|
||||
);
|
||||
}
|
||||
case 'email':
|
||||
case 'email': {
|
||||
return (
|
||||
<TextInput
|
||||
autoComplete={autoComplete}
|
||||
disabled={disabled}
|
||||
error={errorMessage}
|
||||
label={label}
|
||||
labelAction={labelAction}
|
||||
id={name}
|
||||
hint={hint}
|
||||
name={name}
|
||||
onChange={onChange}
|
||||
placeholder={formattedPlaceholder}
|
||||
required={required}
|
||||
type="email"
|
||||
value={value || ''}
|
||||
/>
|
||||
);
|
||||
}
|
||||
case 'timestamp':
|
||||
case 'text':
|
||||
case 'string': {
|
||||
return (
|
||||
@ -213,7 +233,7 @@ const GenericInput = ({
|
||||
onChange={onChange}
|
||||
placeholder={formattedPlaceholder}
|
||||
required={required}
|
||||
type={type}
|
||||
type="text"
|
||||
value={value || ''}
|
||||
/>
|
||||
);
|
||||
@ -343,9 +363,14 @@ const GenericInput = ({
|
||||
}
|
||||
default: {
|
||||
return (
|
||||
<div>
|
||||
{type} is not supported for {name}
|
||||
</div>
|
||||
<NotSupported
|
||||
name={name}
|
||||
label={label}
|
||||
labelAction={labelAction}
|
||||
hint={hint}
|
||||
error={errorMessage}
|
||||
required={required}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user