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/stores/storesSlice'
import {saveFile} from "../../helpers/fileSaver";
import dataFormatter from '../../helpers/dataFormatter';
import ImageField from "../../components/ImageField";
import LayoutAuthenticated from "../../layouts/Authenticated";
import {getPageTitle} from "../../config";
import SectionTitleLineWithButton from "../../components/SectionTitleLineWithButton";
import SectionMain from "../../components/SectionMain";
import CardBox from "../../components/CardBox";
import BaseButton from "../../components/BaseButton";
import BaseDivider from "../../components/BaseDivider";
import {mdiChartTimelineVariant} from "@mdi/js";
import {SwitchField} from "../../components/SwitchField";
import FormField from "../../components/FormField";

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


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

    const { id } = router.query;
    
    function removeLastCharacter(str) {
      console.log(str,`str`)
      return str.slice(0, -1);
    }

    useEffect(() => {
        dispatch(fetch({ id }));
    }, [dispatch, id]);


    return (
      <>
          <Head>
              <title>{getPageTitle('View stores')}</title>
          </Head>
          <SectionMain>
            <SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View stores')} main>
                <BaseButton
                  color='info'
                  label='Edit'
                  href={`/stores/stores-edit/?id=${id}`}
                />
            </SectionTitleLineWithButton>
            <CardBox>
            

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

              

              

              

              

              

              

              

              

              

              

              

              
              

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

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Phone</p>
                    <p>{stores?.phone}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Email</p>
                    <p>{stores?.email}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>AddressLine1</p>
                    <p>{stores?.address_line1}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>AddressLine2</p>
                    <p>{stores?.address_line2}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

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

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Emirate</p>
                    <p>{stores?.emirate}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>PostalCode</p>
                    <p>{stores?.postal_code}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

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

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>VATTRN</p>
                    <p>{stores?.vat_trn}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

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

              

              

              

              
              

              

              

              

              

              

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

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

              

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

              

              

              
              

                
                
                
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Price_lists Store</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>PriceListName</th>
                                
                                
                                
                                <th>Code</th>
                                
                                
                                
                                
                                
                                <th>ValidFrom</th>
                                
                                
                                
                                <th>ValidTo</th>
                                
                                
                                
                                <th>IsActive</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {stores.price_lists_store && Array.isArray(stores.price_lists_store) &&
                              stores.price_lists_store.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/price_lists/price_lists-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="code">
                                        { item.code }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="valid_from">
                                        { dataFormatter.dateTimeFormatter(item.valid_from) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="valid_to">
                                        { dataFormatter.dateTimeFormatter(item.valid_to) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!stores?.price_lists_store?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Discounts Store</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>DiscountName</th>
                                
                                
                                
                                <th>DiscountType</th>
                                
                                
                                
                                <th>Value</th>
                                
                                
                                
                                <th>CouponCode</th>
                                
                                
                                
                                <th>StartsAt</th>
                                
                                
                                
                                <th>EndsAt</th>
                                
                                
                                
                                <th>IsActive</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {stores.discounts_store && Array.isArray(stores.discounts_store) &&
                              stores.discounts_store.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/discounts/discounts-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="discount_type">
                                        { item.discount_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="value">
                                        { item.value }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="coupon_code">
                                        { item.coupon_code }
                                    </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="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!stores?.discounts_store?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Registers Store</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>RegisterName</th>
                                
                                
                                
                                <th>RegisterCode</th>
                                
                                
                                
                                
                                
                                <th>IsActive</th>
                                
                                
                                
                                <th>ReceiptFooterNote</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {stores.registers_store && Array.isArray(stores.registers_store) &&
                              stores.registers_store.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/registers/registers-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="code">
                                        { item.code }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="receipt_footer_note">
                                        { item.receipt_footer_note }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!stores?.registers_store?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Sales Store</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>ReceiptNumber</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>SoldAt</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Subtotal</th>
                                
                                
                                
                                <th>DiscountTotal</th>
                                
                                
                                
                                <th>VATTotal</th>
                                
                                
                                
                                <th>GrandTotal</th>
                                
                                
                                
                                <th>AmountPaid</th>
                                
                                
                                
                                <th>ChangeGiven</th>
                                
                                
                                
                                <th>ReceiptDelivery</th>
                                
                                
                                
                                <th>CustomerEmail</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {stores.sales_store && Array.isArray(stores.sales_store) &&
                              stores.sales_store.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/sales/sales-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="receipt_number">
                                        { item.receipt_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="sold_at">
                                        { dataFormatter.dateTimeFormatter(item.sold_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subtotal">
                                        { item.subtotal }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="discount_total">
                                        { item.discount_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="vat_total">
                                        { item.vat_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="grand_total">
                                        { item.grand_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="amount_paid">
                                        { item.amount_paid }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="change_given">
                                        { item.change_given }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="receipt_delivery">
                                        { item.receipt_delivery }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="customer_email">
                                        { item.customer_email }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!stores?.sales_store?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Returns Store</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>ReturnNumber</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>ReturnedAt</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Reason</th>
                                
                                
                                
                                <th>RefundTotal</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {stores.returns_store && Array.isArray(stores.returns_store) &&
                              stores.returns_store.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/returns/returns-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="return_number">
                                        { item.return_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="returned_at">
                                        { dataFormatter.dateTimeFormatter(item.returned_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reason">
                                        { item.reason }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="refund_total">
                                        { item.refund_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!stores?.returns_store?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Purchase_orders Store</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>PONumber</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>OrderedAt</th>
                                
                                
                                
                                <th>ExpectedAt</th>
                                
                                
                                
                                <th>ReceivedAt</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Subtotal</th>
                                
                                
                                
                                <th>VATTotal</th>
                                
                                
                                
                                <th>GrandTotal</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {stores.purchase_orders_store && Array.isArray(stores.purchase_orders_store) &&
                              stores.purchase_orders_store.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/purchase_orders/purchase_orders-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="po_number">
                                        { item.po_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="ordered_at">
                                        { dataFormatter.dateTimeFormatter(item.ordered_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="expected_at">
                                        { dataFormatter.dateTimeFormatter(item.expected_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="received_at">
                                        { dataFormatter.dateTimeFormatter(item.received_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subtotal">
                                        { item.subtotal }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="vat_total">
                                        { item.vat_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="grand_total">
                                        { item.grand_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!stores?.purchase_orders_store?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Inventory_items Store</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>OnHand</th>
                                
                                
                                
                                <th>Reserved</th>
                                
                                
                                
                                <th>Available</th>
                                
                                
                                
                                <th>LastCountedAt</th>
                                
                                
                                
                                <th>LastMovementAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {stores.inventory_items_store && Array.isArray(stores.inventory_items_store) &&
                              stores.inventory_items_store.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/inventory_items/inventory_items-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="on_hand">
                                        { item.on_hand }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reserved">
                                        { item.reserved }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="available">
                                        { item.available }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="last_counted_at">
                                        { dataFormatter.dateTimeFormatter(item.last_counted_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="last_movement_at">
                                        { dataFormatter.dateTimeFormatter(item.last_movement_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!stores?.inventory_items_store?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Stock_movements Store</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>MovedAt</th>
                                
                                
                                
                                <th>MovementType</th>
                                
                                
                                
                                <th>Quantity</th>
                                
                                
                                
                                <th>ReferenceCode</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {stores.stock_movements_store && Array.isArray(stores.stock_movements_store) &&
                              stores.stock_movements_store.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/stock_movements/stock_movements-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="moved_at">
                                        { dataFormatter.dateTimeFormatter(item.moved_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="movement_type">
                                        { item.movement_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="quantity">
                                        { item.quantity }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reference_code">
                                        { item.reference_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!stores?.stock_movements_store?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Stock_transfers FromStore</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>TransferNumber</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>RequestedAt</th>
                                
                                
                                
                                <th>ShippedAt</th>
                                
                                
                                
                                <th>ReceivedAt</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {stores.stock_transfers_from_store && Array.isArray(stores.stock_transfers_from_store) &&
                              stores.stock_transfers_from_store.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/stock_transfers/stock_transfers-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="transfer_number">
                                        { item.transfer_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="requested_at">
                                        { dataFormatter.dateTimeFormatter(item.requested_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="shipped_at">
                                        { dataFormatter.dateTimeFormatter(item.shipped_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="received_at">
                                        { dataFormatter.dateTimeFormatter(item.received_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!stores?.stock_transfers_from_store?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                <>
                    <p className={'block font-bold mb-2'}>Stock_transfers ToStore</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>TransferNumber</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>RequestedAt</th>
                                
                                
                                
                                <th>ShippedAt</th>
                                
                                
                                
                                <th>ReceivedAt</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {stores.stock_transfers_to_store && Array.isArray(stores.stock_transfers_to_store) &&
                              stores.stock_transfers_to_store.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/stock_transfers/stock_transfers-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="transfer_number">
                                        { item.transfer_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="requested_at">
                                        { dataFormatter.dateTimeFormatter(item.requested_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="shipped_at">
                                        { dataFormatter.dateTimeFormatter(item.shipped_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="received_at">
                                        { dataFormatter.dateTimeFormatter(item.received_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!stores?.stock_transfers_to_store?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                

                <BaseDivider />

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

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

export default StoresView;