Skip to content

Commit

Permalink
fix: set default date to midnight (#1254)
Browse files Browse the repository at this point in the history
* fix: set default date value to midnight

On both the datefield component default value as well as the reset() default value

* build(dev-deps): upgrade sqlite3
  • Loading branch information
prestonlimlianjie committed Feb 17, 2022
1 parent 18bda50 commit 23f0ebf
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 44 deletions.
88 changes: 47 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"lint-staged": "^11.2.6",
"prettier": "^2.4.1",
"sequelize-cli": "^6.2.0",
"sqlite3": "^5.0.1",
"sqlite3": "^5.0.2",
"supertest": "^6.1.6",
"ts-jest": "^27.0.7",
"ts-loader": "^9.2.6",
Expand Down
5 changes: 4 additions & 1 deletion src/client/components/Checker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ export const Checker: FC<CheckerProps> = ({ config }) => {
methods.setValue(field.id, 0)
break
case 'DATE':
methods.setValue(field.id, new Date())
methods.setValue(
field.id,
new Date(new Date().setHours(0, 0, 0, 0))
)
break
case 'RADIO':
methods.setValue(field.id, '')
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/fields/DateField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const DateField: FC<Field> = ({ id, title, description }) => {
<Controller
name={id}
control={control}
defaultValue={new Date()}
defaultValue={new Date(new Date().setHours(0, 0, 0, 0))}
rules={{ required: true }}
render={({
field: { onChange, value, ref },
Expand Down

0 comments on commit 23f0ebf

Please sign in to comment.