Skip to content

Commit

Permalink
Merge pull request #20 from bancodobrasil/fix/menu-items-operation-sc…
Browse files Browse the repository at this point in the history
…reen-bug-meta
  • Loading branch information
ralphg6 authored Jul 28, 2023
2 parents 1ce7dfb + 77b97b7 commit 125752f
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/components/Menu/Items/OperationScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,22 @@ export const OperationScreen = ({
rules,
...rest
} = node;
let meta = Object.keys(rest.meta).reduce((acc, key) => {
const name = data.menu.meta.find(meta => meta.id === Number(key))?.name || key;
const meta = rest.meta[key];
const originalMeta = original?.meta[key] || original?.meta[name];
if (meta == null || meta === '' || meta === originalMeta) {
return acc;
}
return {
...acc,
[name]: meta,
};
}, {});
if (Object.keys(meta).length === 0) meta = undefined;
let meta;
if (rest.meta) {
meta = Object.keys(rest.meta).reduce((acc, key) => {
const name = data.menu.meta.find(meta => meta.id === Number(key))?.name || key;
const meta = rest.meta[key];
const originalMeta = original?.meta[key] || original?.meta[name];
if (meta == null || meta === '' || meta === originalMeta) {
return acc;
}
return {
...acc,
[name]: meta,
};
}, {});
if (Object.keys(meta).length === 0) meta = undefined;
}
let startPublication;
if (rest.startPublication) {
if (
Expand Down Expand Up @@ -930,7 +933,7 @@ export const OperationScreen = ({
</LocalizationProvider>
</Box>
<Divider sx={{ mt: '2rem' }} />
{data?.menu.meta?.length && (
{data?.menu.meta?.length > 0 && (
<Box sx={{ mt: '1.5rem' }}>
<Typography variant="h3">
{t('menu.fields.meta.title', { count: data.menu.meta.length })}
Expand Down Expand Up @@ -1224,7 +1227,7 @@ export const OperationScreen = ({
</LocalizationProvider>
</Box>
<Divider sx={{ mt: '2rem' }} />
{data?.menu.meta?.length && (
{data?.menu.meta?.length > 0 && (
<Box sx={{ mt: '1.5rem' }}>
<Typography variant="h3">
{t('menu.fields.meta.title', { count: data.menu.meta.length })}
Expand Down

0 comments on commit 125752f

Please sign in to comment.