Skip to content

Commit

Permalink
use unmarshaller in detail views
Browse files Browse the repository at this point in the history
  • Loading branch information
mmadariaga committed Mar 7, 2024
1 parent 38f1724 commit 8b3b493
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion library/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@irontec/ivoz-ui",
"version": "1.2.0",
"version": "1.2.1",
"description": "UI library used in ivozprovider",
"license": "GPL-3.0",
"main": "index.js",
Expand Down
5 changes: 4 additions & 1 deletion library/src/components/Detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ type DetailComponentProps = {
entityService: EntityService;
row: any;
View: () => Promise<ViewType>;
} & Pick<EntityInterface, 'foreignKeyResolver' | 'foreignKeyGetter'> &
} & Pick<
EntityInterface,
'foreignKeyResolver' | 'foreignKeyGetter' | 'unmarshaller' | 'properties'
> &
Pick<FormProps, 'groups'>;

type DetailComponentType = FunctionComponent<DetailComponentProps>;
Expand Down
18 changes: 13 additions & 5 deletions library/src/entities/DefaultEntityBehavior/View.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
import { Grid } from '@mui/material';
import React, { useEffect, useState } from 'react';
import { useStoreState } from 'store';
import FormFieldFactory from '../../services/form/FormFieldFactory';
import {
StyledGroupGrid,
StyledGroupLegend,
} from '../DefaultEntityBehavior.styles';
import { ForeignKeyGetterType, ViewProps } from '../EntityInterface';
import useFkChoices from '../data/useFkChoices';
import filterFieldsetGroups, {
FieldsetGroups,
FieldsetGroupsField,
} from './FilterFieldsetGroups';
import { useFormHandler } from './Form/useFormHandler';
import { NullablePropertyFkChoices } from './Form';
import { useStoreState } from 'store';
import useFkChoices from '../data/useFkChoices';
import { useFormHandler } from './Form/useFormHandler';

const View = (props: ViewProps): JSX.Element | null => {
const { entityService, row, fkChoices, match, foreignKeyGetter: foreignKeyGetterLoader } = props;
const {
entityService,
row,
unmarshaller,
properties,
fkChoices,
match,
foreignKeyGetter: foreignKeyGetterLoader,
} = props;

const [foreignKeyGetter, setForeignKeyGetter] = useState<
ForeignKeyGetterType | undefined
Expand All @@ -43,7 +51,7 @@ const View = (props: ViewProps): JSX.Element | null => {

const formik = useFormHandler({
...props,
initialValues: row,
initialValues: unmarshaller(row, properties),
validator: () => {
return {};
},
Expand Down
5 changes: 4 additions & 1 deletion library/src/entities/EntityInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ export type ViewProps = {
edit?: false;
fkChoices?: FkChoices;
match: PathMatch;
} & Pick<EntityInterface, 'foreignKeyResolver' | 'foreignKeyGetter'>;
} & Pick<
EntityInterface,
'foreignKeyResolver' | 'foreignKeyGetter' | 'unmarshaller' | 'properties'
>;

export type ViewType = (props: ViewProps) => JSX.Element | null;

Expand Down

0 comments on commit 8b3b493

Please sign in to comment.