import React, { ReactElement, useEffect } from 'react';
import Head from 'next/head'
import DatePicker from "react-datepicker";
import "react-datepicker/dist/react-datepicker.css";
import dayjs from "dayjs";
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
import {useRouter} from "next/router";
import { fetch } from '../../stores/files/filesSlice'
import {saveFile} from "../../helpers/fileSaver";
import dataFormatter from '../../helpers/dataFormatter';
import ImageField from "../../components/ImageField";
import LayoutAuthenticated from "../../layouts/Authenticated";
import {getPageTitle} from "../../config";
import SectionTitleLineWithButton from "../../components/SectionTitleLineWithButton";
import SectionMain from "../../components/SectionMain";
import CardBox from "../../components/CardBox";
import BaseButton from "../../components/BaseButton";
import BaseDivider from "../../components/BaseDivider";
import {mdiChartTimelineVariant} from "@mdi/js";
import {SwitchField} from "../../components/SwitchField";
import FormField from "../../components/FormField";


const FilesView = () => {
    const router = useRouter()
    const dispatch = useAppDispatch()
    const { files } = useAppSelector((state) => state.files)
    

    const { id } = router.query;
    
    function removeLastCharacter(str) {
      console.log(str,`str`)
      return str.slice(0, -1);
    }

    useEffect(() => {
        dispatch(fetch({ id }));
    }, [dispatch, id]);


    return (
      <>
          <Head>
              <title>{getPageTitle('View files')}</title>
          </Head>
          <SectionMain>
            <SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View files')} main>
                <BaseButton
                  color='info'
                  label='Edit'
                  href={`/files/files-edit/?id=${id}`}
                />
            </SectionTitleLineWithButton>
            <CardBox>
            

              

              

              

              

              

              

              

              

              

              
              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Owner</p>
                    
                    
                        <p>{files?.owner?.firstName ?? 'No data'}</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                </div>
                 
              

              

              

              
              

              

              

              

              

              

              

              

              

              

              
              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Matter</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                        <p>{files?.matter?.title ?? 'No data'}</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                </div>
                 
              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>FileName</p>
                    <p>{files?.file_name}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>ContentType</p>
                    <p>{files?.content_type}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>FileExtension</p>
                    <p>{files?.file_extension}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>SizeBytes</p>
                  <p>{files?.size_bytes || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>StorageProvider</p>
                    <p>{files?.storage_provider}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>StorageKey</p>
                    <p>{files?.storage_key}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>ChecksumSha256</p>
                    <p>{files?.checksum_sha256}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

              
                <FormField label='IsOcrRequired'>
                    <SwitchField
                      field={{name: 'is_ocr_required', value: files?.is_ocr_required}}
                      form={{setFieldValue: () => null}}
                      disabled
                    />
                </FormField>
              

              

              

              

              
              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>ProcessingStatus</p>
                    <p>{files?.processing_status ?? 'No data'}</p>
                </div>
              

              

              

              

              

              
              

              

              

              

              

              

              
                <FormField label='UploadedAt'>
                    {files.uploaded_at ? <DatePicker
                      dateFormat="yyyy-MM-dd hh:mm"
                      showTimeSelect
                      selected={files.uploaded_at ?
                        new Date(
                          dayjs(files.uploaded_at).format('YYYY-MM-DD hh:mm'),
                        ) : null
                      }
                      disabled
                    /> : <p>No UploadedAt</p>}
                </FormField>
              

              

              

              

              

              

              

              
              

              

              
                <FormField label='Multi Text' hasTextareaHeight>
                  <textarea className={'w-full'} disabled value={files?.tags} />
                </FormField>
              

              

              

              

              

              

              

              

              

              

              

              
              

                
                
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>File_extractions File</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ExtractionType</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Language</th>
                                
                                
                                
                                <th>PageCount</th>
                                
                                
                                
                                <th>ResultText</th>
                                
                                
                                
                                <th>StartedAt</th>
                                
                                
                                
                                <th>FinishedAt</th>
                                
                                
                                
                                <th>ErrorMessage</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {files.file_extractions_file && Array.isArray(files.file_extractions_file) &&
                              files.file_extractions_file.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/file_extractions/file_extractions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="extraction_type">
                                        { item.extraction_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="language">
                                        { item.language }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="page_count">
                                        { item.page_count }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="result_text">
                                        { item.result_text }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="started_at">
                                        { dataFormatter.dateTimeFormatter(item.started_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="finished_at">
                                        { dataFormatter.dateTimeFormatter(item.finished_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="error_message">
                                        { item.error_message }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!files?.file_extractions_file?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Ai_jobs File</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>JobType</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>InputSummary</th>
                                
                                
                                
                                <th>OutputSummary</th>
                                
                                
                                
                                <th>CostUSD</th>
                                
                                
                                
                                <th>QueuedAt</th>
                                
                                
                                
                                <th>StartedAt</th>
                                
                                
                                
                                <th>CompletedAt</th>
                                
                                
                                
                                <th>ErrorMessage</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {files.ai_jobs_file && Array.isArray(files.ai_jobs_file) &&
                              files.ai_jobs_file.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/ai_jobs/ai_jobs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="job_type">
                                        { item.job_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="input_summary">
                                        { item.input_summary }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="output_summary">
                                        { item.output_summary }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="cost_usd">
                                        { item.cost_usd }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="queued_at">
                                        { dataFormatter.dateTimeFormatter(item.queued_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="started_at">
                                        { dataFormatter.dateTimeFormatter(item.started_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="completed_at">
                                        { dataFormatter.dateTimeFormatter(item.completed_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="error_message">
                                        { item.error_message }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!files?.ai_jobs_file?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Legal_templates SourceFile</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>TemplateName</th>
                                
                                
                                
                                <th>TemplateCategory</th>
                                
                                
                                
                                <th>Jurisdiction</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>IsPublic</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {files.legal_templates_source_file && Array.isArray(files.legal_templates_source_file) &&
                              files.legal_templates_source_file.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/legal_templates/legal_templates-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="template_name">
                                        { item.template_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="template_category">
                                        { item.template_category }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="jurisdiction">
                                        { item.jurisdiction }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="is_public">
                                        { dataFormatter.booleanFormatter(item.is_public) }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!files?.legal_templates_source_file?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Generated_documents ExportFile</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>DocumentTitle</th>
                                
                                
                                
                                <th>DocumentType</th>
                                
                                
                                
                                <th>Format</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>LastEditedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {files.generated_documents_export_file && Array.isArray(files.generated_documents_export_file) &&
                              files.generated_documents_export_file.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/generated_documents/generated_documents-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="document_title">
                                        { item.document_title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="document_type">
                                        { item.document_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="format">
                                        { item.format }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="last_edited_at">
                                        { dataFormatter.dateTimeFormatter(item.last_edited_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!files?.generated_documents_export_file?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Mock_trial_turns AudioFile</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>TurnType</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>SpokenAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {files.mock_trial_turns_audio_file && Array.isArray(files.mock_trial_turns_audio_file) &&
                              files.mock_trial_turns_audio_file.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/mock_trial_turns/mock_trial_turns-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="turn_type">
                                        { item.turn_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="spoken_at">
                                        { dataFormatter.dateTimeFormatter(item.spoken_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!files?.mock_trial_turns_audio_file?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Transcription_jobs MediaFile</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>SourceLanguage</th>
                                
                                
                                
                                <th>TargetLanguage</th>
                                
                                
                                
                                <th>SpeakerDiarization</th>
                                
                                
                                
                                <th>ConfidenceAvg</th>
                                
                                
                                
                                <th>TranscriptText</th>
                                
                                
                                
                                <th>SummaryText</th>
                                
                                
                                
                                
                                
                                <th>StartedAt</th>
                                
                                
                                
                                <th>FinishedAt</th>
                                
                                
                                
                                <th>ErrorMessage</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {files.transcription_jobs_media_file && Array.isArray(files.transcription_jobs_media_file) &&
                              files.transcription_jobs_media_file.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/transcription_jobs/transcription_jobs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="source_language">
                                        { item.source_language }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="target_language">
                                        { item.target_language }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="speaker_diarization">
                                        { dataFormatter.booleanFormatter(item.speaker_diarization) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="confidence_avg">
                                        { item.confidence_avg }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="transcript_text">
                                        { item.transcript_text }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="summary_text">
                                        { item.summary_text }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="started_at">
                                        { dataFormatter.dateTimeFormatter(item.started_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="finished_at">
                                        { dataFormatter.dateTimeFormatter(item.finished_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="error_message">
                                        { item.error_message }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!files?.transcription_jobs_media_file?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                <>
                    <p className={'block font-bold mb-2'}>Transcription_jobs ExportFile</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>SourceLanguage</th>
                                
                                
                                
                                <th>TargetLanguage</th>
                                
                                
                                
                                <th>SpeakerDiarization</th>
                                
                                
                                
                                <th>ConfidenceAvg</th>
                                
                                
                                
                                <th>TranscriptText</th>
                                
                                
                                
                                <th>SummaryText</th>
                                
                                
                                
                                
                                
                                <th>StartedAt</th>
                                
                                
                                
                                <th>FinishedAt</th>
                                
                                
                                
                                <th>ErrorMessage</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {files.transcription_jobs_export_file && Array.isArray(files.transcription_jobs_export_file) &&
                              files.transcription_jobs_export_file.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/transcription_jobs/transcription_jobs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="source_language">
                                        { item.source_language }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="target_language">
                                        { item.target_language }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="speaker_diarization">
                                        { dataFormatter.booleanFormatter(item.speaker_diarization) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="confidence_avg">
                                        { item.confidence_avg }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="transcript_text">
                                        { item.transcript_text }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="summary_text">
                                        { item.summary_text }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="started_at">
                                        { dataFormatter.dateTimeFormatter(item.started_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="finished_at">
                                        { dataFormatter.dateTimeFormatter(item.finished_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="error_message">
                                        { item.error_message }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!files?.transcription_jobs_export_file?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Medical_chronology_reports ExportFile</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>ReportTitle</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>GeneratedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {files.medical_chronology_reports_export_file && Array.isArray(files.medical_chronology_reports_export_file) &&
                              files.medical_chronology_reports_export_file.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/medical_chronology_reports/medical_chronology_reports-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="report_title">
                                        { item.report_title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="generated_at">
                                        { dataFormatter.dateTimeFormatter(item.generated_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!files?.medical_chronology_reports_export_file?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Medical_events LinkedFile</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>EventAt</th>
                                
                                
                                
                                <th>ProviderName</th>
                                
                                
                                
                                <th>FacilityName</th>
                                
                                
                                
                                <th>Diagnoses</th>
                                
                                
                                
                                <th>Icd10Codes</th>
                                
                                
                                
                                <th>Procedures</th>
                                
                                
                                
                                <th>Medications</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {files.medical_events_linked_file && Array.isArray(files.medical_events_linked_file) &&
                              files.medical_events_linked_file.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/medical_events/medical_events-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="event_at">
                                        { dataFormatter.dateTimeFormatter(item.event_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="provider_name">
                                        { item.provider_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="facility_name">
                                        { item.facility_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="diagnoses">
                                        { item.diagnoses }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="icd10_codes">
                                        { item.icd10_codes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="procedures">
                                        { item.procedures }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="medications">
                                        { item.medications }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!files?.medical_events_linked_file?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Causation_analyses ExportFile</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>AnalysisTitle</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>GeneratedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {files.causation_analyses_export_file && Array.isArray(files.causation_analyses_export_file) &&
                              files.causation_analyses_export_file.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/causation_analyses/causation_analyses-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="analysis_title">
                                        { item.analysis_title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="generated_at">
                                        { dataFormatter.dateTimeFormatter(item.generated_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!files?.causation_analyses_export_file?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                

                <BaseDivider />

                <BaseButton
                    color='info'
                    label='Back'
                    onClick={() => router.push('/files/files-list')}
                />
              </CardBox>
          </SectionMain>
      </>
    );
};

FilesView.getLayout = function getLayout(page: ReactElement) {
    return (
      <LayoutAuthenticated
        
        permission={'READ_FILES'}
        
      >
          {page}
      </LayoutAuthenticated>
    )
}

export default FilesView;