@@ -19,19 +19,19 @@ export type CustomTypeFieldMap = Record<string, FieldMap>;
1919type CustomTypeField = { id : string ; fields : string [ ] } ;
2020
2121interface ContentRelationshipFieldPickerProps {
22- value : CustomTypeField [ ] | undefined ;
22+ initialValues : CustomTypeField [ ] | undefined ;
2323 onChange : ( fields : CustomTypeField [ ] ) => void ;
2424}
2525
2626export function ContentRelationshipFieldPicker (
2727 props : ContentRelationshipFieldPickerProps ,
2828) {
29- const { value , onChange } = props ;
29+ const { initialValues , onChange } = props ;
3030 const customTypes = useCustomTypes ( ) ;
3131
3232 const stableOnChange = useStableCallback ( onChange ) ;
3333 const form = useFormik < CustomTypeFieldMap > ( {
34- initialValues : value ? getInitialValues ( value ) : { } ,
34+ initialValues : initialValues ? getInitialValues ( initialValues ) : { } ,
3535 onSubmit : ( ) => undefined , // values will be updated on change
3636 } ) ;
3737
@@ -163,13 +163,13 @@ function countPickedFields(fields: CustomTypeFieldMap | FieldMap | undefined) {
163163}
164164
165165function getInitialValues ( value : CustomTypeField [ ] ) {
166- return value . reduce < CustomTypeFieldMap > ( ( cts , ct ) => {
167- cts [ ct . id ] = ct . fields . reduce < FieldMap > ( ( fields , field ) => {
168- fields [ field ] = true ;
169- return fields ;
166+ return value . reduce < CustomTypeFieldMap > ( ( customTypes , { id , fields } ) => {
167+ customTypes [ id ] = fields . reduce < FieldMap > ( ( customTypeFields , field ) => {
168+ customTypeFields [ field ] = true ;
169+ return customTypeFields ;
170170 } , { } ) ;
171171
172- return cts ;
172+ return customTypes ;
173173 } , { } ) ;
174174}
175175
0 commit comments