Skip to content

Commit

Permalink
remove redundancy of fields
Browse files Browse the repository at this point in the history
  • Loading branch information
glespinosa committed Feb 1, 2024
1 parent fc4321f commit 430baa8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 3 additions & 5 deletions src/apps/content-editor/src/app/components/Editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,18 @@ export default memo(function Editor({
saveClicked,
onUpdateFieldErrors,
fieldErrors,
newModelFields,
}) {
const dispatch = useDispatch();
const isNewItem = itemZUID.slice(0, 3) === "new";
const { data: fields } = useGetContentModelFieldsQuery(modelZUID);
const currentFields = isNewItem ? newModelFields : fields;

const activeFields = useMemo(() => {
if (currentFields?.length) {
return currentFields.filter((field) => !field.deletedAt);
if (fields?.length) {
return fields.filter((field) => !field.deletedAt);
}

return [];
}, [currentFields]);
}, [fields]);

const firstTextField = useMemo(() => {
if (activeFields?.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ export const ItemCreate = () => {
});

const {
data: newModelFields,
isSuccess: isSuccessNewModelFields,
isFetching: isFetchingNewModelFields,
} = useGetContentModelFieldsQuery(modelZUID);
Expand Down Expand Up @@ -314,7 +313,6 @@ export const ItemCreate = () => {
onUpdateFieldErrors={(errors: FieldError) => {
setFieldErrors(errors);
}}
newModelFields={newModelFields}
/>

<div className={styles.Meta}>
Expand Down

0 comments on commit 430baa8

Please sign in to comment.