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/properties/propertiesSlice'
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";

import {hasPermission} from "../../helpers/userPermissions";


const PropertiesView = () => {
    const router = useRouter()
    const dispatch = useAppDispatch()
    const { properties } = useAppSelector((state) => state.properties)
    
    const { currentUser } = useAppSelector((state) => state.auth);
    

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

              

              

              

              

              

              

              

              

              

              
              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Tenant</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                        <p>{properties?.tenant?.name ?? 'No data'}</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                </div>
                 
              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Propertyname</p>
                    <p>{properties?.name}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Propertycode</p>
                    <p>{properties?.code}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

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

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>City</p>
                    <p>{properties?.city}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Country</p>
                    <p>{properties?.country}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Timezone</p>
                    <p>{properties?.timezone}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

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

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Images</p>
                    {properties?.images?.length
                      ? (
                        <ImageField
                          name={'images'}
                          image={properties?.images}
                          className='w-20 h-20'
                        />
                      ) : <p>No Images</p>
                    }
                </div>
              

              
              

              

              

              

              

              

              

              

              

              
                <FormField label='Isactive'>
                    <SwitchField
                      field={{name: 'is_active', value: properties?.is_active}}
                      form={{setFieldValue: () => null}}
                      disabled
                    />
                </FormField>
              

              

              

              

              
              

              

              

              

              

              

              

              

              

              

              

              
                <>
                    <p className={'block font-bold mb-2'}>Unittypes</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                    <th>Unittypename</th>
                                
                                
                                
                                    <th>Code</th>
                                
                                
                                
                                    <th>Maxoccupancy</th>
                                
                                
                                
                                    <th>Bedrooms</th>
                                
                                
                                
                                    <th>Bathrooms</th>
                                
                                
                                
                                    <th>Size(sqm)</th>
                                
                                
                                
                                
                                
                                    <th>Basenightlyrate</th>
                                
                                
                                
                                    <th>Basemonthlyrate</th>
                                
                                
                                
                                    <th>Minimumstay(nights)</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {properties.unit_types && Array.isArray(properties.unit_types) &&
                              properties.unit_types.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/unit_types/unit_types-view/?id=${item.id}`)}>
                                  
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                  
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="code">
                                        { item.code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="max_occupancy">
                                        { item.max_occupancy }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="bedrooms">
                                        { item.bedrooms }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="bathrooms">
                                        { item.bathrooms }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="size_sqm">
                                        { item.size_sqm }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="base_nightly_rate">
                                        { item.base_nightly_rate }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="base_monthly_rate">
                                        { item.base_monthly_rate }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="minimum_stay_nights">
                                        { item.minimum_stay_nights }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!properties?.unit_types?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
              

              

              
              

              

              

              

              

              

              

              

              

              

              

              
                <>
                    <p className={'block font-bold mb-2'}>Units</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                    <th>Unitnumber</th>
                                
                                
                                
                                    <th>Floor</th>
                                
                                
                                
                                    <th>Status</th>
                                
                                
                                
                                    <th>Maxoccupancyoverride</th>
                                
                                
                                
                                    <th>Notes</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {properties.units && Array.isArray(properties.units) &&
                              properties.units.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/units/units-view/?id=${item.id}`)}>
                                  
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                  
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="unit_number">
                                        { item.unit_number }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="floor">
                                        { item.floor }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="max_occupancy_override">
                                        { item.max_occupancy_override }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!properties?.units?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
              

              

              
              

              

              

              

              

              

              

              

              

              

              

              
                <>
                    <p className={'block font-bold mb-2'}>Amenities</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                    <th>Amenityname</th>
                                
                                
                                
                                    <th>Description</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {properties.amenities && Array.isArray(properties.amenities) &&
                              properties.amenities.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/amenities/amenities-view/?id=${item.id}`)}>
                                  
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                  
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!properties?.amenities?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
              

              

              
              

              

              

              

              

              

              

              

              

              

              
              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>organizations</p>
                    
                    
                    
                    
                    
                    
                    
                    
                        <p>{properties?.organizations?.name ?? 'No data'}</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                </div>
                 
              

              

              

              
              

                
                
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Amenities Property</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Amenityname</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {properties.amenities_property && Array.isArray(properties.amenities_property) &&
                              properties.amenities_property.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/amenities/amenities-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!properties?.amenities_property?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Unit_types Property</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Unittypename</th>
                                
                                
                                
                                <th>Code</th>
                                
                                
                                
                                <th>Maxoccupancy</th>
                                
                                
                                
                                <th>Bedrooms</th>
                                
                                
                                
                                <th>Bathrooms</th>
                                
                                
                                
                                <th>Size(sqm)</th>
                                
                                
                                
                                
                                
                                <th>Basenightlyrate</th>
                                
                                
                                
                                <th>Basemonthlyrate</th>
                                
                                
                                
                                <th>Minimumstay(nights)</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {properties.unit_types_property && Array.isArray(properties.unit_types_property) &&
                              properties.unit_types_property.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/unit_types/unit_types-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="code">
                                        { item.code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="max_occupancy">
                                        { item.max_occupancy }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="bedrooms">
                                        { item.bedrooms }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="bathrooms">
                                        { item.bathrooms }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="size_sqm">
                                        { item.size_sqm }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="base_nightly_rate">
                                        { item.base_nightly_rate }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="base_monthly_rate">
                                        { item.base_monthly_rate }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="minimum_stay_nights">
                                        { item.minimum_stay_nights }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!properties?.unit_types_property?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Units Property</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Unitnumber</th>
                                
                                
                                
                                <th>Floor</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Maxoccupancyoverride</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {properties.units_property && Array.isArray(properties.units_property) &&
                              properties.units_property.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/units/units-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="unit_number">
                                        { item.unit_number }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="floor">
                                        { item.floor }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="max_occupancy_override">
                                        { item.max_occupancy_override }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!properties?.units_property?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Negotiated_rates Property</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Ratetype</th>
                                
                                
                                
                                <th>Rateamount</th>
                                
                                
                                
                                <th>Validfrom</th>
                                
                                
                                
                                <th>Validuntil</th>
                                
                                
                                
                                <th>Minimumstay(nights)</th>
                                
                                
                                
                                <th>Isactive</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {properties.negotiated_rates_property && Array.isArray(properties.negotiated_rates_property) &&
                              properties.negotiated_rates_property.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/negotiated_rates/negotiated_rates-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="rate_type">
                                        { item.rate_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="rate_amount">
                                        { item.rate_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="valid_from">
                                        { dataFormatter.dateTimeFormatter(item.valid_from) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="valid_until">
                                        { dataFormatter.dateTimeFormatter(item.valid_until) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="minimum_stay_nights">
                                        { item.minimum_stay_nights }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!properties?.negotiated_rates_property?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Booking_requests Preferredproperty</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Requestcode</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Check-inat</th>
                                
                                
                                
                                <th>Check-outat</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>Preferredbedrooms</th>
                                
                                
                                
                                <th>Guestcount</th>
                                
                                
                                
                                <th>Purposeofstay</th>
                                
                                
                                
                                <th>Specialrequirements</th>
                                
                                
                                
                                <th>Budgetcode</th>
                                
                                
                                
                                <th>Maxbudgetamount</th>
                                
                                
                                
                                <th>Currency</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {properties.booking_requests_preferred_property && Array.isArray(properties.booking_requests_preferred_property) &&
                              properties.booking_requests_preferred_property.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/booking_requests/booking_requests-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="request_code">
                                        { item.request_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="check_in_at">
                                        { dataFormatter.dateTimeFormatter(item.check_in_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="check_out_at">
                                        { dataFormatter.dateTimeFormatter(item.check_out_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="preferred_bedrooms">
                                        { item.preferred_bedrooms }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="guest_count">
                                        { item.guest_count }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="purpose_of_stay">
                                        { item.purpose_of_stay }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="special_requirements">
                                        { item.special_requirements }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="budget_code">
                                        { item.budget_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="max_budget_amount">
                                        { item.max_budget_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!properties?.booking_requests_preferred_property?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Reservations Property</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Reservationcode</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Check-inat</th>
                                
                                
                                
                                <th>Check-outat</th>
                                
                                
                                
                                <th>Actualcheck-inat</th>
                                
                                
                                
                                <th>Actualcheck-outat</th>
                                
                                
                                
                                <th>Earlycheck-in</th>
                                
                                
                                
                                <th>Latecheck-out</th>
                                
                                
                                
                                <th>Guestcount</th>
                                
                                
                                
                                <th>Nightlyrate</th>
                                
                                
                                
                                <th>Monthlyrate</th>
                                
                                
                                
                                <th>Currency</th>
                                
                                
                                
                                <th>Internalnotes</th>
                                
                                
                                
                                <th>Externalnotes</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {properties.reservations_property && Array.isArray(properties.reservations_property) &&
                              properties.reservations_property.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/reservations/reservations-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="reservation_code">
                                        { item.reservation_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="check_in_at">
                                        { dataFormatter.dateTimeFormatter(item.check_in_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="check_out_at">
                                        { dataFormatter.dateTimeFormatter(item.check_out_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="actual_check_in_at">
                                        { dataFormatter.dateTimeFormatter(item.actual_check_in_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="actual_check_out_at">
                                        { dataFormatter.dateTimeFormatter(item.actual_check_out_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="early_check_in">
                                        { dataFormatter.booleanFormatter(item.early_check_in) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="late_check_out">
                                        { dataFormatter.booleanFormatter(item.late_check_out) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="guest_count">
                                        { item.guest_count }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="nightly_rate">
                                        { item.nightly_rate }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="monthly_rate">
                                        { item.monthly_rate }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="internal_notes">
                                        { item.internal_notes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="external_notes">
                                        { item.external_notes }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!properties?.reservations_property?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                
                
                
                
                
                
                
                

                <BaseDivider />

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

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

export default PropertiesView;