import React from 'react'; import {getHost} from '../../helpers/getHost' interface AccessReportProps { accessData: { pdf?: string; docx?: string; json?: string; }; chatBoxSettings: { report_type?: string; }; report: string; } const AccessReport: React.FC = ({ accessData, chatBoxSettings, report }) => { const host = getHost(); const getReportLink = (dataType: 'pdf' | 'docx' | 'json'): string => { // Early return if path is not available if (!accessData?.[dataType]) { console.warn(`No ${dataType} path provided`); return '#'; } const path = accessData[dataType] as string; // Clean the path - remove leading/trailing slashes and handle outputs/ prefix const cleanPath = path .trim() .replace(/^\/+|\/+$/g, ''); // Remove leading/trailing slashes // Only prepend outputs/ if it's not already there const finalPath = cleanPath.startsWith('outputs/') ? cleanPath : `outputs/${cleanPath}`; return `${host}/${finalPath}`; }; // Safety check for accessData if (!accessData || typeof accessData !== 'object') { return null; } return (
View as PDF Download DocX {chatBoxSettings?.report_type === 'research_report' && ( Download Logs )}
); }; export default AccessReport;