NTP-22476 | Training module integration
This commit is contained in:
@@ -8,6 +8,8 @@ import RNFetchBlob from 'react-native-blob-util';
|
||||
import SuspenseLoader from '@rn-ui-lib/components/suspense_loader/SuspenseLoader';
|
||||
import Text from '@rn-ui-lib/components/Text';
|
||||
import { isFunction } from '@components/utlis/commonFunctions';
|
||||
import { getFileType } from '@screens/caseDetails/PDFUtil';
|
||||
import { DocumentContentType } from '@screens/caseDetails/interface';
|
||||
|
||||
const ERROR_STATE = 'ERROR';
|
||||
|
||||
@@ -29,8 +31,16 @@ const PdfRenderer: React.FC<IPdfRenderer> = ({ docId, url, onPageChange }) => {
|
||||
setPdfFilePath(ERROR_STATE);
|
||||
} else if (highQualityResponse.respInfo.status === 200) {
|
||||
const highQualityImageBase64 = await highQualityResponse.base64();
|
||||
const documentType = await getFileType(highQualityImageBase64);
|
||||
if (documentType !== DocumentContentType.PDF) {
|
||||
setPdfFilePath(ERROR_STATE);
|
||||
return;
|
||||
}
|
||||
await RNFetchBlob.fs.writeFile(cacheFilePath, highQualityImageBase64, 'base64');
|
||||
setPdfFilePath(cacheFilePath);
|
||||
const exists = await RNFetchBlob.fs.exists(cacheFilePath);
|
||||
if (exists) {
|
||||
setPdfFilePath(cacheFilePath);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ const TrainingMaterialDetail: React.FC<TrainingMaterialDetailProps> = (props) =>
|
||||
params: { trainingMaterialData },
|
||||
},
|
||||
} = props;
|
||||
const { title, fileType, referenceId } = trainingMaterialData;
|
||||
const { title, fileType, referenceId } = trainingMaterialData || {};
|
||||
const isVideo = fileType === TrainingMaterialContentType.VIDEO;
|
||||
const [fileDetails, setFileDetails] = React.useState<ITrainingMaterialDetail>({
|
||||
referenceId: '',
|
||||
|
||||
Reference in New Issue
Block a user