Skip to content

Commit

Permalink
chore: resolve merge conflict from master
Browse files Browse the repository at this point in the history
  • Loading branch information
Chisomchima committed Nov 28, 2024
2 parents 66da56f + 93c2d51 commit 5ec5c43
Show file tree
Hide file tree
Showing 7 changed files with 464 additions and 448 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [0.17.0](https://github.com/dhis2/maintenance-app-beta/compare/v0.16.1...v0.17.0) (2024-11-27)


### Features

* add format validation to date fields and to dates in schemas ([#451](https://github.com/dhis2/maintenance-app-beta/issues/451)) ([4ea1d3c](https://github.com/dhis2/maintenance-app-beta/commit/4ea1d3c22133b2f9b63bc58cbf69b3d09e70e2a9))

## [0.16.1](https://github.com/dhis2/maintenance-app-beta/compare/v0.16.0...v0.16.1) (2024-11-25)


Expand Down
8 changes: 5 additions & 3 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2024-11-27T08:30:38.416Z\n"
"PO-Revision-Date: 2024-11-27T08:30:38.417Z\n"
"POT-Creation-Date: 2024-11-26T14:06:00.934Z\n"
"PO-Revision-Date: 2024-11-26T14:06:00.934Z\n"

msgid "schemas"
msgstr "schemas"
Expand Down Expand Up @@ -102,6 +104,9 @@ msgstr "Set up information for the attributes assigned to {{modelName}}"
msgid "Code"
msgstr "Code"

msgid "Required"
msgstr "Required"

msgid "Description"
msgstr "Description"

Expand Down Expand Up @@ -906,9 +911,6 @@ msgstr "Cannot save empty object"
msgid "Created successfully"
msgstr "Created successfully"

msgid "Required"
msgstr "Required"

msgid "Period type"
msgstr "Period type"

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "maintenance-app",
"version": "0.16.1",
"version": "0.17.0",
"description": "",
"license": "BSD-3-Clause",
"private": true,
Expand Down Expand Up @@ -40,7 +40,7 @@
"dependencies": {
"@dhis2/app-runtime": "^3.9.3",
"@dhis2/multi-calendar-dates": "^2.0.0",
"@dhis2/ui": "^10.0.2",
"@dhis2/ui": "^10.1.3",
"@tanstack/react-table": "^8.16.0",
"@types/lodash": "^4.14.198",
"lodash": "^4.17.21",
Expand All @@ -56,6 +56,6 @@
"resolutions": {
"eslint": "^8",
"@dhis2/multi-calendar-dates": "^2.0.0",
"@dhis2/ui": "^10.0.2"
"@dhis2/ui": "^10.1.3"
}
}
27 changes: 17 additions & 10 deletions src/components/form/fields/DateField.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import i18n from '@dhis2/d2-i18n'
import { CalendarInput, CalendarInputProps } from '@dhis2/ui'
import React, { useState } from 'react'
import React, { useEffect, useState } from 'react'
import { useField } from 'react-final-form'
import { selectedLocale, useSystemSetting } from '../../../lib'

Expand All @@ -16,6 +17,7 @@ type ValidationProps = {
error: boolean
validationText?: string
valid?: boolean
validationCode?: string
}
export function DateField({
name,
Expand All @@ -29,21 +31,24 @@ export function DateField({
error: false,
})

const { input } = useField<string | undefined>(name, {
validate: () => {
if (validation.error) {
return validation.validationText
}
},
})
const { input, meta } = useField<string | undefined>(name)

const handleChange: CalendarInputProps['onDateSelect'] = (
payload: {
calendarDateString: string
validation?: ValidationProps
} | null
) => {
setValidation(payload?.validation || { error: false })
if (!payload?.calendarDateString && required) {
setValidation({
error: true,
valid: false,
validationCode: 'EMPTY',
validationText: i18n.t('Required'),
})
} else {
setValidation(payload?.validation || { error: false })
}
input.onChange(payload?.calendarDateString || '')
input.onBlur()
}
Expand All @@ -54,13 +59,15 @@ export function DateField({
inputWidth={'400px'}
date={input.value}
name={name}
required={required}
calendar={calendar as CalendarInputProps['calendar']}
onDateSelect={handleChange}
timeZone={'utc'}
locale={locale}
format={'YYYY-MM-DD'}
onBlur={(_, e) => input.onBlur(e)}
clearable
label={required ? `${label} (required) *` : label}
label={required ? `${label} (required)` : label}
{...validation}
valid={validation?.valid && input?.value !== ''}
{...calendarInputProps}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/categoryOptions/form/categoryOptionSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export const categoryOptionSchema = identifiable
})
.optional(),
description: z.string().trim().optional(),
startDate: z.string().optional(),
endDate: z.string().optional(),
startDate: z.string().date().optional(),
endDate: z.string().date().optional(),
organisationUnits: referenceCollection.optional(),
})
.refine(
Expand Down
4 changes: 2 additions & 2 deletions src/pages/organisationUnits/form/organisationUnitSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const organisationUnitSchema = identifiable
}),
})
.optional(),
openingDate: z.string(),
openingDate: z.string().date(),
email: z.string().email().optional(),
address: z
.string()
Expand All @@ -47,7 +47,7 @@ export const organisationUnitSchema = identifiable
.string()
.url({ message: i18n.t('Must be a valid url') })
.optional(),
closedDate: z.string().optional(),
closedDate: z.string().date().optional(),
comment: z
.string()
.max(2147483647, {
Expand Down
Loading

0 comments on commit 5ec5c43

Please sign in to comment.