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/books/booksSlice'
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 BooksView = () => {
    const router = useRouter()
    const dispatch = useAppDispatch()
    const { books } = useAppSelector((state) => state.books)
    

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

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Title</p>
                    <p>{books?.title}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Subtitle</p>
                    <p>{books?.subtitle}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>ISBN</p>
                    <p>{books?.isbn}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Language</p>
                    <p>{books?.language ?? 'No data'}</p>
                </div>
              

              

              

              

              

              
              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Format</p>
                    <p>{books?.format ?? 'No data'}</p>
                </div>
              

              

              

              

              

              
              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Status</p>
                    <p>{books?.status ?? 'No data'}</p>
                </div>
              

              

              

              

              

              
              

              

              

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

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

              

              

              

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

              
              

              

              

              

              

              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Contentfiles</p>
                    {books?.content_files?.length
                      ? dataFormatter.filesFormatter(books.content_files).map(link => (
                        <button
                          key={link.publicUrl}
                          onClick={(e) => saveFile(e, link.publicUrl, link.name)}
                        >
                            {link.name}
                        </button>
                      )) : <p>No Contentfiles</p>
                    }
                </div>
              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>Pagecount</p>
                  <p>{books?.page_count || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>Wordcount</p>
                  <p>{books?.word_count || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>Duration(seconds)</p>
                  <p>{books?.duration_seconds || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>Difficultyscore</p>
                  <p>{books?.difficulty_score || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>Popularityscore</p>
                  <p>{books?.popularity_score || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

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

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

              

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

              

              

              
              

              

              

              

              

              

              

              

              

              

              

              
                <>
                    <p className={'block font-bold mb-2'}>Authors</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                    <th>Name</th>
                                
                                
                                
                                
                                
                                
                                
                                    <th>WebsiteURL</th>
                                
                                
                                
                                    <th>Primarylanguage</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {books.authors && Array.isArray(books.authors) &&
                              books.authors.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/authors/authors-view/?id=${item.id}`)}>
                                  
                                    
                                    
                                    
                                    
                                  
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="website_url">
                                        { item.website_url }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="primary_language">
                                        { item.primary_language }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!books?.authors?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
              

              

              
              

              

              

              

              

              

              

              

              

              

              

              
                <>
                    <p className={'block font-bold mb-2'}>Genres</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                    <th>Name</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {books.genres && Array.isArray(books.genres) &&
                              books.genres.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/genres/genres-view/?id=${item.id}`)}>
                                  
                                    
                                    
                                    
                                    
                                    
                                  
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!books?.genres?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
              

              

              
              

                
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>User_library_items Book</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Source</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Offlinedownloaded</th>
                                
                                
                                
                                <th>Downloadedat</th>
                                
                                
                                
                                <th>Progresspercent</th>
                                
                                
                                
                                <th>Currentlocation</th>
                                
                                
                                
                                <th>Lastopenedat</th>
                                
                                
                                
                                <th>Completedat</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {books.user_library_items_book && Array.isArray(books.user_library_items_book) &&
                              books.user_library_items_book.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/user_library_items/user_library_items-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="source">
                                        { item.source }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="offline_downloaded">
                                        { dataFormatter.booleanFormatter(item.offline_downloaded) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="downloaded_at">
                                        { dataFormatter.dateTimeFormatter(item.downloaded_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="progress_percent">
                                        { item.progress_percent }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="current_location">
                                        { item.current_location }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="last_opened_at">
                                        { dataFormatter.dateTimeFormatter(item.last_opened_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="completed_at">
                                        { dataFormatter.dateTimeFormatter(item.completed_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!books?.user_library_items_book?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Bookmarks Book</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Location</th>
                                
                                
                                
                                <th>Label</th>
                                
                                
                                
                                <th>Addedat</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {books.bookmarks_book && Array.isArray(books.bookmarks_book) &&
                              books.bookmarks_book.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/bookmarks/bookmarks-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="location">
                                        { item.location }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="label">
                                        { item.label }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="added_at">
                                        { dataFormatter.dateTimeFormatter(item.added_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!books?.bookmarks_book?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Notes Book</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Location</th>
                                
                                
                                
                                <th>Title</th>
                                
                                
                                
                                
                                
                                <th>Isprivate</th>
                                
                                
                                
                                <th>Notedat</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {books.notes_book && Array.isArray(books.notes_book) &&
                              books.notes_book.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/notes/notes-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="location">
                                        { item.location }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="is_private">
                                        { dataFormatter.booleanFormatter(item.is_private) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="noted_at">
                                        { dataFormatter.dateTimeFormatter(item.noted_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!books?.notes_book?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Camera_scan_sessions Book</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Scantype</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Startedat</th>
                                
                                
                                
                                <th>Endedat</th>
                                
                                
                                
                                <th>Framesanalyzed</th>
                                
                                
                                
                                <th>Pagesdetected</th>
                                
                                
                                
                                <th>Confidencescore</th>
                                
                                
                                
                                <th>Pageturningdetected</th>
                                
                                
                                
                                <th>Duplicatepagedetected</th>
                                
                                
                                
                                <th>Fraudreason</th>
                                
                                
                                
                                <th>Coinsawarded</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {books.camera_scan_sessions_book && Array.isArray(books.camera_scan_sessions_book) &&
                              books.camera_scan_sessions_book.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/camera_scan_sessions/camera_scan_sessions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="scan_type">
                                        { item.scan_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="started_at">
                                        { dataFormatter.dateTimeFormatter(item.started_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ended_at">
                                        { dataFormatter.dateTimeFormatter(item.ended_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="frames_analyzed">
                                        { item.frames_analyzed }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="pages_detected">
                                        { item.pages_detected }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="confidence_score">
                                        { item.confidence_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="page_turning_detected">
                                        { dataFormatter.booleanFormatter(item.page_turning_detected) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="duplicate_page_detected">
                                        { dataFormatter.booleanFormatter(item.duplicate_page_detected) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="fraud_reason">
                                        { item.fraud_reason }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="coins_awarded">
                                        { item.coins_awarded }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!books?.camera_scan_sessions_book?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Coin_ledger_entries Book</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Entrytype</th>
                                
                                
                                
                                <th>Reason</th>
                                
                                
                                
                                <th>Amount(coins)</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                                
                                <th>Occurredat</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {books.coin_ledger_entries_book && Array.isArray(books.coin_ledger_entries_book) &&
                              books.coin_ledger_entries_book.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/coin_ledger_entries/coin_ledger_entries-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="entry_type">
                                        { item.entry_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reason">
                                        { item.reason }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="amount_coins">
                                        { item.amount_coins }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="occurred_at">
                                        { dataFormatter.dateTimeFormatter(item.occurred_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!books?.coin_ledger_entries_book?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Quiz_definitions Book</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Title</th>
                                
                                
                                
                                <th>Difficulty</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Questioncount</th>
                                
                                
                                
                                <th>Timelimit(seconds)</th>
                                
                                
                                
                                <th>Generatedat</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {books.quiz_definitions_book && Array.isArray(books.quiz_definitions_book) &&
                              books.quiz_definitions_book.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/quiz_definitions/quiz_definitions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="difficulty">
                                        { item.difficulty }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="question_count">
                                        { item.question_count }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="time_limit_seconds">
                                        { item.time_limit_seconds }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="generated_at">
                                        { dataFormatter.dateTimeFormatter(item.generated_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!books?.quiz_definitions_book?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Reading_circle_events Book</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Title</th>
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Startat</th>
                                
                                
                                
                                <th>Endat</th>
                                
                                
                                
                                <th>Meetinglink</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {books.reading_circle_events_book && Array.isArray(books.reading_circle_events_book) &&
                              books.reading_circle_events_book.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/reading_circle_events/reading_circle_events-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="start_at">
                                        { dataFormatter.dateTimeFormatter(item.start_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="end_at">
                                        { dataFormatter.dateTimeFormatter(item.end_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="meeting_link">
                                        { item.meeting_link }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!books?.reading_circle_events_book?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Recommendation_events Book</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Source</th>
                                
                                
                                
                                <th>Score</th>
                                
                                
                                
                                <th>Explanation</th>
                                
                                
                                
                                <th>Recommendedat</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {books.recommendation_events_book && Array.isArray(books.recommendation_events_book) &&
                              books.recommendation_events_book.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/recommendation_events/recommendation_events-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="source">
                                        { item.source }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="score">
                                        { item.score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="explanation">
                                        { item.explanation }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="recommended_at">
                                        { dataFormatter.dateTimeFormatter(item.recommended_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!books?.recommendation_events_book?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                

                <BaseDivider />

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

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

export default BooksView;