Commit da455e40 authored by JzoNg's avatar JzoNg

fix state of preview switching

parent 97c06617
...@@ -401,18 +401,15 @@ const StepTwo = ({ ...@@ -401,18 +401,15 @@ const StepTwo = ({
setAutomaticFileIndexingEstimate(null) setAutomaticFileIndexingEstimate(null)
setShowPreview() setShowPreview()
fetchFileIndexingEstimate() fetchFileIndexingEstimate()
setPreviewSwitched(false)
} }
else { else {
hidePreview() hidePreview()
setCustomFileIndexingEstimate(null) setCustomFileIndexingEstimate(null)
setPreviewSwitched(false)
} }
}, [segmentationType, indexType]) }, [segmentationType, indexType])
useEffect(() => {
if (docForm === DocForm.TEXT)
setPreviewSwitched(false)
}, [docForm])
return ( return (
<div className='flex w-full h-full'> <div className='flex w-full h-full'>
<div ref={scrollRef} className='relative h-full w-full overflow-y-scroll'> <div ref={scrollRef} className='relative h-full w-full overflow-y-scroll'>
...@@ -680,14 +677,14 @@ const StepTwo = ({ ...@@ -680,14 +677,14 @@ const StepTwo = ({
)} )}
</div> </div>
<div className='my-4 px-8 space-y-4'> <div className='my-4 px-8 space-y-4'>
{previewSwitched && fileIndexingEstimate?.qa_preview && ( {previewSwitched && docForm === DocForm.QA && fileIndexingEstimate?.qa_preview && (
<> <>
{fileIndexingEstimate?.qa_preview.map((item, index) => ( {fileIndexingEstimate?.qa_preview.map((item, index) => (
<PreviewItem type={PreviewType.QA} key={item.question} qa={item} index={index + 1} /> <PreviewItem type={PreviewType.QA} key={item.question} qa={item} index={index + 1} />
))} ))}
</> </>
)} )}
{!previewSwitched && fileIndexingEstimate?.preview && ( {(docForm === DocForm.TEXT || !previewSwitched) && fileIndexingEstimate?.preview && (
<> <>
{fileIndexingEstimate?.preview.map((item, index) => ( {fileIndexingEstimate?.preview.map((item, index) => (
<PreviewItem type={PreviewType.TEXT} key={item} content={item} index={index + 1} /> <PreviewItem type={PreviewType.TEXT} key={item} content={item} index={index + 1} />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment