Skip to content

Commit

Permalink
feat: display staging in detailed view
Browse files Browse the repository at this point in the history
  • Loading branch information
danielstefanequilobe committed Feb 24, 2022
1 parent 24e0287 commit eb33eb6
Showing 1 changed file with 34 additions and 21 deletions.
55 changes: 34 additions & 21 deletions src/components/blocks/DetailedViewStagingTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,48 @@ const StyledDetailedViewTab = styled('div')`
`;

const DetailedViewTabItem = ({ entry }) => {
const hasEntryKeyData = key =>
(entry[key].original !== null && entry[key].original !== 'null') ||
(entry[key].changes &&
entry[key].changes.some(change => change !== null && change !== 'null'));

const isKeyAllowedToBeDisplayed = key =>
![
'orgUid',
'warehouseProjectId',
'id',
'createdAt',
'updatedAt',
'label_unit',
].includes(key);

const isOriginalDataToBeDisplayedInRed = key =>
entry[key].changes &&
entry[key].changes.length > 0 &&
entry[key].changes.some(x => x !== null);

return (
<StyledDetailedViewTabItem>
{Object.keys(entry).map(
(entryProp, index) =>
![
'orgUid',
'warehouseProjectId',
'id',
'createdAt',
'updatedAt',
'label_unit',
].includes(entryProp) && (
isKeyAllowedToBeDisplayed(entryProp) &&
hasEntryKeyData(entryProp) && (
<div key={index}>
<Body size="Bold">
{convertPascalCaseToSentenceCase(entryProp)}
</Body>
{entry[entryProp].original && (
<Body
color={
entry[entryProp].changes &&
entry[entryProp].changes.length > 0 &&
entry[entryProp].changes.some(x => x !== null)
? '#f5222d'
: '#000000'
}
>
{entry[entryProp].original}
</Body>
)}
{entry[entryProp].original &&
entry[entryProp].original !== 'null' && (
<Body
color={
isOriginalDataToBeDisplayedInRed(entryProp)
? '#f5222d'
: '#000000'
}
>
{entry[entryProp].original}
</Body>
)}
{entry[entryProp].changes &&
entry[entryProp].changes.length > 0 &&
entry[entryProp].changes.some(x => x !== null) &&
Expand Down

0 comments on commit eb33eb6

Please sign in to comment.