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

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


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

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

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


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

              

              

              

              

              

              

              

              

              

              
              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Album</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                        <p>{media_items?.album?.title ?? 'No data'}</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                </div>
                 
              

              

              

              
              

              

              

              

              

              

              

              

              

              

              
              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Uploader</p>
                    
                    
                        <p>{media_items?.uploader?.firstName ?? 'No data'}</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                </div>
                 
              

              

              

              
              

              

              

              

              

              

              

              

              

              

              
              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>StorageObject</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                        <p>{media_items?.storage_object?.object_key ?? 'No data'}</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                </div>
                 
              

              

              

              
              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>MediaType</p>
                    <p>{media_items?.media_type ?? 'No data'}</p>
                </div>
              

              

              

              

              

              
              

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

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

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

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

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

              

              

              

              

              

              

              
              

              

              

              

              

              

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

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>Width</p>
                  <p>{media_items?.width || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>Height</p>
                  <p>{media_items?.height || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>DurationSeconds</p>
                  <p>{media_items?.duration_seconds || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>CameraMake</p>
                    <p>{media_items?.camera_make}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>CameraModel</p>
                    <p>{media_items?.camera_model}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>GPSLatitude</p>
                  <p>{media_items?.gps_latitude || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>GPSLongitude</p>
                  <p>{media_items?.gps_longitude || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Visibility</p>
                    <p>{media_items?.visibility ?? 'No data'}</p>
                </div>
              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

              
                <FormField label='IsDuplicate'>
                    <SwitchField
                      field={{name: 'is_duplicate', value: media_items?.is_duplicate}}
                      form={{setFieldValue: () => null}}
                      disabled
                    />
                </FormField>
              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>DuplicateGroupKey</p>
                    <p>{media_items?.duplicate_group_key}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

              

              

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

              

              
              

              

              

              

              

              

              

              

              

              

              

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

              

              
              

              

              

              

              

              

              

              

              

              

              

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

              

              
              

              

              

              

              

              

              

              

              

              

              

              
                <>
                    <p className={'block font-bold mb-2'}>Comments</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                    <th>Content</th>
                                
                                
                                
                                    <th>Status</th>
                                
                                
                                
                                    <th>PostedAt</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {media_items.comments && Array.isArray(media_items.comments) &&
                              media_items.comments.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/comments/comments-view/?id=${item.id}`)}>
                                  
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                  
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="content">
                                        { item.content }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="posted_at">
                                        { dataFormatter.dateTimeFormatter(item.posted_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!media_items?.comments?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
              

              

              
              

              

              

              

              

              

              

              

              

              

              

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

              

              
              

              

              

              

              

              

              

              

              

              

              

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

              

              
              

              

              

              

              

              

              

              

              

              

              

              
                <>
                    <p className={'block font-bold mb-2'}>FaceDetections</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                    <th>BBoxX</th>
                                
                                
                                
                                    <th>BBoxY</th>
                                
                                
                                
                                    <th>BBoxWidth</th>
                                
                                
                                
                                    <th>BBoxHeight</th>
                                
                                
                                
                                    <th>Confidence</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {media_items.face_detections && Array.isArray(media_items.face_detections) &&
                              media_items.face_detections.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/face_detections/face_detections-view/?id=${item.id}`)}>
                                  
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                  
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="bbox_x">
                                        { item.bbox_x }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="bbox_y">
                                        { item.bbox_y }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="bbox_width">
                                        { item.bbox_width }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="bbox_height">
                                        { item.bbox_height }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="confidence">
                                        { item.confidence }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!media_items?.face_detections?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
              

              

              
              

              

              

              

              

              

              

              

              

              

              

              
                <>
                    <p className={'block font-bold mb-2'}>WatermarkedDownloads</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                    <th>Status</th>
                                
                                
                                
                                    <th>WatermarkText</th>
                                
                                
                                
                                
                                
                                    <th>RequestedAt</th>
                                
                                
                                
                                    <th>CompletedAt</th>
                                
                                
                                
                                    <th>ErrorMessage</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {media_items.watermarked_downloads && Array.isArray(media_items.watermarked_downloads) &&
                              media_items.watermarked_downloads.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/download_jobs/download_jobs-view/?id=${item.id}`)}>
                                  
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                  
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="watermark_text">
                                        { item.watermark_text }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="requested_at">
                                        { dataFormatter.dateTimeFormatter(item.requested_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="completed_at">
                                        { dataFormatter.dateTimeFormatter(item.completed_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="error_message">
                                        { item.error_message }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!media_items?.watermarked_downloads?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
              

              

              
              

              

              

              

              

              

              

              

              

              

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

              

              

              
              

                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Upload_files MediaItem</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>FileName</th>
                                
                                
                                
                                <th>ContentType</th>
                                
                                
                                
                                <th>SizeBytes</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>ProgressPercent</th>
                                
                                
                                
                                <th>ErrorMessage</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {media_items.upload_files_media_item && Array.isArray(media_items.upload_files_media_item) &&
                              media_items.upload_files_media_item.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/upload_files/upload_files-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="file_name">
                                        { item.file_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="content_type">
                                        { item.content_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="size_bytes">
                                        { item.size_bytes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="progress_percent">
                                        { item.progress_percent }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="error_message">
                                        { item.error_message }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!media_items?.upload_files_media_item?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Media_ai_tags MediaItem</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Confidence</th>
                                
                                
                                
                                <th>Source</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {media_items.media_ai_tags_media_item && Array.isArray(media_items.media_ai_tags_media_item) &&
                              media_items.media_ai_tags_media_item.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/media_ai_tags/media_ai_tags-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="confidence">
                                        { item.confidence }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="source">
                                        { item.source }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!media_items?.media_ai_tags_media_item?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Media_user_tags MediaItem</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {media_items.media_user_tags_media_item && Array.isArray(media_items.media_user_tags_media_item) &&
                              media_items.media_user_tags_media_item.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/media_user_tags/media_user_tags-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!media_items?.media_user_tags_media_item?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Likes MediaItem</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>LikedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {media_items.likes_media_item && Array.isArray(media_items.likes_media_item) &&
                              media_items.likes_media_item.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/likes/likes-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="liked_at">
                                        { dataFormatter.dateTimeFormatter(item.liked_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!media_items?.likes_media_item?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Favourites MediaItem</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>SavedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {media_items.favourites_media_item && Array.isArray(media_items.favourites_media_item) &&
                              media_items.favourites_media_item.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/favourites/favourites-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="saved_at">
                                        { dataFormatter.dateTimeFormatter(item.saved_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!media_items?.favourites_media_item?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Comments MediaItem</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Content</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>PostedAt</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {media_items.comments_media_item && Array.isArray(media_items.comments_media_item) &&
                              media_items.comments_media_item.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/comments/comments-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="content">
                                        { item.content }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="posted_at">
                                        { dataFormatter.dateTimeFormatter(item.posted_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!media_items?.comments_media_item?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Mentions MediaItem</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {media_items.mentions_media_item && Array.isArray(media_items.mentions_media_item) &&
                              media_items.mentions_media_item.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/mentions/mentions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!media_items?.mentions_media_item?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Notifications MediaItem</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Type</th>
                                
                                
                                
                                <th>Title</th>
                                
                                
                                
                                <th>Body</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>IsRead</th>
                                
                                
                                
                                <th>ReadAt</th>
                                
                                
                                
                                <th>SentAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {media_items.notifications_media_item && Array.isArray(media_items.notifications_media_item) &&
                              media_items.notifications_media_item.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/notifications/notifications-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="type">
                                        { item.type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="body">
                                        { item.body }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="is_read">
                                        { dataFormatter.booleanFormatter(item.is_read) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="read_at">
                                        { dataFormatter.dateTimeFormatter(item.read_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sent_at">
                                        { dataFormatter.dateTimeFormatter(item.sent_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!media_items?.notifications_media_item?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Download_jobs MediaItem</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>WatermarkText</th>
                                
                                
                                
                                
                                
                                <th>RequestedAt</th>
                                
                                
                                
                                <th>CompletedAt</th>
                                
                                
                                
                                <th>ErrorMessage</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {media_items.download_jobs_media_item && Array.isArray(media_items.download_jobs_media_item) &&
                              media_items.download_jobs_media_item.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/download_jobs/download_jobs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="watermark_text">
                                        { item.watermark_text }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="requested_at">
                                        { dataFormatter.dateTimeFormatter(item.requested_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="completed_at">
                                        { dataFormatter.dateTimeFormatter(item.completed_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="error_message">
                                        { item.error_message }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!media_items?.download_jobs_media_item?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Ai_embeddings MediaItem</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>VectorRef</th>
                                
                                
                                
                                <th>Dimensions</th>
                                
                                
                                
                                <th>EmbeddingType</th>
                                
                                
                                
                                <th>QualityScore</th>
                                
                                
                                
                                <th>IndexedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {media_items.ai_embeddings_media_item && Array.isArray(media_items.ai_embeddings_media_item) &&
                              media_items.ai_embeddings_media_item.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/ai_embeddings/ai_embeddings-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="vector_ref">
                                        { item.vector_ref }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="dimensions">
                                        { item.dimensions }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="embedding_type">
                                        { item.embedding_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="quality_score">
                                        { item.quality_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="indexed_at">
                                        { dataFormatter.dateTimeFormatter(item.indexed_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!media_items?.ai_embeddings_media_item?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Face_detections MediaItem</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>BBoxX</th>
                                
                                
                                
                                <th>BBoxY</th>
                                
                                
                                
                                <th>BBoxWidth</th>
                                
                                
                                
                                <th>BBoxHeight</th>
                                
                                
                                
                                <th>Confidence</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {media_items.face_detections_media_item && Array.isArray(media_items.face_detections_media_item) &&
                              media_items.face_detections_media_item.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/face_detections/face_detections-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="bbox_x">
                                        { item.bbox_x }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="bbox_y">
                                        { item.bbox_y }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="bbox_width">
                                        { item.bbox_width }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="bbox_height">
                                        { item.bbox_height }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="confidence">
                                        { item.confidence }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!media_items?.face_detections_media_item?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Ai_captions MediaItem</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>CaptionText</th>
                                
                                
                                
                                <th>Confidence</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {media_items.ai_captions_media_item && Array.isArray(media_items.ai_captions_media_item) &&
                              media_items.ai_captions_media_item.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/ai_captions/ai_captions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="caption_text">
                                        { item.caption_text }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="confidence">
                                        { item.confidence }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!media_items?.ai_captions_media_item?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Moderation_flags MediaItem</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Reason</th>
                                
                                
                                
                                <th>Details</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                
                                
                                <th>ReportedAt</th>
                                
                                
                                
                                <th>ResolvedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {media_items.moderation_flags_media_item && Array.isArray(media_items.moderation_flags_media_item) &&
                              media_items.moderation_flags_media_item.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/moderation_flags/moderation_flags-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="reason">
                                        { item.reason }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="details">
                                        { item.details }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="reported_at">
                                        { dataFormatter.dateTimeFormatter(item.reported_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="resolved_at">
                                        { dataFormatter.dateTimeFormatter(item.resolved_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!media_items?.moderation_flags_media_item?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Story_items MediaItem</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>SortOrder</th>
                                
                                
                                
                                <th>Layout</th>
                                
                                
                                
                                <th>OverlayText</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {media_items.story_items_media_item && Array.isArray(media_items.story_items_media_item) &&
                              media_items.story_items_media_item.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/story_items/story_items-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="sort_order">
                                        { item.sort_order }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="layout">
                                        { item.layout }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="overlay_text">
                                        { item.overlay_text }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!media_items?.story_items_media_item?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Analytics_events MediaItem</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>EventType</th>
                                
                                
                                
                                <th>MetadataJSON</th>
                                
                                
                                
                                <th>OccurredAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {media_items.analytics_events_media_item && Array.isArray(media_items.analytics_events_media_item) &&
                              media_items.analytics_events_media_item.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/analytics_events/analytics_events-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="event_type">
                                        { item.event_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="metadata_json">
                                        { item.metadata_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="occurred_at">
                                        { dataFormatter.dateTimeFormatter(item.occurred_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!media_items?.analytics_events_media_item?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                

                <BaseDivider />

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

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

export default Media_itemsView;