@@ -19,6 +19,7 @@ import {
1919import getImageDataURI from '@/utils/getImageDataURI' ;
2020import { SummaryProps } from '@/commonComponents' ;
2121
22+ import SplitRowSpanHandler from '@/handlers/splitRowSpanHandler' ;
2223import Summary from '../ReportView/components/Summary' ;
2324import RunningLeft from './components/RunningLeft' ;
2425import RunningCenter from './components/RunningCenter' ;
@@ -34,6 +35,8 @@ const Appendices = lazy(() => import('../ReportView/components/Appendices'));
3435
3536const reducer = ( state , action ) => {
3637 switch ( action . type ) {
38+ case 'summary' :
39+ return { ...state , summary : true } ;
3740 case 'summary-genomic' :
3841 return { ...state , summary : true } ;
3942 case 'summary-tgr' :
@@ -176,45 +179,6 @@ const Print = ({
176179 }
177180 } , [ params . ident , report ] ) ;
178181
179- useEffect ( ( ) => {
180- if ( reportSectionsLoaded
181- && template ?. sections . length
182- && Object . entries ( reportSectionsLoaded ) . every ( ( [ section , loaded ] ) => loaded || ! template ?. sections . includes ( section ) )
183- && ! isPrintDialogShown ) {
184- const showPrint = async ( ) => {
185- const paged = new Previewer ( ) ;
186- await paged . preview ( document . getElementById ( 'root' ) , [ 'index.css' ] , document . body ) ;
187- const templateName = report . template . name === 'probe' ? 'targeted_gene' : report . template . name ;
188- const currentDate = new Date ( ) ;
189- const year = currentDate . getFullYear ( ) ;
190- const month = ( currentDate . getMonth ( ) + 1 ) . toString ( ) . padStart ( 2 , '0' ) ;
191- const day = currentDate . getDate ( ) . toString ( ) . padStart ( 2 , '0' ) ;
192- const hours = currentDate . getHours ( ) . toString ( ) . padStart ( 2 , '0' ) ;
193- const minutes = currentDate . getMinutes ( ) . toString ( ) . padStart ( 2 , '0' ) ;
194- const seconds = currentDate . getSeconds ( ) . toString ( ) . padStart ( 2 , '0' ) ;
195- let serverName ;
196- switch ( process . env . NODE_ENV ) {
197- case 'development' :
198- serverName = '_iprdev' ;
199- break ;
200- case 'staging' :
201- serverName = '_iprstaging' ;
202- break ;
203- default :
204- serverName = '' ;
205- break ;
206- }
207- const formattedDate = `${ year } -${ month } -${ day } _${ hours } h${ minutes } m${ seconds } s` ;
208-
209- document . title = `${ report . patientId } ${ serverName } _${ templateName } _report_${ formattedDate } ` ;
210-
211- window . print ( ) ;
212- setIsPrintDialogShown ( true ) ;
213- } ;
214- showPrint ( ) ;
215- }
216- } , [ isPrintDialogShown , report , reportSectionsLoaded , template ] ) ;
217-
218182 const renderSections = useMemo ( ( ) => {
219183 if ( report && template ) { // TODO remove checks on 'summary' and template name once data updated in prod
220184 return (
@@ -267,6 +231,48 @@ const Print = ({
267231 setReport,
268232 } ) , [ report , setReport ] ) ;
269233
234+ useEffect ( ( ) => {
235+ if (
236+ reportSectionsLoaded
237+ && template ?. sections . length
238+ && Object . entries ( reportSectionsLoaded ) . every ( ( [ section , loaded ] ) => loaded || ! template ?. sections . includes ( section ) )
239+ && ! isPrintDialogShown
240+ ) {
241+ const showPrint = async ( ) => {
242+ const paged = new Previewer ( ) ;
243+ paged . registerHandlers ( SplitRowSpanHandler ) ;
244+ await paged . preview ( document . getElementById ( 'root' ) , [ 'index.css' ] , document . body ) ;
245+ const templateName = report . template . name === 'probe' ? 'targeted_gene' : report . template . name ;
246+ const currentDate = new Date ( ) ;
247+ const year = currentDate . getFullYear ( ) ;
248+ const month = ( currentDate . getMonth ( ) + 1 ) . toString ( ) . padStart ( 2 , '0' ) ;
249+ const day = currentDate . getDate ( ) . toString ( ) . padStart ( 2 , '0' ) ;
250+ const hours = currentDate . getHours ( ) . toString ( ) . padStart ( 2 , '0' ) ;
251+ const minutes = currentDate . getMinutes ( ) . toString ( ) . padStart ( 2 , '0' ) ;
252+ const seconds = currentDate . getSeconds ( ) . toString ( ) . padStart ( 2 , '0' ) ;
253+ let serverName ;
254+ switch ( process . env . NODE_ENV ) {
255+ case 'development' :
256+ serverName = '_iprdev' ;
257+ break ;
258+ case 'staging' :
259+ serverName = '_iprstaging' ;
260+ break ;
261+ default :
262+ serverName = '' ;
263+ break ;
264+ }
265+ const formattedDate = `${ year } -${ month } -${ day } _${ hours } h${ minutes } m${ seconds } s` ;
266+
267+ document . title = `${ report . patientId } ${ serverName } _${ templateName } _report_${ formattedDate } ` ;
268+
269+ window . print ( ) ;
270+ setIsPrintDialogShown ( true ) ;
271+ } ;
272+ showPrint ( ) ;
273+ }
274+ } , [ isPrintDialogShown , report , reportSectionsLoaded , template ] ) ;
275+
270276 return (
271277 < ReportContext . Provider value = { reportContextValue } >
272278 < div className = { `${ printVersion === 'condensedLayout' ? 'condensedLayout' : 'print' } ` } >
0 commit comments