More typings

This commit is contained in:
Adria Navarro 2024-12-24 00:42:57 +01:00
parent 26d1243e68
commit be1eef2976
2 changed files with 39 additions and 35 deletions

View File

@ -19,17 +19,12 @@ const columnTypeManyParser = {
field: {
timeOnly?: boolean
dateOnly?: boolean
ignoreTimezones?: boolean
}
) => {
function parseDate(value: any) {
const { timeOnly, dateOnly, ignoreTimezones } = field || {}
const { timeOnly, dateOnly } = field || {}
const enableTime = !dateOnly
const parsedValue = Helpers.parseDate(value, {
timeOnly,
enableTime,
ignoreTimezones,
})
const parsedValue = Helpers.parseDate(value, { enableTime })
const parsed = Helpers.getDateDisplayValue(parsedValue, {
enableTime,
timeOnly,
@ -51,11 +46,12 @@ const columnTypeManyParser = {
export function enrichSchemaWithRelColumns(
schema: Record<string, UIFieldSchema>
) {
): Record<string, UIFieldSchema> {
if (!schema) {
return
}
const result = Object.keys(schema).reduce((result, fieldName) => {
const result = Object.keys(schema).reduce<Record<string, UIFieldSchema>>(
(result, fieldName) => {
const field = schema[fieldName]
result[fieldName] = field
@ -75,6 +71,7 @@ export function enrichSchemaWithRelColumns(
const name = `${field.name}.${relColumn}`
result[name] = {
...relField,
type: null, // TODO
name,
related: { field: fieldName, subField: relColumn },
cellRenderType:
@ -84,7 +81,9 @@ export function enrichSchemaWithRelColumns(
}
}
return result
}, {})
},
{}
)
return result
}

View File

@ -7,5 +7,10 @@ import {
export type UIFieldSchema = FieldSchema &
BasicViewFieldMetadata & {
related?: { field: string; subField: string }
columns?: Record<string, RelationSchemaField & { type?: string }>
columns?: Record<string, UIRelationSchemaField & { type?: string }>
cellRenderType?: string
}
interface UIRelationSchemaField extends RelationSchemaField {
type: string
}