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/matters/mattersSlice'
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 MattersView = () => {
    const router = useRouter()
    const dispatch = useAppDispatch()
    const { matters } = useAppSelector((state) => state.matters)
    

    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 matters')}</title>
          </Head>
          <SectionMain>
            <SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View matters')} main>
                <BaseButton
                  color='info'
                  label='Edit'
                  href={`/matters/matters-edit/?id=${id}`}
                />
            </SectionTitleLineWithButton>
            <CardBox>
            

              

              

              

              

              

              

              

              

              

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

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Title</p>
                    <p>{matters?.title}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>MatterType</p>
                    <p>{matters?.matter_type ?? 'No data'}</p>
                </div>
              

              

              

              

              

              
              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Status</p>
                    <p>{matters?.status ?? 'No data'}</p>
                </div>
              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Jurisdiction</p>
                    <p>{matters?.jurisdiction}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>CourtName</p>
                    <p>{matters?.court_name}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>CaseNumber</p>
                    <p>{matters?.case_number}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

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

              

              

              

              

              

              

              
              

              

              

              

              

              

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

              

              

              

              

              

              

              
              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>Notes</p>
                  {matters.notes
                    ? <p dangerouslySetInnerHTML={{__html: matters.notes}}/>
                    : <p>No data</p>
                  }
                </div>
              

              

              

              

              

              

              

              

              

              

              
              

                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Matter_parties Matter</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>PartyRole</th>
                                
                                
                                
                                <th>DisplayName</th>
                                
                                
                                
                                <th>OrganizationName</th>
                                
                                
                                
                                <th>Email</th>
                                
                                
                                
                                <th>Phone</th>
                                
                                
                                
                                <th>Address</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {matters.matter_parties_matter && Array.isArray(matters.matter_parties_matter) &&
                              matters.matter_parties_matter.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/matter_parties/matter_parties-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="party_role">
                                        { item.party_role }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="display_name">
                                        { item.display_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="organization_name">
                                        { item.organization_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="email">
                                        { item.email }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="phone">
                                        { item.phone }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="address">
                                        { item.address }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!matters?.matter_parties_matter?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Files Matter</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>FileName</th>
                                
                                
                                
                                <th>ContentType</th>
                                
                                
                                
                                <th>FileExtension</th>
                                
                                
                                
                                <th>SizeBytes</th>
                                
                                
                                
                                <th>StorageProvider</th>
                                
                                
                                
                                <th>StorageKey</th>
                                
                                
                                
                                <th>ChecksumSha256</th>
                                
                                
                                
                                <th>IsOcrRequired</th>
                                
                                
                                
                                <th>ProcessingStatus</th>
                                
                                
                                
                                <th>UploadedAt</th>
                                
                                
                                
                                <th>Tags</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {matters.files_matter && Array.isArray(matters.files_matter) &&
                              matters.files_matter.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/files/files-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="file_name">
                                        { item.file_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="content_type">
                                        { item.content_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="file_extension">
                                        { item.file_extension }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="size_bytes">
                                        { item.size_bytes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="storage_provider">
                                        { item.storage_provider }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="storage_key">
                                        { item.storage_key }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="checksum_sha256">
                                        { item.checksum_sha256 }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_ocr_required">
                                        { dataFormatter.booleanFormatter(item.is_ocr_required) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="processing_status">
                                        { item.processing_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="uploaded_at">
                                        { dataFormatter.dateTimeFormatter(item.uploaded_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tags">
                                        { item.tags }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!matters?.files_matter?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Assistant_threads Matter</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Title</th>
                                
                                
                                
                                <th>ThreadScope</th>
                                
                                
                                
                                <th>IsPinned</th>
                                
                                
                                
                                <th>LastActivityAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {matters.assistant_threads_matter && Array.isArray(matters.assistant_threads_matter) &&
                              matters.assistant_threads_matter.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/assistant_threads/assistant_threads-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="thread_scope">
                                        { item.thread_scope }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_pinned">
                                        { dataFormatter.booleanFormatter(item.is_pinned) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="last_activity_at">
                                        { dataFormatter.dateTimeFormatter(item.last_activity_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!matters?.assistant_threads_matter?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Ai_jobs Matter</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>
                            {matters.ai_jobs_matter && Array.isArray(matters.ai_jobs_matter) &&
                              matters.ai_jobs_matter.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>
                        {!matters?.ai_jobs_matter?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Generated_documents Matter</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>
                            {matters.generated_documents_matter && Array.isArray(matters.generated_documents_matter) &&
                              matters.generated_documents_matter.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>
                        {!matters?.generated_documents_matter?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Research_queries Matter</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>QueryText</th>
                                
                                
                                
                                <th>Jurisdiction</th>
                                
                                
                                
                                <th>SourceScope</th>
                                
                                
                                
                                <th>SearchedAt</th>
                                
                                
                                
                                <th>FiltersJson</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {matters.research_queries_matter && Array.isArray(matters.research_queries_matter) &&
                              matters.research_queries_matter.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/research_queries/research_queries-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="query_text">
                                        { item.query_text }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="jurisdiction">
                                        { item.jurisdiction }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="source_scope">
                                        { item.source_scope }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="searched_at">
                                        { dataFormatter.dateTimeFormatter(item.searched_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="filters_json">
                                        { item.filters_json }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!matters?.research_queries_matter?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Citator_checks Matter</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Standing</th>
                                
                                
                                
                                <th>Analysis</th>
                                
                                
                                
                                <th>ConflictsSummary</th>
                                
                                
                                
                                <th>CheckedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {matters.citator_checks_matter && Array.isArray(matters.citator_checks_matter) &&
                              matters.citator_checks_matter.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/citator_checks/citator_checks-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="standing">
                                        { item.standing }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="analysis">
                                        { item.analysis }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="conflicts_summary">
                                        { item.conflicts_summary }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="checked_at">
                                        { dataFormatter.dateTimeFormatter(item.checked_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!matters?.citator_checks_matter?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Mock_trials Matter</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>SessionTitle</th>
                                
                                
                                
                                <th>Mode</th>
                                
                                
                                
                                <th>InputType</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>ScheduledAt</th>
                                
                                
                                
                                <th>StartedAt</th>
                                
                                
                                
                                <th>EndedAt</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {matters.mock_trials_matter && Array.isArray(matters.mock_trials_matter) &&
                              matters.mock_trials_matter.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/mock_trials/mock_trials-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="session_title">
                                        { item.session_title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="mode">
                                        { item.mode }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="input_type">
                                        { item.input_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="scheduled_at">
                                        { dataFormatter.dateTimeFormatter(item.scheduled_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="started_at">
                                        { dataFormatter.dateTimeFormatter(item.started_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ended_at">
                                        { dataFormatter.dateTimeFormatter(item.ended_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!matters?.mock_trials_matter?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Transcription_jobs Matter</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>
                            {matters.transcription_jobs_matter && Array.isArray(matters.transcription_jobs_matter) &&
                              matters.transcription_jobs_matter.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>
                        {!matters?.transcription_jobs_matter?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Medical_chronology_reports Matter</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>
                            {matters.medical_chronology_reports_matter && Array.isArray(matters.medical_chronology_reports_matter) &&
                              matters.medical_chronology_reports_matter.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>
                        {!matters?.medical_chronology_reports_matter?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Causation_analyses Matter</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>
                            {matters.causation_analyses_matter && Array.isArray(matters.causation_analyses_matter) &&
                              matters.causation_analyses_matter.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>
                        {!matters?.causation_analyses_matter?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Audit_events Matter</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>EventName</th>
                                
                                
                                
                                <th>EventCategory</th>
                                
                                
                                
                                <th>EventDetails</th>
                                
                                
                                
                                <th>OccurredAt</th>
                                
                                
                                
                                <th>IpAddress</th>
                                
                                
                                
                                <th>UserAgent</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {matters.audit_events_matter && Array.isArray(matters.audit_events_matter) &&
                              matters.audit_events_matter.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/audit_events/audit_events-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="event_name">
                                        { item.event_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="event_category">
                                        { item.event_category }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="event_details">
                                        { item.event_details }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="occurred_at">
                                        { dataFormatter.dateTimeFormatter(item.occurred_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ip_address">
                                        { item.ip_address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="user_agent">
                                        { item.user_agent }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!matters?.audit_events_matter?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                

                <BaseDivider />

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

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

export default MattersView;