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/footer_content_blocks/footer_content_blocksSlice'
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 Footer_content_blocksView = () => {
    const router = useRouter()
    const dispatch = useAppDispatch()
    const { footer_content_blocks } = useAppSelector((state) => state.footer_content_blocks)
    

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

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>StoreDescription(Arabic)</p>
                  {footer_content_blocks.store_description_ar
                    ? <p dangerouslySetInnerHTML={{__html: footer_content_blocks.store_description_ar}}/>
                    : <p>No data</p>
                  }
                </div>
              

              

              

              

              

              

              

              

              

              

              
              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>StoreDescription(English)</p>
                  {footer_content_blocks.store_description_en
                    ? <p dangerouslySetInnerHTML={{__html: footer_content_blocks.store_description_en}}/>
                    : <p>No data</p>
                  }
                </div>
              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

              

              

              
                <>
                    <p className={'block font-bold mb-2'}>SocialLinks</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                    <th>Platform</th>
                                
                                
                                
                                    <th>URL</th>
                                
                                
                                
                                    <th>IsActive</th>
                                
                                
                                
                                    <th>SortOrder</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {footer_content_blocks.social_links && Array.isArray(footer_content_blocks.social_links) &&
                              footer_content_blocks.social_links.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/social_links/social_links-view/?id=${item.id}`)}>
                                  
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                  
                                    
                                    <td data-label="platform">
                                        { item.platform }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="url">
                                        { item.url }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sort_order">
                                        { item.sort_order }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!footer_content_blocks?.social_links?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
              

              

              
              

              

              

              

              

              

              

              

              

              

              

              
                <>
                    <p className={'block font-bold mb-2'}>FooterLinks</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                    <th>LinkGroup</th>
                                
                                
                                
                                    <th>Label(Arabic)</th>
                                
                                
                                
                                    <th>Label(English)</th>
                                
                                
                                
                                    <th>Href</th>
                                
                                
                                
                                    <th>IsActive</th>
                                
                                
                                
                                    <th>SortOrder</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {footer_content_blocks.footer_links && Array.isArray(footer_content_blocks.footer_links) &&
                              footer_content_blocks.footer_links.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/footer_links/footer_links-view/?id=${item.id}`)}>
                                  
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                  
                                    
                                    <td data-label="link_group">
                                        { item.link_group }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="label_ar">
                                        { item.label_ar }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="label_en">
                                        { item.label_en }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="href">
                                        { item.href }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sort_order">
                                        { item.sort_order }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!footer_content_blocks?.footer_links?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
              

              

              
              

              

              

              

              

              

              

              

              

              

              

              
                <>
                    <p className={'block font-bold mb-2'}>PaymentBadges</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                    <th>Method</th>
                                
                                
                                
                                
                                
                                    <th>Label</th>
                                
                                
                                
                                    <th>IsActive</th>
                                
                                
                                
                                    <th>SortOrder</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {footer_content_blocks.payment_badges && Array.isArray(footer_content_blocks.payment_badges) &&
                              footer_content_blocks.payment_badges.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/payment_badges/payment_badges-view/?id=${item.id}`)}>
                                  
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                  
                                    
                                    <td data-label="method">
                                        { item.method }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="label">
                                        { item.label }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sort_order">
                                        { item.sort_order }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!footer_content_blocks?.payment_badges?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
              

              

              
              

                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Social_links FooterContentBlock</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>Platform</th>
                                
                                
                                
                                <th>URL</th>
                                
                                
                                
                                <th>IsActive</th>
                                
                                
                                
                                <th>SortOrder</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {footer_content_blocks.social_links_footer_content_block && Array.isArray(footer_content_blocks.social_links_footer_content_block) &&
                              footer_content_blocks.social_links_footer_content_block.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/social_links/social_links-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="platform">
                                        { item.platform }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="url">
                                        { item.url }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sort_order">
                                        { item.sort_order }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!footer_content_blocks?.social_links_footer_content_block?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Footer_links FooterContentBlock</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>LinkGroup</th>
                                
                                
                                
                                <th>Label(Arabic)</th>
                                
                                
                                
                                <th>Label(English)</th>
                                
                                
                                
                                <th>Href</th>
                                
                                
                                
                                <th>IsActive</th>
                                
                                
                                
                                <th>SortOrder</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {footer_content_blocks.footer_links_footer_content_block && Array.isArray(footer_content_blocks.footer_links_footer_content_block) &&
                              footer_content_blocks.footer_links_footer_content_block.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/footer_links/footer_links-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="link_group">
                                        { item.link_group }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="label_ar">
                                        { item.label_ar }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="label_en">
                                        { item.label_en }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="href">
                                        { item.href }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sort_order">
                                        { item.sort_order }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!footer_content_blocks?.footer_links_footer_content_block?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Payment_badges FooterContentBlock</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>Method</th>
                                
                                
                                
                                
                                
                                <th>Label</th>
                                
                                
                                
                                <th>IsActive</th>
                                
                                
                                
                                <th>SortOrder</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {footer_content_blocks.payment_badges_footer_content_block && Array.isArray(footer_content_blocks.payment_badges_footer_content_block) &&
                              footer_content_blocks.payment_badges_footer_content_block.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/payment_badges/payment_badges-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="method">
                                        { item.method }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="label">
                                        { item.label }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sort_order">
                                        { item.sort_order }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!footer_content_blocks?.payment_badges_footer_content_block?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                

                <BaseDivider />

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

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

export default Footer_content_blocksView;