mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +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:
|
||||
row.type !== 'checkbox'
|
||||
? row.type === 'date' && row.default
|
||||
? new Date(row.default)
|
||||
? row.type === 'date'
|
||||
? // 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.checked,
|
||||
} || { value: null }
|
||||
|
||||
@@ -13,7 +13,7 @@ const DateField: React.FC<Props> = (props) => {
|
||||
const controller = useController({
|
||||
name: `test.${props.index}.value`,
|
||||
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 },
|
||||
});
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ export interface IColorInput {
|
||||
export interface IDateInput {
|
||||
type: 'date';
|
||||
label: string;
|
||||
default?: string;
|
||||
default?: string | true;
|
||||
disabled?: boolean;
|
||||
description?: string;
|
||||
required?: boolean;
|
||||
|
||||
Reference in New Issue
Block a user