Skip to content

Commit

Permalink
uncommit me
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammer5 committed Oct 12, 2023
1 parent 2162394 commit 783d7ff
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"react-router-dom": "^6.11.2",
"use-debounce": "^9.0.4",
"use-query-params": "^2.2.1",
"zod": "^3.22.2",
"zustand": "^4.4.0"
}
}
2 changes: 1 addition & 1 deletion src/pages/dataElements/Edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Attribute, DataElement } from '../../types/generated'
import { createJsonPatchOperations } from './edit'
import classes from './Edit.module.css'
import { DataElementFormFields, useCustomAttributesQuery } from './form'
import { FormValues } from './form/types'
import type { FormValues } from './form'

type FinalFormFormApi = FormApi<FormValues>

Expand Down
2 changes: 1 addition & 1 deletion src/pages/dataElements/New.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { SCHEMA_SECTIONS } from '../../constants'
import { getSectionPath } from '../../lib'
import { Attribute } from '../../types/generated'
import { DataElementFormFields, useCustomAttributesQuery } from './form'
import { FormValues } from './form/types'
import type { FormValues } from './form'
import classes from './New.module.css'

const listPath = `/${getSectionPath(SCHEMA_SECTIONS.dataElement)}`
Expand Down
2 changes: 1 addition & 1 deletion src/pages/dataElements/edit/createJsonPatchOperations.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import get from 'lodash/fp/get'
import { JsonPatchOperation } from '../../../types'
import { DataElement } from '../../../types/generated'
import { FormValues } from '../form/types'
import type { FormValues } from '../form'

type DataElementKey = keyof DataElement

Expand Down
87 changes: 87 additions & 0 deletions src/pages/dataElements/edit/dataElementSchema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { z } from 'zod'

export const dataElementSchema = z.object({
name: z.string(),
shortName: z.string(),
code: z.string().optional(),
description: z.string().optional(),
url: z.string().optional(),
color: z.string().optional(),
icon: z.string().optional(),
fieldMask: z.string().optional(),
domainType: z.union([
z.literal('AGGREGATE'),
z.literal('TRACKER'),
]),
formName: z.string().optional(),
valueType: z.union([
z.literal('TEXT'),
z.literal('LONG_TEXT'),
z.literal('MULTI_TEXT'),
z.literal('LETTER'),
z.literal('PHONE_NUMBER'),
z.literal('EMAIL'),
z.literal('BOOLEAN'),
z.literal('TRUE_ONLY'),
z.literal('DATE'),
z.literal('DATETIME'),
z.literal('TIME'),
z.literal('NUMBER'),
z.literal('UNIT_INTERVAL'),
z.literal('PERCENTAGE'),
z.literal('INTEGER'),
z.literal('INTEGER_POSITIVE'),
z.literal('INTEGER_NEGATIVE'),
z.literal('INTEGER_ZERO_OR_POSITIVE'),
z.literal('TRACKER_ASSOCIATE'),
z.literal('USERNAME'),
z.literal('COORDINATE'),
z.literal('ORGANISATION_UNIT'),
z.literal('REFERENCE'),
z.literal('AGE'),
z.literal('URL'),
z.literal('FILE_RESOURCE'),
z.literal('IMAGE'),
z.literal('GEOJSON'),
]).optional(),
aggregationType: z.union([
z.literal('SUM'),
z.literal('AVERAGE'),
z.literal('AVERAGE_SUM_ORG_UNIT'),
z.literal('LAST'),
z.literal('LAST_AVERAGE_ORG_UNIT'),
z.literal('LAST_LAST_ORG_UNIT'),
z.literal('LAST_IN_PERIOD'),
z.literal('LAST_IN_PERIOD_AVERAGE_ORG_UNIT'),
z.literal('FIRST'),
z.literal('FIRST_AVERAGE_ORG_UNIT'),
z.literal('FIRST_FIRST_ORG_UNIT'),
z.literal('COUNT'),
z.literal('STDDEV'),
z.literal('VARIANCE'),
z.literal('MIN'),
z.literal('MAX'),
z.literal('MIN_SUM_ORG_UNIT'),
z.literal('MAX_SUM_ORG_UNIT'),
z.literal('NONE'),
z.literal('CUSTOM'),
z.literal('DEFAULT'),
]).optional(),
categoryCombo: z.object({
id: z.string(),
}),
optionSet: z.object({
id: z.string().optional(),
}),
commentOptionSet: z.object({
id: z.string().optional(),
}),
legendSets: z.array(z.string()),
aggregationLevels: z.array(z.number()),
attributeValues: z.array(z.object({
value: z.string(),
attribute: z.object({
id: z.string(),
}),
})),
})
1 change: 1 addition & 0 deletions src/pages/dataElements/form/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { DataElementFormFields } from './DataElementFormFields'
export { computeInitialValues } from './computeInitialValues'
export { useCustomAttributesQuery } from './useCustomAttributesQuery'
export { FormValues } from './types'
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14181,6 +14181,11 @@ zip-stream@^2.1.2:
compress-commons "^2.1.1"
readable-stream "^3.4.0"

zod@^3.22.2:
version "3.22.4"
resolved "https://registry.yarnpkg.com/zod/-/zod-3.22.4.tgz#f31c3a9386f61b1f228af56faa9255e845cf3fff"
integrity sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==

zustand@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/zustand/-/zustand-4.4.0.tgz#13b3e8ca959dd53d536034440aec382ff91b65c3"
Expand Down

0 comments on commit 783d7ff

Please sign in to comment.