mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-19 07:56:02 +01:00
refactor(web/input): set date to current if default is set to true
This commit is contained in:
@@ -59,8 +59,11 @@ const InputDialog: React.FC = () => {
|
|||||||
{
|
{
|
||||||
value:
|
value:
|
||||||
row.type !== 'checkbox'
|
row.type !== 'checkbox'
|
||||||
? row.type === 'date' && row.default
|
? row.type === 'date'
|
||||||
? new Date(row.default)
|
? // Set date to current one if default is set to true
|
||||||
|
row.default === true
|
||||||
|
? new Date()
|
||||||
|
: row.default && new Date(row.default)
|
||||||
: row.default
|
: row.default
|
||||||
: row.checked,
|
: row.checked,
|
||||||
} || { value: null }
|
} || { value: null }
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const DateField: React.FC<Props> = (props) => {
|
|||||||
const controller = useController({
|
const controller = useController({
|
||||||
name: `test.${props.index}.value`,
|
name: `test.${props.index}.value`,
|
||||||
control: props.control,
|
control: props.control,
|
||||||
defaultValue: props.row.default && new Date(props.row.default),
|
defaultValue: props.row.default === true ? new Date() : props.row.default ? new Date(props.row.default) : undefined,
|
||||||
rules: { required: props.row.required },
|
rules: { required: props.row.required },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export interface IColorInput {
|
|||||||
export interface IDateInput {
|
export interface IDateInput {
|
||||||
type: 'date';
|
type: 'date';
|
||||||
label: string;
|
label: string;
|
||||||
default?: string;
|
default?: string | true;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
description?: string;
|
description?: string;
|
||||||
required?: boolean;
|
required?: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user