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


const UsersView = () => {
    const router = useRouter()
    const dispatch = useAppDispatch()
    const { users } = useAppSelector((state) => state.users)
    

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

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>First Name</p>
                    <p>{users?.firstName}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Last Name</p>
                    <p>{users?.lastName}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

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

              

              

              

              

              

              

              

              

              

              

              

              
              

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

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

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

              

              

              

              
              

              

              

              

              

              

              

              

              

              

              

              

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

              
              

              

              

              

              

              

              

              

              

              

              
              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>App Role</p>
                    
                    
                    
                    
                        <p>{users?.app_role?.name ?? 'No data'}</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                </div>
                 
              

              

              

              
              

              

              

              

              

              

              

              

              

              

              

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

              

              
              

                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>User_relationships Follower</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>CloseFriends</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.user_relationships_follower && Array.isArray(users.user_relationships_follower) &&
                              users.user_relationships_follower.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/user_relationships/user_relationships-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="close_friends">
                                        { dataFormatter.booleanFormatter(item.close_friends) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.user_relationships_follower?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                <>
                    <p className={'block font-bold mb-2'}>User_relationships Following</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>CloseFriends</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.user_relationships_following && Array.isArray(users.user_relationships_following) &&
                              users.user_relationships_following.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/user_relationships/user_relationships-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="close_friends">
                                        { dataFormatter.booleanFormatter(item.close_friends) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.user_relationships_following?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Posts Author</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>PostType</th>
                                
                                
                                
                                <th>Caption</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>Location</th>
                                
                                
                                
                                <th>CommentsEnabled</th>
                                
                                
                                
                                <th>Archived</th>
                                
                                
                                
                                <th>PublishedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.posts_author && Array.isArray(users.posts_author) &&
                              users.posts_author.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/posts/posts-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="post_type">
                                        { item.post_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="caption">
                                        { item.caption }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="location_name">
                                        { item.location_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="comments_enabled">
                                        { dataFormatter.booleanFormatter(item.comments_enabled) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_archived">
                                        { dataFormatter.booleanFormatter(item.is_archived) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="published_at">
                                        { dataFormatter.dateTimeFormatter(item.published_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.posts_author?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Post_comments Author</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Comment</th>
                                
                                
                                
                                
                                
                                <th>Pinned</th>
                                
                                
                                
                                <th>CommentedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.post_comments_author && Array.isArray(users.post_comments_author) &&
                              users.post_comments_author.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/post_comments/post_comments-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="body">
                                        { item.body }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="is_pinned">
                                        { dataFormatter.booleanFormatter(item.is_pinned) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="commented_at">
                                        { dataFormatter.dateTimeFormatter(item.commented_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.post_comments_author?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Post_reactions User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>ReactionType</th>
                                
                                
                                
                                <th>ReactedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.post_reactions_user && Array.isArray(users.post_reactions_user) &&
                              users.post_reactions_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/post_reactions/post_reactions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="reaction_type">
                                        { item.reaction_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reacted_at">
                                        { dataFormatter.dateTimeFormatter(item.reacted_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.post_reactions_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Post_saves User</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>
                            {users.post_saves_user && Array.isArray(users.post_saves_user) &&
                              users.post_saves_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/post_saves/post_saves-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="saved_at">
                                        { dataFormatter.dateTimeFormatter(item.saved_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.post_saves_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Save_collections Owner</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Title</th>
                                
                                
                                
                                <th>Private</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.save_collections_owner && Array.isArray(users.save_collections_owner) &&
                              users.save_collections_owner.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/save_collections/save_collections-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_private">
                                        { dataFormatter.booleanFormatter(item.is_private) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.save_collections_owner?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Stories Author</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>MediaType</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>Caption</th>
                                
                                
                                
                                <th>CloseFriendsOnly</th>
                                
                                
                                
                                <th>PostedAt</th>
                                
                                
                                
                                <th>ExpiresAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.stories_author && Array.isArray(users.stories_author) &&
                              users.stories_author.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/stories/stories-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="media_type">
                                        { item.media_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="caption">
                                        { item.caption }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="close_friends_only">
                                        { dataFormatter.booleanFormatter(item.close_friends_only) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="posted_at">
                                        { dataFormatter.dateTimeFormatter(item.posted_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="expires_at">
                                        { dataFormatter.dateTimeFormatter(item.expires_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.stories_author?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Story_views Viewer</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>ViewedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.story_views_viewer && Array.isArray(users.story_views_viewer) &&
                              users.story_views_viewer.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/story_views/story_views-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="viewed_at">
                                        { dataFormatter.dateTimeFormatter(item.viewed_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.story_views_viewer?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Highlights Owner</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Title</th>
                                
                                
                                
                                
                                
                                <th>Archived</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.highlights_owner && Array.isArray(users.highlights_owner) &&
                              users.highlights_owner.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/highlights/highlights-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="is_archived">
                                        { dataFormatter.booleanFormatter(item.is_archived) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.highlights_owner?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Reels Author</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Caption</th>
                                
                                
                                
                                <th>AudioTitle</th>
                                
                                
                                
                                <th>AudioArtist</th>
                                
                                
                                
                                <th>Duration(Seconds)</th>
                                
                                
                                
                                <th>Archived</th>
                                
                                
                                
                                <th>PublishedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.reels_author && Array.isArray(users.reels_author) &&
                              users.reels_author.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/reels/reels-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="caption">
                                        { item.caption }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="audio_title">
                                        { item.audio_title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="audio_artist">
                                        { item.audio_artist }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="duration_seconds">
                                        { item.duration_seconds }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_archived">
                                        { dataFormatter.booleanFormatter(item.is_archived) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="published_at">
                                        { dataFormatter.dateTimeFormatter(item.published_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.reels_author?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Reel_reactions User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>ReactionType</th>
                                
                                
                                
                                <th>ReactedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.reel_reactions_user && Array.isArray(users.reel_reactions_user) &&
                              users.reel_reactions_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/reel_reactions/reel_reactions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="reaction_type">
                                        { item.reaction_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reacted_at">
                                        { dataFormatter.dateTimeFormatter(item.reacted_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.reel_reactions_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Reel_comments Author</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Comment</th>
                                
                                
                                
                                
                                
                                <th>CommentedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.reel_comments_author && Array.isArray(users.reel_comments_author) &&
                              users.reel_comments_author.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/reel_comments/reel_comments-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="body">
                                        { item.body }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="commented_at">
                                        { dataFormatter.dateTimeFormatter(item.commented_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.reel_comments_author?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Conversations Owner</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>ConversationType</th>
                                
                                
                                
                                <th>Title</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>LastMessageAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.conversations_owner && Array.isArray(users.conversations_owner) &&
                              users.conversations_owner.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/conversations/conversations-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="conversation_type">
                                        { item.conversation_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="last_message_at">
                                        { dataFormatter.dateTimeFormatter(item.last_message_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.conversations_owner?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Conversation_members User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Role</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>JoinedAt</th>
                                
                                
                                
                                <th>LastReadAt</th>
                                
                                
                                
                                <th>Muted</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.conversation_members_user && Array.isArray(users.conversation_members_user) &&
                              users.conversation_members_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/conversation_members/conversation_members-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="member_role">
                                        { item.member_role }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="member_status">
                                        { item.member_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="joined_at">
                                        { dataFormatter.dateTimeFormatter(item.joined_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="last_read_at">
                                        { dataFormatter.dateTimeFormatter(item.last_read_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_muted">
                                        { dataFormatter.booleanFormatter(item.is_muted) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.conversation_members_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Messages Sender</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>MessageType</th>
                                
                                
                                
                                <th>Message</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>DeliveryStatus</th>
                                
                                
                                
                                <th>SentAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.messages_sender && Array.isArray(users.messages_sender) &&
                              users.messages_sender.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/messages/messages-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="message_type">
                                        { item.message_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="body">
                                        { item.body }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="delivery_status">
                                        { item.delivery_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sent_at">
                                        { dataFormatter.dateTimeFormatter(item.sent_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.messages_sender?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Calls Initiator</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>CallType</th>
                                
                                
                                
                                <th>CallStatus</th>
                                
                                
                                
                                <th>StartedAt</th>
                                
                                
                                
                                <th>EndedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.calls_initiator && Array.isArray(users.calls_initiator) &&
                              users.calls_initiator.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/calls/calls-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="call_type">
                                        { item.call_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="call_status">
                                        { item.call_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="started_at">
                                        { dataFormatter.dateTimeFormatter(item.started_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ended_at">
                                        { dataFormatter.dateTimeFormatter(item.ended_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.calls_initiator?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Notifications Recipient</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>DeepLink</th>
                                
                                
                                
                                <th>Read</th>
                                
                                
                                
                                <th>NotifiedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.notifications_recipient && Array.isArray(users.notifications_recipient) &&
                              users.notifications_recipient.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/notifications/notifications-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="notification_type">
                                        { item.notification_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="body">
                                        { item.body }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="deep_link">
                                        { item.deep_link }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_read">
                                        { dataFormatter.booleanFormatter(item.is_read) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notified_at">
                                        { dataFormatter.dateTimeFormatter(item.notified_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.notifications_recipient?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Reports Reporter</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>TargetType</th>
                                
                                
                                
                                <th>TargetReference</th>
                                
                                
                                
                                <th>Reason</th>
                                
                                
                                
                                <th>Details</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>ReportedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.reports_reporter && Array.isArray(users.reports_reporter) &&
                              users.reports_reporter.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/reports/reports-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="target_type">
                                        { item.target_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="target_ref">
                                        { item.target_ref }
                                    </td>
                                    
                                    
                                    
                                    <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>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.reports_reporter?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Products Seller</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Title</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                                
                                
                                
                                <th>Price</th>
                                
                                
                                
                                <th>Currency</th>
                                
                                
                                
                                <th>ProductURL</th>
                                
                                
                                
                                <th>Active</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.products_seller && Array.isArray(users.products_seller) &&
                              users.products_seller.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/products/products-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="price">
                                        { item.price }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="product_url">
                                        { item.product_url }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.products_seller?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Insight_snapshots Owner</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ContentType</th>
                                
                                
                                
                                <th>ContentReference</th>
                                
                                
                                
                                <th>WindowStart</th>
                                
                                
                                
                                <th>WindowEnd</th>
                                
                                
                                
                                <th>Impressions</th>
                                
                                
                                
                                <th>Reach</th>
                                
                                
                                
                                <th>ProfileVisits</th>
                                
                                
                                
                                <th>Likes</th>
                                
                                
                                
                                <th>Comments</th>
                                
                                
                                
                                <th>Saves</th>
                                
                                
                                
                                <th>Shares</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.insight_snapshots_owner && Array.isArray(users.insight_snapshots_owner) &&
                              users.insight_snapshots_owner.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/insight_snapshots/insight_snapshots-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="content_type">
                                        { item.content_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="content_ref">
                                        { item.content_ref }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="window_start_at">
                                        { dataFormatter.dateTimeFormatter(item.window_start_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="window_end_at">
                                        { dataFormatter.dateTimeFormatter(item.window_end_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="impressions">
                                        { item.impressions }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reach">
                                        { item.reach }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="profile_visits">
                                        { item.profile_visits }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="likes">
                                        { item.likes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="comments">
                                        { item.comments }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="saves">
                                        { item.saves }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="shares">
                                        { item.shares }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.insight_snapshots_owner?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                

                <BaseDivider />

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

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

export default UsersView;