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/restaurants/restaurantsSlice'
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 RestaurantsView = () => {
    const router = useRouter()
    const dispatch = useAppDispatch()
    const { restaurants } = useAppSelector((state) => state.restaurants)
    

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

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

              

              

              

              

              

              

              

              

              

              

              

              
              

              

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

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Contact</p>
                    <p>{restaurants?.contact_phone}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>Nombredemembresdupersonnel(prévu)</p>
                  <p>{restaurants?.staff_count_planned || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>Nombredetables</p>
                  <p>{restaurants?.table_count || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

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

              

              

              

              

              

              

              
              

              

              

              

              

              

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

              

              

              

              

              

              

              
              

              

              

              

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

              

              

              

              

              

              

              

              

              
              

              

              

              

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

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>Rayongéofence(mètres)</p>
                  <p>{restaurants?.geofence_radius_meters || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

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

              

              

              

              
              

                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Restaurant_tables Restaurant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Nom/Numérodetable</th>
                                
                                
                                
                                <th>Nombredeplaces</th>
                                
                                
                                
                                <th>DonnéesQR(payload)</th>
                                
                                
                                
                                
                                
                                <th>Disponible</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {restaurants.restaurant_tables_restaurant && Array.isArray(restaurants.restaurant_tables_restaurant) &&
                              restaurants.restaurant_tables_restaurant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/restaurant_tables/restaurant_tables-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="table_label">
                                        { item.table_label }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="seat_count">
                                        { item.seat_count }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="qr_payload">
                                        { item.qr_payload }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="is_available">
                                        { dataFormatter.booleanFormatter(item.is_available) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!restaurants?.restaurant_tables_restaurant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Work_schedules Restaurant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Titreplanning</th>
                                
                                
                                
                                <th>Débutpériode</th>
                                
                                
                                
                                <th>Finpériode</th>
                                
                                
                                
                                <th>Statut</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {restaurants.work_schedules_restaurant && Array.isArray(restaurants.work_schedules_restaurant) &&
                              restaurants.work_schedules_restaurant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/work_schedules/work_schedules-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="period_start">
                                        { dataFormatter.dateTimeFormatter(item.period_start) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="period_end">
                                        { dataFormatter.dateTimeFormatter(item.period_end) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!restaurants?.work_schedules_restaurant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Attendance_events Restaurant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Typed'évènement</th>
                                
                                
                                
                                <th>Dateetheure</th>
                                
                                
                                
                                <th>Latitude</th>
                                
                                
                                
                                <th>Longitude</th>
                                
                                
                                
                                <th>Distance(mètres)</th>
                                
                                
                                
                                <th>Horszoneautorisée</th>
                                
                                
                                
                                <th>Commentaire</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {restaurants.attendance_events_restaurant && Array.isArray(restaurants.attendance_events_restaurant) &&
                              restaurants.attendance_events_restaurant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/attendance_events/attendance_events-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="event_type">
                                        { item.event_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="event_time">
                                        { dataFormatter.dateTimeFormatter(item.event_time) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="latitude">
                                        { item.latitude }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="longitude">
                                        { item.longitude }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="distance_meters">
                                        { item.distance_meters }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="out_of_geofence">
                                        { dataFormatter.booleanFormatter(item.out_of_geofence) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="comment">
                                        { item.comment }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!restaurants?.attendance_events_restaurant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Geofence_alerts Restaurant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Distance(mètres)</th>
                                
                                
                                
                                <th>Latitude</th>
                                
                                
                                
                                <th>Longitude</th>
                                
                                
                                
                                <th>Date/heurealerte</th>
                                
                                
                                
                                <th>Sévérité</th>
                                
                                
                                
                                <th>Alerteacquittée</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {restaurants.geofence_alerts_restaurant && Array.isArray(restaurants.geofence_alerts_restaurant) &&
                              restaurants.geofence_alerts_restaurant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/geofence_alerts/geofence_alerts-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="distance_meters">
                                        { item.distance_meters }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="latitude">
                                        { item.latitude }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="longitude">
                                        { item.longitude }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="alert_time">
                                        { dataFormatter.dateTimeFormatter(item.alert_time) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="severity">
                                        { item.severity }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_acknowledged">
                                        { dataFormatter.booleanFormatter(item.is_acknowledged) }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!restaurants?.geofence_alerts_restaurant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Menu_categories Restaurant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Catégorie</th>
                                
                                
                                
                                <th>Type</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                                
                                <th>Ordred'affichage</th>
                                
                                
                                
                                <th>Active</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {restaurants.menu_categories_restaurant && Array.isArray(restaurants.menu_categories_restaurant) &&
                              restaurants.menu_categories_restaurant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/menu_categories/menu_categories-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="category_type">
                                        { item.category_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sort_order">
                                        { item.sort_order }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!restaurants?.menu_categories_restaurant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Menu_items Restaurant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Nomduplat/boisson</th>
                                
                                
                                
                                
                                
                                <th>Nature</th>
                                
                                
                                
                                <th>Prix</th>
                                
                                
                                
                                
                                
                                <th>Disponible</th>
                                
                                
                                
                                <th>Tempsdepréparation(min)</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {restaurants.menu_items_restaurant && Array.isArray(restaurants.menu_items_restaurant) &&
                              restaurants.menu_items_restaurant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/menu_items/menu_items-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="item_type">
                                        { item.item_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="price">
                                        { item.price }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="is_available">
                                        { dataFormatter.booleanFormatter(item.is_available) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="prep_time_minutes">
                                        { item.prep_time_minutes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!restaurants?.menu_items_restaurant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Orders Restaurant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Canal</th>
                                
                                
                                
                                <th>Mode</th>
                                
                                
                                
                                <th>Adressedelivraison</th>
                                
                                
                                
                                <th>Latitudelivraison</th>
                                
                                
                                
                                <th>Longitudelivraison</th>
                                
                                
                                
                                <th>Statutcommande</th>
                                
                                
                                
                                <th>Datedecommande</th>
                                
                                
                                
                                <th>Souhaitéepour</th>
                                
                                
                                
                                <th>Noteclient</th>
                                
                                
                                
                                <th>Sous-total</th>
                                
                                
                                
                                <th>Total</th>
                                
                                
                                
                                <th>Payée</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {restaurants.orders_restaurant && Array.isArray(restaurants.orders_restaurant) &&
                              restaurants.orders_restaurant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/orders/orders-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="order_channel">
                                        { item.order_channel }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="fulfillment_type">
                                        { item.fulfillment_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="delivery_address">
                                        { item.delivery_address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="delivery_latitude">
                                        { item.delivery_latitude }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="delivery_longitude">
                                        { item.delivery_longitude }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ordered_at">
                                        { dataFormatter.dateTimeFormatter(item.ordered_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="requested_for">
                                        { dataFormatter.dateTimeFormatter(item.requested_for) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="customer_note">
                                        { item.customer_note }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subtotal_amount">
                                        { item.subtotal_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="total_amount">
                                        { item.total_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_paid">
                                        { dataFormatter.booleanFormatter(item.is_paid) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!restaurants?.orders_restaurant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Reservations Restaurant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Débutréservation</th>
                                
                                
                                
                                <th>Finréservation</th>
                                
                                
                                
                                <th>Nombredepersonnes</th>
                                
                                
                                
                                <th>Statut</th>
                                
                                
                                
                                <th>Note</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {restaurants.reservations_restaurant && Array.isArray(restaurants.reservations_restaurant) &&
                              restaurants.reservations_restaurant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/reservations/reservations-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="start_time">
                                        { dataFormatter.dateTimeFormatter(item.start_time) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="end_time">
                                        { dataFormatter.dateTimeFormatter(item.end_time) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="party_size">
                                        { item.party_size }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="note">
                                        { item.note }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!restaurants?.reservations_restaurant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Payments Restaurant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Modedepaiement</th>
                                
                                
                                
                                <th>Statutpaiement</th>
                                
                                
                                
                                <th>Montant</th>
                                
                                
                                
                                <th>Datedepaiement</th>
                                
                                
                                
                                <th>Référenceprestataire</th>
                                
                                
                                
                                
                                
                                <th>Reçudepaiement(texte)</th>
                                
                                
                                
                                <th>Pointsgagnés</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {restaurants.payments_restaurant && Array.isArray(restaurants.payments_restaurant) &&
                              restaurants.payments_restaurant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/payments/payments-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="payment_method">
                                        { item.payment_method }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="amount">
                                        { item.amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="paid_at">
                                        { dataFormatter.dateTimeFormatter(item.paid_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="provider_reference">
                                        { item.provider_reference }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="receipt_text">
                                        { item.receipt_text }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="points_earned">
                                        { item.points_earned }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!restaurants?.payments_restaurant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Customer_reviews Restaurant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Note</th>
                                
                                
                                
                                <th>Commentaire</th>
                                
                                
                                
                                <th>Date/heure</th>
                                
                                
                                
                                <th>Publié</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {restaurants.customer_reviews_restaurant && Array.isArray(restaurants.customer_reviews_restaurant) &&
                              restaurants.customer_reviews_restaurant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/customer_reviews/customer_reviews-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="rating">
                                        { item.rating }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="comment">
                                        { item.comment }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reviewed_at">
                                        { dataFormatter.dateTimeFormatter(item.reviewed_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_published">
                                        { dataFormatter.booleanFormatter(item.is_published) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!restaurants?.customer_reviews_restaurant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Notification_events Restaurant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Typed'évènement</th>
                                
                                
                                
                                <th>Audience</th>
                                
                                
                                
                                <th>Naturecommande</th>
                                
                                
                                
                                <th>Quantitétotale</th>
                                
                                
                                
                                <th>Titre</th>
                                
                                
                                
                                <th>Message</th>
                                
                                
                                
                                <th>Date/heure</th>
                                
                                
                                
                                <th>Lu</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {restaurants.notification_events_restaurant && Array.isArray(restaurants.notification_events_restaurant) &&
                              restaurants.notification_events_restaurant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/notification_events/notification_events-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="event_type">
                                        { item.event_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="audience">
                                        { item.audience }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="order_nature">
                                        { item.order_nature }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="quantity_total">
                                        { item.quantity_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="message">
                                        { item.message }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="event_time">
                                        { dataFormatter.dateTimeFormatter(item.event_time) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_read">
                                        { dataFormatter.booleanFormatter(item.is_read) }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!restaurants?.notification_events_restaurant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Stock_locations Restaurant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Typedestock</th>
                                
                                
                                
                                <th>Nomemplacement</th>
                                
                                
                                
                                <th>Actif</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {restaurants.stock_locations_restaurant && Array.isArray(restaurants.stock_locations_restaurant) &&
                              restaurants.stock_locations_restaurant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/stock_locations/stock_locations-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="location_type">
                                        { item.location_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!restaurants?.stock_locations_restaurant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Stock_movements Restaurant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Typemouvement</th>
                                
                                
                                
                                <th>Quantité</th>
                                
                                
                                
                                <th>Date/heure</th>
                                
                                
                                
                                <th>Motif</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {restaurants.stock_movements_restaurant && Array.isArray(restaurants.stock_movements_restaurant) &&
                              restaurants.stock_movements_restaurant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/stock_movements/stock_movements-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="movement_type">
                                        { item.movement_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="quantity">
                                        { item.quantity }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="movement_time">
                                        { dataFormatter.dateTimeFormatter(item.movement_time) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reason">
                                        { item.reason }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!restaurants?.stock_movements_restaurant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Invoices Restaurant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Numérofacture</th>
                                
                                
                                
                                <th>Statutfacture</th>
                                
                                
                                
                                <th>Sous-total</th>
                                
                                
                                
                                <th>Total</th>
                                
                                
                                
                                <th>Dateémission</th>
                                
                                
                                
                                <th>Dateclôture</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {restaurants.invoices_restaurant && Array.isArray(restaurants.invoices_restaurant) &&
                              restaurants.invoices_restaurant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/invoices/invoices-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="invoice_number">
                                        { item.invoice_number }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subtotal_amount">
                                        { item.subtotal_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="total_amount">
                                        { item.total_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="issued_at">
                                        { dataFormatter.dateTimeFormatter(item.issued_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="closed_at">
                                        { dataFormatter.dateTimeFormatter(item.closed_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!restaurants?.invoices_restaurant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Audit_logs Restaurant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Action</th>
                                
                                
                                
                                <th>Entité</th>
                                
                                
                                
                                <th>Référenceentité</th>
                                
                                
                                
                                <th>Date/heure</th>
                                
                                
                                
                                <th>Détails</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {restaurants.audit_logs_restaurant && Array.isArray(restaurants.audit_logs_restaurant) &&
                              restaurants.audit_logs_restaurant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/audit_logs/audit_logs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="action">
                                        { item.action }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_name">
                                        { item.entity_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_ref">
                                        { item.entity_ref }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="action_time">
                                        { dataFormatter.dateTimeFormatter(item.action_time) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="details">
                                        { item.details }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!restaurants?.audit_logs_restaurant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                

                <BaseDivider />

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

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

export default RestaurantsView;