@@ -19,6 +19,9 @@ export default function FixIssuesContentPreview({
1919 const [ currentFile , setCurrentFile ] = useState ( null )
2020 const [ oldFile , setOldFile ] = useState ( null )
2121
22+ const ORIGINAL_LABEL = "-original"
23+ const REPLACED_LABEL = "-replaced"
24+
2225 useEffect ( ( ) => {
2326 if ( activeIssue ) {
2427 handleFileReference ( )
@@ -53,39 +56,43 @@ export default function FixIssuesContentPreview({
5356 activeIssue . fileData . replacement ?. references ?. forEach ( ( ref ) => {
5457 let tempRef = JSON . parse ( JSON . stringify ( ref ) )
5558 tempRef . status = 1
56- if ( ! tempReferences [ tempRef . contentItemId ] ) {
57- tempReferences [ tempRef . contentItemId ] = [ ]
59+ const refKey = tempRef . contentItemId + REPLACED_LABEL
60+ if ( ! tempReferences [ refKey ] ) {
61+ tempReferences [ refKey ] = [ ]
5862 }
59- tempReferences [ tempRef . contentItemId ] . push ( tempRef )
63+ tempReferences [ refKey ] . push ( tempRef )
6064 } )
6165
6266 activeIssue . fileData . replacement ?. sectionRefs ?. forEach ( ( ref ) => {
6367 let tempRef = JSON . parse ( JSON . stringify ( ref ) )
6468 tempRef . status = 1
65- if ( ! tempReferences [ tempRef . contentItemId ] ) {
66- tempReferences [ tempRef . contentItemId ] = [ ]
69+ const refKey = tempRef . contentItemId + REPLACED_LABEL
70+ if ( ! tempReferences [ refKey ] ) {
71+ tempReferences [ refKey ] = [ ]
6772 }
68- tempReferences [ tempRef . contentItemId ] . push ( tempRef )
73+ tempReferences [ refKey ] . push ( tempRef )
6974 } )
7075
7176
7277 activeIssue . fileData . references ?. forEach ( ( ref ) => {
7378 let tempRef = JSON . parse ( JSON . stringify ( ref ) )
7479 tempRef . status = 0
75- if ( ! tempReferences [ tempRef . contentItemId ] ) {
76- tempReferences [ tempRef . contentItemId ] = [ ]
80+ const refKey = tempRef . contentItemId + ORIGINAL_LABEL
81+ if ( ! tempReferences [ refKey ] ) {
82+ tempReferences [ refKey ] = [ ]
7783 }
78- tempReferences [ tempRef . contentItemId ] . push ( tempRef )
84+ tempReferences [ refKey ] . push ( tempRef )
7985 } )
8086
8187
8288 activeIssue . fileData . sectionRefs ?. forEach ( ( ref ) => {
8389 let tempRef = JSON . parse ( JSON . stringify ( ref ) )
8490 tempRef . status = 0
85- if ( ! tempReferences [ tempRef . contentItemId ] ) {
86- tempReferences [ tempRef . contentItemId ] = [ ]
91+ const refKey = tempRef . contentItemId + ORIGINAL_LABEL
92+ if ( ! tempReferences [ refKey ] ) {
93+ tempReferences [ refKey ] = [ ]
8794 }
88- tempReferences [ tempRef . contentItemId ] . push ( tempRef )
95+ tempReferences [ refKey ] . push ( tempRef )
8996 } )
9097
9198 setFileReferenceHolder ( tempReferences )
@@ -148,19 +155,19 @@ export default function FixIssuesContentPreview({
148155 </ tr >
149156 </ thead >
150157 < tbody >
151- { Object . keys ( fileReferenceHolder ) ?. map ( ( contentId , index ) => (
158+ { Object . keys ( fileReferenceHolder ) ?. map ( ( key , index ) => (
152159 < tr key = { index } >
153160 < td >
154- < a href = { fileReferenceHolder [ contentId ] [ 0 ] . contentType == "quiz_question" ? fileReferenceHolder [ contentId ] [ 0 ] . contentItemUrl . replace ( / \/ q u e s t i o n s .* / , "/edit#questions_tab" ) : fileReferenceHolder [ contentId ] [ 0 ] . contentItemUrl } target = '_blank' className = 'location-link flex-row align-items-center' >
155- { fileReferenceHolder [ contentId ] [ 0 ] . contentItemTitle }
161+ < a href = { fileReferenceHolder [ key ] [ 0 ] . contentType == "quiz_question" ? fileReferenceHolder [ key ] [ 0 ] . contentItemUrl . replace ( / \/ q u e s t i o n s .* / , "/edit#questions_tab" ) : fileReferenceHolder [ key ] [ 0 ] . contentItemUrl } target = '_blank' className = 'location-link flex-row align-items-center' >
162+ { fileReferenceHolder [ key ] [ 0 ] . contentItemTitle }
156163 < ExternalLinkIcon className = "link-color align-self-center ms-2 icon-sm" />
157164 </ a >
158165 </ td >
159166 < td >
160- < p > { fileReferenceHolder [ contentId ] ?. length } </ p >
167+ < p > { fileReferenceHolder [ key ] ?. length } </ p >
161168 </ td >
162169 < td >
163- { activeIssue . fileData . replacement ? (
170+ { key . includes ( REPLACED_LABEL ) ? (
164171 < div className = 'file-label-pill file-new' > { t ( 'form.file.new.label' ) } </ div >
165172 ) : (
166173 < div className = 'file-label-pill' > { t ( 'form.file.original.label' ) } </ div >
0 commit comments