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";

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


const UsersView = () => {
    const router = useRouter()
    const dispatch = useAppDispatch()
    const { users } = useAppSelector((state) => state.users)
    
    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 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>
                </>
              

              

              
              

              

              

              

              

              

              

              

              

              

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

              

              

              
              

                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Creator_profiles User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Handle</th>
                                
                                
                                
                                <th>CreatorType</th>
                                
                                
                                
                                <th>IsVerified</th>
                                
                                
                                
                                <th>IsAdultCreator</th>
                                
                                
                                
                                <th>Slogan</th>
                                
                                
                                
                                
                                
                                <th>BusinessEmail</th>
                                
                                
                                
                                <th>SupportEmail</th>
                                
                                
                                
                                <th>PreferredLanguage</th>
                                
                                
                                
                                <th>CategoryTags(Comma-separated)</th>
                                
                                
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.creator_profiles_user && Array.isArray(users.creator_profiles_user) &&
                              users.creator_profiles_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/creator_profiles/creator_profiles-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="handle">
                                        { item.handle }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="creator_type">
                                        { item.creator_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_verified">
                                        { dataFormatter.booleanFormatter(item.is_verified) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_adult_creator">
                                        { dataFormatter.booleanFormatter(item.is_adult_creator) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="slogan">
                                        { item.slogan }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="business_email">
                                        { item.business_email }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="support_email">
                                        { item.support_email }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="preferred_language">
                                        { item.preferred_language }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="category_tags">
                                        { item.category_tags }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.creator_profiles_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Fan_profiles User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Nickname</th>
                                
                                
                                
                                
                                
                                <th>HideSocialActivity</th>
                                
                                
                                
                                <th>XPCoinsBalance</th>
                                
                                
                                
                                <th>AdultModeEnabled</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.fan_profiles_user && Array.isArray(users.fan_profiles_user) &&
                              users.fan_profiles_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/fan_profiles/fan_profiles-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="nickname">
                                        { item.nickname }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="hide_social_activity">
                                        { dataFormatter.booleanFormatter(item.hide_social_activity) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="xp_coins_balance">
                                        { item.xp_coins_balance }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="adult_mode_enabled">
                                        { dataFormatter.booleanFormatter(item.adult_mode_enabled) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.fan_profiles_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Follows FollowerUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>FollowedAt</th>
                                
                                
                                
                                <th>NotificationsEnabled</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.follows_follower_user && Array.isArray(users.follows_follower_user) &&
                              users.follows_follower_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/follows/follows-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="followed_at">
                                        { dataFormatter.dateTimeFormatter(item.followed_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notifications_enabled">
                                        { dataFormatter.booleanFormatter(item.notifications_enabled) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.follows_follower_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Theme_profiles OwnerUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Mode</th>
                                
                                
                                
                                <th>ThemeName</th>
                                
                                
                                
                                <th>PrimaryColorHex</th>
                                
                                
                                
                                <th>AccentColorHex</th>
                                
                                
                                
                                <th>NeonGlowColorHex</th>
                                
                                
                                
                                <th>RGBCycleEnabled</th>
                                
                                
                                
                                <th>RGBCycleSpeed</th>
                                
                                
                                
                                <th>HolidayPalette</th>
                                
                                
                                
                                <th>AdultPaletteEnabled</th>
                                
                                
                                
                                <th>AdultPrimaryColorHex</th>
                                
                                
                                
                                <th>AdultAccentColorHex</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.theme_profiles_owner_user && Array.isArray(users.theme_profiles_owner_user) &&
                              users.theme_profiles_owner_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/theme_profiles/theme_profiles-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="mode">
                                        { item.mode }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="theme_name">
                                        { item.theme_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="primary_color_hex">
                                        { item.primary_color_hex }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="accent_color_hex">
                                        { item.accent_color_hex }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="neon_glow_color_hex">
                                        { item.neon_glow_color_hex }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="rgb_cycle_enabled">
                                        { dataFormatter.booleanFormatter(item.rgb_cycle_enabled) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="rgb_cycle_speed">
                                        { item.rgb_cycle_speed }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="holiday_palette">
                                        { item.holiday_palette }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="adult_palette_enabled">
                                        { dataFormatter.booleanFormatter(item.adult_palette_enabled) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="adult_primary_color_hex">
                                        { item.adult_primary_color_hex }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="adult_accent_color_hex">
                                        { item.adult_accent_color_hex }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.theme_profiles_owner_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Profile_styles OwnerUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>StyleName</th>
                                
                                
                                
                                <th>UsernameColorHex</th>
                                
                                
                                
                                <th>BioFontFamily</th>
                                
                                
                                
                                <th>PanelOrderJSON</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>ProfileLayout</th>
                                
                                
                                
                                <th>ShowPronounsBadge</th>
                                
                                
                                
                                <th>PronounsText</th>
                                
                                
                                
                                <th>CustomCSS</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.profile_styles_owner_user && Array.isArray(users.profile_styles_owner_user) &&
                              users.profile_styles_owner_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/profile_styles/profile_styles-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="style_name">
                                        { item.style_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="username_color_hex">
                                        { item.username_color_hex }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="bio_font_family">
                                        { item.bio_font_family }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="panel_order_json">
                                        { item.panel_order_json }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="profile_layout">
                                        { item.profile_layout }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="show_pronouns_badge">
                                        { dataFormatter.booleanFormatter(item.show_pronouns_badge) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="pronouns_text">
                                        { item.pronouns_text }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="custom_css">
                                        { item.custom_css }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.profile_styles_owner_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Comments AuthorUser</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>TargetKey</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>PostedAt</th>
                                
                                
                                
                                <th>IsHidden</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.comments_author_user && Array.isArray(users.comments_author_user) &&
                              users.comments_author_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/comments/comments-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="target_type">
                                        { item.target_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="target_key">
                                        { item.target_key }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="posted_at">
                                        { dataFormatter.dateTimeFormatter(item.posted_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_hidden">
                                        { dataFormatter.booleanFormatter(item.is_hidden) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.comments_author_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Playlists OwnerUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>PlaylistName</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>Visibility</th>
                                
                                
                                
                                <th>Collaborative</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.playlists_owner_user && Array.isArray(users.playlists_owner_user) &&
                              users.playlists_owner_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/playlists/playlists-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="visibility">
                                        { item.visibility }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="collaborative">
                                        { dataFormatter.booleanFormatter(item.collaborative) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.playlists_owner_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Tips FromUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Amount</th>
                                
                                
                                
                                <th>Currency</th>
                                
                                
                                
                                
                                
                                <th>IsAnonymous</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>SentAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.tips_from_user && Array.isArray(users.tips_from_user) &&
                              users.tips_from_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/tips/tips-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="amount">
                                        { item.amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="is_anonymous">
                                        { dataFormatter.booleanFormatter(item.is_anonymous) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sent_at">
                                        { dataFormatter.dateTimeFormatter(item.sent_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.tips_from_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Alert_profiles OwnerUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ProfileName</th>
                                
                                
                                
                                <th>BrandPrimaryHex</th>
                                
                                
                                
                                <th>BrandAccentHex</th>
                                
                                
                                
                                <th>AnimationStyle</th>
                                
                                
                                
                                
                                
                                <th>TTSEnabled</th>
                                
                                
                                
                                <th>TTSVoice</th>
                                
                                
                                
                                <th>TemplateStyle</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.alert_profiles_owner_user && Array.isArray(users.alert_profiles_owner_user) &&
                              users.alert_profiles_owner_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/alert_profiles/alert_profiles-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="profile_name">
                                        { item.profile_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="brand_primary_hex">
                                        { item.brand_primary_hex }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="brand_accent_hex">
                                        { item.brand_accent_hex }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="animation_style">
                                        { item.animation_style }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="tts_enabled">
                                        { dataFormatter.booleanFormatter(item.tts_enabled) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tts_voice">
                                        { item.tts_voice }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="template_style">
                                        { item.template_style }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.alert_profiles_owner_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Orders BuyerUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Subtotal</th>
                                
                                
                                
                                <th>ShippingCost</th>
                                
                                
                                
                                <th>TaxTotal</th>
                                
                                
                                
                                <th>Total</th>
                                
                                
                                
                                <th>Currency</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>PaymentMethod</th>
                                
                                
                                
                                <th>PlacedAt</th>
                                
                                
                                
                                <th>PaidAt</th>
                                
                                
                                
                                <th>FulfilledAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.orders_buyer_user && Array.isArray(users.orders_buyer_user) &&
                              users.orders_buyer_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/orders/orders-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="subtotal">
                                        { item.subtotal }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="shipping_cost">
                                        { item.shipping_cost }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tax_total">
                                        { item.tax_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="total">
                                        { item.total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="payment_method">
                                        { item.payment_method }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="placed_at">
                                        { dataFormatter.dateTimeFormatter(item.placed_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="paid_at">
                                        { dataFormatter.dateTimeFormatter(item.paid_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="fulfilled_at">
                                        { dataFormatter.dateTimeFormatter(item.fulfilled_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.orders_buyer_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Messages FromUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Subject</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>SentAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.messages_from_user && Array.isArray(users.messages_from_user) &&
                              users.messages_from_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/messages/messages-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="subject">
                                        { item.subject }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sent_at">
                                        { dataFormatter.dateTimeFormatter(item.sent_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.messages_from_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Reports ReporterUser</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>TargetKey</th>
                                
                                
                                
                                <th>Reason</th>
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>ReportedAt</th>
                                
                                
                                
                                <th>ResolvedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.reports_reporter_user && Array.isArray(users.reports_reporter_user) &&
                              users.reports_reporter_user.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_key">
                                        { item.target_key }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reason">
                                        { item.reason }
                                    </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>
                        {!users?.reports_reporter_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Demo_wallets OwnerUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>AvailableBalance</th>
                                
                                
                                
                                <th>LifetimeEarned</th>
                                
                                
                                
                                <th>LifetimeSpent</th>
                                
                                
                                
                                <th>Currency</th>
                                
                                
                                
                                <th>PayoutsEnabled</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.demo_wallets_owner_user && Array.isArray(users.demo_wallets_owner_user) &&
                              users.demo_wallets_owner_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/demo_wallets/demo_wallets-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="available_balance">
                                        { item.available_balance }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="lifetime_earned">
                                        { item.lifetime_earned }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="lifetime_spent">
                                        { item.lifetime_spent }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="payouts_enabled">
                                        { dataFormatter.booleanFormatter(item.payouts_enabled) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.demo_wallets_owner_user?.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;