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/locations/locationsSlice'
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 LocationsView = () => {
    const router = useRouter()
    const dispatch = useAppDispatch()
    const { locations } = useAppSelector((state) => state.locations)
    

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

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

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>LocationKind</p>
                    <p>{locations?.location_kind ?? 'No data'}</p>
                </div>
              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

              

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

              

              

              
              

              

              

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

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>Latitude</p>
                  <p>{locations?.latitude || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>Longitude</p>
                  <p>{locations?.longitude || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

              

              

              

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

              
              

              

              

              

              

              

              

              

              

              
                <FormField label='IsLocked'>
                    <SwitchField
                      field={{name: 'is_locked', value: locations?.is_locked}}
                      form={{setFieldValue: () => null}}
                      disabled
                    />
                </FormField>
              

              

              

              

              
              

                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Player_profiles HomeLocation</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Gender</th>
                                
                                
                                
                                <th>FirstName</th>
                                
                                
                                
                                <th>LastName</th>
                                
                                
                                
                                <th>StartedAt</th>
                                
                                
                                
                                <th>Level</th>
                                
                                
                                
                                <th>ExperiencePoints</th>
                                
                                
                                
                                <th>MoneyBalance</th>
                                
                                
                                
                                <th>PIXBalance</th>
                                
                                
                                
                                <th>CommunityReputation</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {locations.player_profiles_home_location && Array.isArray(locations.player_profiles_home_location) &&
                              locations.player_profiles_home_location.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/player_profiles/player_profiles-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="gender">
                                        { item.gender }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="first_name">
                                        { item.first_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="last_name">
                                        { item.last_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="started_at">
                                        { dataFormatter.dateTimeFormatter(item.started_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="level">
                                        { item.level }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="experience_points">
                                        { item.experience_points }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="money_balance">
                                        { item.money_balance }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="pix_balance">
                                        { item.pix_balance }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reputation_score">
                                        { item.reputation_score }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!locations?.player_profiles_home_location?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Npcs HomeLocation</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>Name</th>
                                
                                
                                
                                <th>Age</th>
                                
                                
                                
                                <th>Profession</th>
                                
                                
                                
                                <th>Personality</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>EmotionState</th>
                                
                                
                                
                                
                                
                                <th>IsMainCharacter</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {locations.npcs_home_location && Array.isArray(locations.npcs_home_location) &&
                              locations.npcs_home_location.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/npcs/npcs-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="age">
                                        { item.age }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="profession">
                                        { item.profession }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="personality">
                                        { item.personality }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="emotion_state">
                                        { item.emotion_state }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="is_main_character">
                                        { dataFormatter.booleanFormatter(item.is_main_character) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!locations?.npcs_home_location?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                <>
                    <p className={'block font-bold mb-2'}>Npcs WorkLocation</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>Name</th>
                                
                                
                                
                                <th>Age</th>
                                
                                
                                
                                <th>Profession</th>
                                
                                
                                
                                <th>Personality</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>EmotionState</th>
                                
                                
                                
                                
                                
                                <th>IsMainCharacter</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {locations.npcs_work_location && Array.isArray(locations.npcs_work_location) &&
                              locations.npcs_work_location.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/npcs/npcs-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="age">
                                        { item.age }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="profession">
                                        { item.profession }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="personality">
                                        { item.personality }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="emotion_state">
                                        { item.emotion_state }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="is_main_character">
                                        { dataFormatter.booleanFormatter(item.is_main_character) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!locations?.npcs_work_location?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Families HomeLocation</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>Name</th>
                                
                                
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {locations.families_home_location && Array.isArray(locations.families_home_location) &&
                              locations.families_home_location.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/families/families-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!locations?.families_home_location?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Quests StartLocation</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>Title</th>
                                
                                
                                
                                <th>QuestType</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>AvailableFrom</th>
                                
                                
                                
                                <th>AvailableUntil</th>
                                
                                
                                
                                <th>RewardMoney</th>
                                
                                
                                
                                <th>RewardReputation</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {locations.quests_start_location && Array.isArray(locations.quests_start_location) &&
                              locations.quests_start_location.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/quests/quests-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="quest_type">
                                        { item.quest_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="available_from">
                                        { dataFormatter.dateTimeFormatter(item.available_from) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="available_until">
                                        { dataFormatter.dateTimeFormatter(item.available_until) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reward_money">
                                        { item.reward_money }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reward_reputation">
                                        { item.reward_reputation }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!locations?.quests_start_location?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                <>
                    <p className={'block font-bold mb-2'}>Quests EndLocation</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>Title</th>
                                
                                
                                
                                <th>QuestType</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>AvailableFrom</th>
                                
                                
                                
                                <th>AvailableUntil</th>
                                
                                
                                
                                <th>RewardMoney</th>
                                
                                
                                
                                <th>RewardReputation</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {locations.quests_end_location && Array.isArray(locations.quests_end_location) &&
                              locations.quests_end_location.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/quests/quests-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="quest_type">
                                        { item.quest_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="available_from">
                                        { dataFormatter.dateTimeFormatter(item.available_from) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="available_until">
                                        { dataFormatter.dateTimeFormatter(item.available_until) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reward_money">
                                        { item.reward_money }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reward_reputation">
                                        { item.reward_reputation }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!locations?.quests_end_location?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Quest_objectives TargetLocation</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ObjectiveType</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>TargetQuantity</th>
                                
                                
                                
                                <th>SequenceOrder</th>
                                
                                
                                
                                <th>IsOptional</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {locations.quest_objectives_target_location && Array.isArray(locations.quest_objectives_target_location) &&
                              locations.quest_objectives_target_location.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/quest_objectives/quest_objectives-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="objective_type">
                                        { item.objective_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="target_quantity">
                                        { item.target_quantity }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sequence_order">
                                        { item.sequence_order }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_optional">
                                        { dataFormatter.booleanFormatter(item.is_optional) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!locations?.quest_objectives_target_location?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Market_stores Location</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>Name</th>
                                
                                
                                
                                
                                
                                <th>StoreStatus</th>
                                
                                
                                
                                <th>OpenedAt</th>
                                
                                
                                
                                <th>ClosedAt</th>
                                
                                
                                
                                <th>CashBalance</th>
                                
                                
                                
                                <th>PIXBalance</th>
                                
                                
                                
                                <th>CardBalance</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {locations.market_stores_location && Array.isArray(locations.market_stores_location) &&
                              locations.market_stores_location.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/market_stores/market_stores-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="store_status">
                                        { item.store_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="opened_at">
                                        { dataFormatter.dateTimeFormatter(item.opened_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="closed_at">
                                        { dataFormatter.dateTimeFormatter(item.closed_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="cash_balance">
                                        { item.cash_balance }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="pix_balance">
                                        { item.pix_balance }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="card_balance">
                                        { item.card_balance }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!locations?.market_stores_location?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Suppliers Location</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>Name</th>
                                
                                
                                
                                <th>SupplierType</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>ReliabilityScore</th>
                                
                                
                                
                                <th>IsActive</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {locations.suppliers_location && Array.isArray(locations.suppliers_location) &&
                              locations.suppliers_location.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/suppliers/suppliers-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="supplier_type">
                                        { item.supplier_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="reliability_score">
                                        { item.reliability_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!locations?.suppliers_location?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Shelves Location</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Name</th>
                                
                                
                                
                                <th>ShelfType</th>
                                
                                
                                
                                <th>CapacityUnits</th>
                                
                                
                                
                                
                                
                                <th>IsCustomerAccessible</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {locations.shelves_location && Array.isArray(locations.shelves_location) &&
                              locations.shelves_location.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/shelves/shelves-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="shelf_type">
                                        { item.shelf_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="capacity_units">
                                        { item.capacity_units }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="is_customer_accessible">
                                        { dataFormatter.booleanFormatter(item.is_customer_accessible) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!locations?.shelves_location?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Farm_plots Location</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Name</th>
                                
                                
                                
                                <th>WidthTiles</th>
                                
                                
                                
                                <th>HeightTiles</th>
                                
                                
                                
                                <th>IsIrrigated</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {locations.farm_plots_location && Array.isArray(locations.farm_plots_location) &&
                              locations.farm_plots_location.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/farm_plots/farm_plots-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="width_tiles">
                                        { item.width_tiles }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="height_tiles">
                                        { item.height_tiles }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_irrigated">
                                        { dataFormatter.booleanFormatter(item.is_irrigated) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!locations?.farm_plots_location?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Fishing_spots Location</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>Name</th>
                                
                                
                                
                                
                                
                                <th>WaterType</th>
                                
                                
                                
                                <th>DifficultyRating</th>
                                
                                
                                
                                <th>IsTournamentSite</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {locations.fishing_spots_location && Array.isArray(locations.fishing_spots_location) &&
                              locations.fishing_spots_location.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/fishing_spots/fishing_spots-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="water_type">
                                        { item.water_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="difficulty_rating">
                                        { item.difficulty_rating }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_tournament_site">
                                        { dataFormatter.booleanFormatter(item.is_tournament_site) }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!locations?.fishing_spots_location?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Crafting_recipes RequiredStationLocation</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>Name</th>
                                
                                
                                
                                <th>RecipeType</th>
                                
                                
                                
                                
                                
                                <th>OutputQuantity</th>
                                
                                
                                
                                <th>CraftTimeSeconds</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {locations.crafting_recipes_required_station_location && Array.isArray(locations.crafting_recipes_required_station_location) &&
                              locations.crafting_recipes_required_station_location.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/crafting_recipes/crafting_recipes-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="recipe_type">
                                        { item.recipe_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="output_quantity">
                                        { item.output_quantity }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="craft_time_seconds">
                                        { item.craft_time_seconds }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!locations?.crafting_recipes_required_station_location?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Buildings Location</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>Name</th>
                                
                                
                                
                                
                                
                                <th>BuildingType</th>
                                
                                
                                
                                <th>ConditionState</th>
                                
                                
                                
                                <th>UpgradeLevel</th>
                                
                                
                                
                                <th>RestoredAt</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {locations.buildings_location && Array.isArray(locations.buildings_location) &&
                              locations.buildings_location.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/buildings/buildings-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="building_type">
                                        { item.building_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="condition_state">
                                        { item.condition_state }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="upgrade_level">
                                        { item.upgrade_level }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="restored_at">
                                        { dataFormatter.dateTimeFormatter(item.restored_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!locations?.buildings_location?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Festivals Location</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>Name</th>
                                
                                
                                
                                
                                
                                <th>StartsAt</th>
                                
                                
                                
                                <th>EndsAt</th>
                                
                                
                                
                                <th>FestivalType</th>
                                
                                
                                
                                
                                
                                <th>IsActive</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {locations.festivals_location && Array.isArray(locations.festivals_location) &&
                              locations.festivals_location.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/festivals/festivals-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="starts_at">
                                        { dataFormatter.dateTimeFormatter(item.starts_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ends_at">
                                        { dataFormatter.dateTimeFormatter(item.ends_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="festival_type">
                                        { item.festival_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!locations?.festivals_location?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                

                <BaseDivider />

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

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

export default LocationsView;