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/city_doctors/city_doctorsSlice'
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 City_doctorsView = () => {
    const router = useRouter()
    const dispatch = useAppDispatch()
    const { city_doctors } = useAppSelector((state) => state.city_doctors)
    

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

              

              

              

              

              

              

              

              

              

              
              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>User</p>
                    
                    
                        <p>{city_doctors?.user?.firstName ?? 'No data'}</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                </div>
                 
              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>FullName</p>
                    <p>{city_doctors?.full_name}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>HospitalCode</p>
                    <p>{city_doctors?.hospital_code}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>DoctorRegistrationNo</p>
                    <p>{city_doctors?.doctor_registration_no}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Specialization</p>
                    <p>{city_doctors?.specialization}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>YearsExperience</p>
                  <p>{city_doctors?.years_experience || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Qualification</p>
                    <p>{city_doctors?.qualification}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>AvailabilityStatus</p>
                    <p>{city_doctors?.availability_status ?? 'No data'}</p>
                </div>
              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>ConsultationFee</p>
                  <p>{city_doctors?.consultation_fee || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>ClinicAddress</p>
                    <p>{city_doctors?.clinic_address}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>ClinicLatitude</p>
                  <p>{city_doctors?.clinic_latitude || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>ClinicLongitude</p>
                  <p>{city_doctors?.clinic_longitude || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

                
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Medical_reports AuthorCityDoctor</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>ReportDate</th>
                                
                                
                                
                                <th>ReportType</th>
                                
                                
                                
                                <th>ChiefComplaint</th>
                                
                                
                                
                                <th>Symptoms</th>
                                
                                
                                
                                <th>Diagnosis</th>
                                
                                
                                
                                <th>ClinicalNotes</th>
                                
                                
                                
                                <th>PrescriptionNotes</th>
                                
                                
                                
                                <th>RecommendedTests</th>
                                
                                
                                
                                
                                
                                <th>IsFinalized</th>
                                
                                
                                
                                <th>FinalizedAt</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {city_doctors.medical_reports_author_city_doctor && Array.isArray(city_doctors.medical_reports_author_city_doctor) &&
                              city_doctors.medical_reports_author_city_doctor.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/medical_reports/medical_reports-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="report_date">
                                        { dataFormatter.dateTimeFormatter(item.report_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="report_type">
                                        { item.report_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="chief_complaint">
                                        { item.chief_complaint }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="symptoms">
                                        { item.symptoms }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="diagnosis">
                                        { item.diagnosis }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="clinical_notes">
                                        { item.clinical_notes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="prescription_notes">
                                        { item.prescription_notes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="recommended_tests">
                                        { item.recommended_tests }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="is_finalized">
                                        { dataFormatter.booleanFormatter(item.is_finalized) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="finalized_at">
                                        { dataFormatter.dateTimeFormatter(item.finalized_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!city_doctors?.medical_reports_author_city_doctor?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Medicine_dispatches CoordinatedByCityDoctor</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>RequestedAt</th>
                                
                                
                                
                                <th>ApprovedAt</th>
                                
                                
                                
                                <th>DispatchedAt</th>
                                
                                
                                
                                <th>DeliveredAt</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>DispatchNote</th>
                                
                                
                                
                                <th>DestinationAddress</th>
                                
                                
                                
                                <th>DestinationLatitude</th>
                                
                                
                                
                                <th>DestinationLongitude</th>
                                
                                
                                
                                <th>TrackingReference</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {city_doctors.medicine_dispatches_coordinated_by_city_doctor && Array.isArray(city_doctors.medicine_dispatches_coordinated_by_city_doctor) &&
                              city_doctors.medicine_dispatches_coordinated_by_city_doctor.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/medicine_dispatches/medicine_dispatches-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="requested_at">
                                        { dataFormatter.dateTimeFormatter(item.requested_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="approved_at">
                                        { dataFormatter.dateTimeFormatter(item.approved_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="dispatched_at">
                                        { dataFormatter.dateTimeFormatter(item.dispatched_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="delivered_at">
                                        { dataFormatter.dateTimeFormatter(item.delivered_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="dispatch_note">
                                        { item.dispatch_note }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="destination_address">
                                        { item.destination_address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="destination_latitude">
                                        { item.destination_latitude }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="destination_longitude">
                                        { item.destination_longitude }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tracking_reference">
                                        { item.tracking_reference }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!city_doctors?.medicine_dispatches_coordinated_by_city_doctor?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Medical_camps LeadCityDoctor</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>CampName</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>StartAt</th>
                                
                                
                                
                                <th>EndAt</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>LocationName</th>
                                
                                
                                
                                <th>Address</th>
                                
                                
                                
                                <th>Latitude</th>
                                
                                
                                
                                <th>Longitude</th>
                                
                                
                                
                                <th>ExpectedAttendees</th>
                                
                                
                                
                                <th>ActualAttendees</th>
                                
                                
                                
                                <th>ServicesOffered</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {city_doctors.medical_camps_lead_city_doctor && Array.isArray(city_doctors.medical_camps_lead_city_doctor) &&
                              city_doctors.medical_camps_lead_city_doctor.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/medical_camps/medical_camps-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="camp_name">
                                        { item.camp_name }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="start_at">
                                        { dataFormatter.dateTimeFormatter(item.start_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="end_at">
                                        { dataFormatter.dateTimeFormatter(item.end_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="location_name">
                                        { item.location_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="address">
                                        { item.address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="latitude">
                                        { item.latitude }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="longitude">
                                        { item.longitude }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="expected_attendees">
                                        { item.expected_attendees }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="actual_attendees">
                                        { item.actual_attendees }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="services_offered">
                                        { item.services_offered }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!city_doctors?.medical_camps_lead_city_doctor?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Appointments CityDoctor</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>ScheduledStartAt</th>
                                
                                
                                
                                <th>ScheduledEndAt</th>
                                
                                
                                
                                <th>AppointmentType</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>ReasonForVisit</th>
                                
                                
                                
                                <th>MeetingLink</th>
                                
                                
                                
                                <th>MeetingRoom</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {city_doctors.appointments_city_doctor && Array.isArray(city_doctors.appointments_city_doctor) &&
                              city_doctors.appointments_city_doctor.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/appointments/appointments-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="scheduled_start_at">
                                        { dataFormatter.dateTimeFormatter(item.scheduled_start_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="scheduled_end_at">
                                        { dataFormatter.dateTimeFormatter(item.scheduled_end_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="appointment_type">
                                        { item.appointment_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reason_for_visit">
                                        { item.reason_for_visit }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="meeting_link">
                                        { item.meeting_link }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="meeting_room">
                                        { item.meeting_room }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!city_doctors?.appointments_city_doctor?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                
                
                
                
                
                

                <BaseDivider />

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

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

export default City_doctorsView;