Skip to content

Commit

Permalink
fix: delete typename from metadata.recordModel and send to bff only n…
Browse files Browse the repository at this point in the history
…ecessary fields (#578)
  • Loading branch information
Eliav-Maimon authored Dec 30, 2024
1 parent 1e415a4 commit b052c0a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/discrete-layer/components/layer-details/entity.dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import React, { useEffect, useCallback, useState, useLayoutEffect, useRef } from 'react';
import React, { useEffect, useCallback, useState, useLayoutEffect, useRef, useMemo } from 'react';
import { useIntl } from 'react-intl';
import { observer } from 'mobx-react';
import { FormikValues } from 'formik';
Expand Down Expand Up @@ -44,6 +44,7 @@ import { LayersDetailsComponent } from './layer-details';
import { IRecordFieldInfo } from './layer-details.field-info';
import EntityForm from './layer-datails-form';
import {
cleanUpEntityPayload,
clearSyncWarnings,
getFlatEntityDescriptors,
getPartialRecord,
Expand Down Expand Up @@ -189,6 +190,16 @@ export const EntityDialog: React.FC<EntityDialogProps> = observer(
);
};

const metadataPayloadKeys = useMemo(
() => {
return getFlatEntityDescriptors(
'Layer3DRecord',
store.discreteLayersStore.entityDescriptors as EntityDescriptorModelType[]
)
.map(descriptor => descriptor.fieldName);
},
[store.discreteLayersStore.entityDescriptors]);

const handleIngestQueries = (): void => {
// eslint-disable-next-line @typescript-eslint/naming-convention
const { directory, fileNames, __typename, ...metadata } = inputValues;
Expand All @@ -211,7 +222,7 @@ export const EntityDialog: React.FC<EntityDialogProps> = observer(
data: {
directory: directory as string,
fileNames: [fileNames as string],
metadata: metadata as Layer3DRecordInput,
metadata: cleanUpEntityPayload(metadata, metadataPayloadKeys as string[]) as unknown as Layer3DRecordInput,
type: RecordType.RECORD_3D,
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ const InnerForm = (
metadata: MetadataFile
): void => {
setIsSelectedFiles(!!ingestionFields.fileNames);

delete ((metadata.recordModel as unknown) as Record<string, unknown>)['__typename'];

// Check update related fields in metadata obj
const updateFields = extractDescriptorRelatedFieldNames('updateRules', getFlatEntityDescriptors(layerRecord.__typename, entityDescriptors));
Expand Down

0 comments on commit b052c0a

Please sign in to comment.