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/subject_categories/subject_categoriesSlice'
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 Subject_categoriesView = () => {
    const router = useRouter()
    const dispatch = useAppDispatch()
    const { subject_categories } = useAppSelector((state) => state.subject_categories)
    

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

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>CategoryNameBangla</p>
                    <p>{subject_categories?.name_bn}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>CategoryNameEnglish</p>
                    <p>{subject_categories?.name_en}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>IconKey</p>
                    <p>{subject_categories?.icon_key}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>SeedTutorCount</p>
                  <p>{subject_categories?.seed_tutor_count || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Subjects Category</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>SubjectName</th>
                                
                                
                                
                                <th>SubjectNameBangla</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {subject_categories.subjects_category && Array.isArray(subject_categories.subjects_category) &&
                              subject_categories.subjects_category.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/subjects/subjects-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="name_bn">
                                        { item.name_bn }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!subject_categories?.subjects_category?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Gigs Category</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>GigTitle</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>GigStatus</th>
                                
                                
                                
                                <th>Impressions</th>
                                
                                
                                
                                <th>TotalOrders</th>
                                
                                
                                
                                <th>Rating</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {subject_categories.gigs_category && Array.isArray(subject_categories.gigs_category) &&
                              subject_categories.gigs_category.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/gigs/gigs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="impressions">
                                        { item.impressions }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="total_orders">
                                        { item.total_orders }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="rating">
                                        { item.rating }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!subject_categories?.gigs_category?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Spaces Category</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>SpaceName</th>
                                
                                
                                
                                <th>SpaceNameBangla</th>
                                
                                
                                
                                <th>Visibility</th>
                                
                                
                                
                                <th>SpaceKind</th>
                                
                                
                                
                                
                                
                                <th>Description</th>
                                
                                
                                
                                <th>SeedUnreadCount</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {subject_categories.spaces_category && Array.isArray(subject_categories.spaces_category) &&
                              subject_categories.spaces_category.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/spaces/spaces-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="name_bn">
                                        { item.name_bn }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="visibility">
                                        { item.visibility }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="space_kind">
                                        { item.space_kind }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="unread_seed_count">
                                        { item.unread_seed_count }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!subject_categories?.spaces_category?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                

                <BaseDivider />

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

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

export default Subject_categoriesView;