@@ -3,6 +3,8 @@ import { getComponentFromMap } from '../../../bridge/helpers/sdk_component_map';
33import type { PConnProps } from '../../../types/PConnProps' ;
44
55interface CaseSummaryProps extends PConnProps {
6+ arPrimaryFields : any [ ] ;
7+ arSecondaryFields : any [ ] ;
68 // If any, enter additional props that only exist on this component
79}
810
@@ -11,18 +13,16 @@ export default function CaseSummary(props: PropsWithChildren<CaseSummaryProps>)
1113 const CaseSummaryFields = getComponentFromMap ( 'CaseSummaryFields' ) ;
1214
1315 const { getPConnect, children } = props ;
16+ let { arPrimaryFields = [ ] , arSecondaryFields = [ ] } = props ;
1417
15- const thePConn = getPConnect ( ) ;
16- const theConfigProps : any = thePConn . getConfigProps ( ) ;
17- // const { status, showStatus } = theConfigProps;
18- const status = theConfigProps . status ;
19- const showStatus = theConfigProps . showStatus ;
18+ const thePConn = getPConnect && getPConnect ( ) ;
19+ const theConfigProps : any = thePConn ? .getConfigProps ( ) ;
20+
21+ const status = theConfigProps ? .status ;
22+ const showStatus = theConfigProps ? .showStatus ;
2023 const localizedVal = PCore . getLocaleUtils ( ) . getLocaleValue ;
2124 const localeCategory = 'ModalContainer' ;
2225
23- let arPrimaryFields : any [ ] = [ ] ;
24- let arSecondaryFields : any [ ] = [ ] ;
25-
2626 function prepareComponentInCaseSummary ( pConnectMeta , getPConnect ) {
2727 const { config, children } = pConnectMeta ;
2828 const pConnect = getPConnect ( ) ;
@@ -54,22 +54,24 @@ export default function CaseSummary(props: PropsWithChildren<CaseSummaryProps>)
5454 return summaryFieldChildren ? convertChildrenToSummaryData ( summaryFieldChildren ?. getChildren ( ) ) : undefined ;
5555 }
5656
57- for ( const child of children as ReactElement [ ] ) {
58- const childPConn = ( child as ReactElement ) . props . getPConnect ( ) ;
59- const childPConnData = childPConn . resolveConfigProps ( childPConn . getRawMetadata ( ) ) ;
60- if ( childPConnData . name . toLowerCase ( ) === 'primary fields' ) {
61- arPrimaryFields = childPConnData . children ;
62- arPrimaryFields . forEach ( field => {
63- if ( field . config ?. value && typeof field . config ?. value === 'string' ) {
64- field . config . value = localizedVal ( field . config . value , localeCategory ) ;
65- }
66- } ) ;
67- } else if ( childPConnData . name . toLowerCase ( ) === 'secondary fields' ) {
68- const secondarySummaryFields = prepareCaseSummaryData ( childPConn ) ;
69- arSecondaryFields = childPConnData . children ;
70- arSecondaryFields . forEach ( ( field , index ) => {
71- field . config . displayLabel = secondarySummaryFields [ index ] ?. value ?. props ?. label ;
72- } ) ;
57+ if ( arPrimaryFields . length === 0 && arSecondaryFields . length === 0 ) {
58+ for ( const child of children as ReactElement [ ] ) {
59+ const childPConn = ( child as ReactElement ) . props . getPConnect ( ) ;
60+ const childPConnData = childPConn . resolveConfigProps ( childPConn . getRawMetadata ( ) ) ;
61+ if ( childPConnData . name . toLowerCase ( ) === 'primary fields' ) {
62+ arPrimaryFields = childPConnData . children ;
63+ arPrimaryFields . forEach ( field => {
64+ if ( field . config ?. value && typeof field . config ?. value === 'string' ) {
65+ field . config . value = localizedVal ( field . config . value , localeCategory ) ;
66+ }
67+ } ) ;
68+ } else if ( childPConnData . name . toLowerCase ( ) === 'secondary fields' ) {
69+ const secondarySummaryFields = prepareCaseSummaryData ( childPConn ) ;
70+ arSecondaryFields = childPConnData . children ;
71+ arSecondaryFields . forEach ( ( field , index ) => {
72+ field . config . displayLabel = secondarySummaryFields [ index ] ?. value ?. props ?. label ;
73+ } ) ;
74+ }
7375 }
7476 }
7577
0 commit comments