@@ -9,6 +9,7 @@ import { Utils } from '../../helpers/utils';
99import StoreContext from '../../../bridge/Context/StoreContext' ;
1010import { getComponentFromMap } from '../../../bridge/helpers/sdk_component_map' ;
1111import type { PConnProps } from '../../../types/PConnProps' ;
12+ import { prepareCaseSummaryData } from '../utils' ;
1213
1314interface CaseViewProps extends PConnProps {
1415 // If any, enter additional props that only exist on this component
@@ -18,6 +19,15 @@ interface CaseViewProps extends PConnProps {
1819 showIconInHeader : boolean ;
1920 caseInfo : any ;
2021 lastUpdateCaseTime : any ;
22+ bShowUtilitiesRegion : any ;
23+ bShowCaseActions : any ;
24+ bShowCaseLifecycle : any ;
25+ bShowPromotedActions : any ;
26+ bShowPulseRegion : any ;
27+ bShowSummaryRegion : any ;
28+ selfServiceCaseView ?: boolean ;
29+ utilitysRegionEmpty ?: boolean ;
30+ summaryData ?: any ;
2131}
2232
2333const useStyles = makeStyles ( theme => ( {
@@ -52,19 +62,23 @@ export default function CaseView(props: PropsWithChildren<CaseViewProps>) {
5262 const CaseViewActionsMenu = getComponentFromMap ( 'CaseViewActionsMenu' ) ;
5363 const VerticalTabs = getComponentFromMap ( 'VerticalTabs' ) ;
5464 const DeferLoad = getComponentFromMap ( 'DeferLoad' ) ;
65+ const CaseSummary = getComponentFromMap ( 'CaseSummary' ) ;
5566
5667 const {
5768 getPConnect,
5869 icon = '' ,
5970 header,
6071 subheader,
6172 children = [ ] ,
62- // eslint-disable-next-line @typescript-eslint/no-unused-vars
63- showIconInHeader = true ,
73+ bShowCaseLifecycle,
74+ bShowSummaryRegion,
75+ bShowUtilitiesRegion,
76+ selfServiceCaseView,
77+ utilitysRegionEmpty,
6478 caseInfo : { availableActions = [ ] , availableProcesses = [ ] , hasNewAttachments, caseTypeID = '' , caseTypeName = '' }
6579 } = props ;
6680 const { lastUpdateCaseTime = getPConnect ( ) . getValue ( 'caseInfo.lastUpdateTime' ) } = props ;
67-
81+ let { summaryData : { primarySummaryFields = [ ] , secondarySummaryFields = [ ] } = { } } = props ;
6882 const currentCaseID = props . caseInfo . ID ;
6983 let isComponentMounted = true ;
7084 const { displayOnlyFA } = useContext < any > ( StoreContext ) ;
@@ -84,9 +98,8 @@ export default function CaseView(props: PropsWithChildren<CaseViewProps>) {
8498 */
8599 function getChildRegionByName ( inName : string ) : any {
86100 for ( const child of children as ReactElement [ ] ) {
87- const theMetadataType : string = ( child as ReactElement ) . props . getPConnect ( ) . getRawMetadata ( ) . type . toLowerCase ( ) ;
88- const theMetadataName : string = ( child as ReactElement ) . props . getPConnect ( ) . getRawMetadata ( ) . name . toLowerCase ( ) ;
89-
101+ const theMetadataType : string = ( child as ReactElement ) . props . getPConnect ( ) . getRawMetadata ( ) . type ?. toLowerCase ( ) ;
102+ const theMetadataName : string = ( child as ReactElement ) . props . getPConnect ( ) . getRawMetadata ( ) . name ?. toLowerCase ( ) ;
90103 if ( theMetadataType === 'region' && theMetadataName === inName ) {
91104 return child ;
92105 }
@@ -95,7 +108,14 @@ export default function CaseView(props: PropsWithChildren<CaseViewProps>) {
95108 return null ;
96109 }
97110
98- const theSummaryRegion = getChildRegionByName ( 'summary' ) ;
111+ const theSummaryRegion = children && children [ 0 ] ;
112+
113+ if ( ! selfServiceCaseView ) {
114+ const data = prepareCaseSummaryData ( theSummaryRegion ) ;
115+ primarySummaryFields = data . primarySummaryFields ;
116+ secondarySummaryFields = data . secondarySummaryFields ;
117+ }
118+
99119 const theStagesRegion = getChildRegionByName ( 'stages' ) ;
100120 const theTodoRegion = getChildRegionByName ( 'todo' ) ;
101121 const theUtilitiesRegion = getChildRegionByName ( 'utilities' ) ;
@@ -109,7 +129,7 @@ export default function CaseView(props: PropsWithChildren<CaseViewProps>) {
109129 // const tmpLoadData2 = { config: { label: "Case History", name: "CaseHistory" }, type: "DeferLoad" };
110130
111131 // Extract the tabs we need to display from theTabsRegion (one tab per entry in theTabsRegionChildren)
112- const theTabsRegionChildren = theTabsRegion . props . getPConnect ( ) . getChildren ( ) ;
132+ const theTabsRegionChildren = theTabsRegion ? .props . getPConnect ( ) . getChildren ( ) ;
113133
114134 // vertTabInfo is sent to VerticalTabs component
115135 const vertTabInfo : object [ ] = [ ] ;
@@ -208,45 +228,49 @@ export default function CaseView(props: PropsWithChildren<CaseViewProps>) {
208228 return (
209229 < Grid2 container >
210230 < Grid2 size = { { xs : 3 } } >
211- < div hidden = { true } id = 'current-caseID' >
212- { currentCaseID }
213- </ div >
214- < Card className = { classes . root } >
215- < CardHeader
216- className = { classes . caseViewHeader }
217- title = {
218- < Typography variant = 'h6' component = 'div' id = 'case-name' >
219- { PCore . getLocaleUtils ( ) . getLocaleValue ( header , '' , localeKey ) }
220- </ Typography >
221- }
222- subheader = {
223- < Typography variant = 'body1' component = 'div' id = 'caseId' >
224- { subheader }
225- </ Typography >
226- }
227- avatar = {
228- < Avatar className = { classes . caseViewIconBox } variant = 'square' >
229- < img src = { svgCase } className = { classes . caseViewIconImage } />
230- </ Avatar >
231- }
232- />
233- { getActionButtonsHtml ( ) }
234- < Divider />
235- { theSummaryRegion }
236- < Divider />
237- { vertTabInfo . length > 1 && < VerticalTabs tabconfig = { vertTabInfo } /> }
238- </ Card >
231+ { ( selfServiceCaseView ? bShowSummaryRegion && ( primarySummaryFields . length > 0 || secondarySummaryFields . length > 0 ) : true ) && (
232+ < div >
233+ < div hidden = { true } id = 'current-caseID' >
234+ { currentCaseID }
235+ </ div >
236+ < Card className = { classes . root } >
237+ < CardHeader
238+ className = { classes . caseViewHeader }
239+ title = {
240+ < Typography variant = 'h6' component = 'div' id = 'case-name' >
241+ { PCore . getLocaleUtils ( ) . getLocaleValue ( header , '' , localeKey ) }
242+ </ Typography >
243+ }
244+ subheader = {
245+ < Typography variant = 'body1' component = 'div' id = 'caseId' >
246+ { subheader }
247+ </ Typography >
248+ }
249+ avatar = {
250+ < Avatar className = { classes . caseViewIconBox } variant = 'square' >
251+ < img src = { svgCase } className = { classes . caseViewIconImage } />
252+ </ Avatar >
253+ }
254+ />
255+ { ! selfServiceCaseView && getActionButtonsHtml ( ) }
256+ < Divider />
257+ < CaseSummary arPrimaryFields = { primarySummaryFields } arSecondaryFields = { secondarySummaryFields } > </ CaseSummary >
258+ < Divider />
259+ { vertTabInfo . length > 1 && < VerticalTabs tabconfig = { vertTabInfo } /> }
260+ </ Card >
261+ </ div >
262+ ) }
239263 </ Grid2 >
240264
241265 < Grid2 size = { { xs : 6 } } >
242- { theStagesRegion }
266+ { bShowCaseLifecycle && theStagesRegion }
243267 { theTodoRegion }
244268 { deferLoadInfo . length > 0 && (
245269 < DeferLoad getPConnect = { getPConnect } name = { deferLoadInfo [ activeVertTab ] . config . name } isTab lastUpdateCaseTime = { lastUpdateCaseTime } />
246270 ) }
247271 </ Grid2 >
248272
249- < Grid2 size = { { xs : 3 } } > { theUtilitiesRegion } </ Grid2 >
273+ { ( selfServiceCaseView ? bShowUtilitiesRegion && utilitysRegionEmpty : true ) && < Grid2 size = { { xs : 3 } } > { theUtilitiesRegion } </ Grid2 > }
250274 </ Grid2 >
251275 ) ;
252276 }
0 commit comments