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'}>Oauth_accounts User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Provider</th>
                                
                                
                                
                                <th>Provideruserkey</th>
                                
                                
                                
                                <th>Accesstoken</th>
                                
                                
                                
                                <th>Refreshtoken</th>
                                
                                
                                
                                <th>Tokenexpiresat</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.oauth_accounts_user && Array.isArray(users.oauth_accounts_user) &&
                              users.oauth_accounts_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/oauth_accounts/oauth_accounts-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="provider">
                                        { item.provider }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="provider_user_key">
                                        { item.provider_user_key }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="access_token">
                                        { item.access_token }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="refresh_token">
                                        { item.refresh_token }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="token_expires_at">
                                        { dataFormatter.dateTimeFormatter(item.token_expires_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.oauth_accounts_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Artist_profiles User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Artistname</th>
                                
                                
                                
                                <th>Profiletype</th>
                                
                                
                                
                                <th>Legalname</th>
                                
                                
                                
                                <th>Country</th>
                                
                                
                                
                                <th>City</th>
                                
                                
                                
                                <th>Taxresidency</th>
                                
                                
                                
                                <th>Payoutcurrency</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>WebsiteURL</th>
                                
                                
                                
                                <th>VKURL</th>
                                
                                
                                
                                <th>YouTubeURL</th>
                                
                                
                                
                                <th>TikTokURL</th>
                                
                                
                                
                                <th>InstagramURL</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.artist_profiles_user && Array.isArray(users.artist_profiles_user) &&
                              users.artist_profiles_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/artist_profiles/artist_profiles-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="artist_name">
                                        { item.artist_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="profile_type">
                                        { item.profile_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="legal_name">
                                        { item.legal_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="country">
                                        { item.country }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="city">
                                        { item.city }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tax_residency">
                                        { item.tax_residency }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="payout_currency">
                                        { item.payout_currency }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="website_url">
                                        { item.website_url }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="vk_url">
                                        { item.vk_url }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="youtube_url">
                                        { item.youtube_url }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tiktok_url">
                                        { item.tiktok_url }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="instagram_url">
                                        { item.instagram_url }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.artist_profiles_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Teams Owner</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Teamname</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.teams_owner && Array.isArray(users.teams_owner) &&
                              users.teams_owner.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/teams/teams-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.teams_owner?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Team_memberships Memberuser</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>Invitedat</th>
                                
                                
                                
                                <th>Acceptedat</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.team_memberships_member_user && Array.isArray(users.team_memberships_member_user) &&
                              users.team_memberships_member_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/team_memberships/team_memberships-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="role">
                                        { item.role }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="invited_at">
                                        { dataFormatter.dateTimeFormatter(item.invited_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="accepted_at">
                                        { dataFormatter.dateTimeFormatter(item.accepted_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.team_memberships_member_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Subscriptions User</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>Startsat</th>
                                
                                
                                
                                <th>Endsat</th>
                                
                                
                                
                                <th>Autorenew</th>
                                
                                
                                
                                <th>Externalbillingkey</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.subscriptions_user && Array.isArray(users.subscriptions_user) &&
                              users.subscriptions_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/subscriptions/subscriptions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="starts_at">
                                        { dataFormatter.dateTimeFormatter(item.starts_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ends_at">
                                        { dataFormatter.dateTimeFormatter(item.ends_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="auto_renew">
                                        { dataFormatter.booleanFormatter(item.auto_renew) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="external_billing_key">
                                        { item.external_billing_key }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.subscriptions_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Wallets User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Currency</th>
                                
                                
                                
                                <th>Availablebalance</th>
                                
                                
                                
                                <th>Pendingbalance</th>
                                
                                
                                
                                <th>Lifetimeearned</th>
                                
                                
                                
                                <th>Lifetimepaidout</th>
                                
                                
                                
                                <th>Minimumwithdrawalamount</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.wallets_user && Array.isArray(users.wallets_user) &&
                              users.wallets_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/wallets/wallets-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="available_balance">
                                        { item.available_balance }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="pending_balance">
                                        { item.pending_balance }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="lifetime_earned">
                                        { item.lifetime_earned }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="lifetime_paid_out">
                                        { item.lifetime_paid_out }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="minimum_withdrawal_amount">
                                        { item.minimum_withdrawal_amount }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.wallets_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Payout_methods User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Methodtype</th>
                                
                                
                                
                                <th>Methodlabel</th>
                                
                                
                                
                                <th>Accountidentifier</th>
                                
                                
                                
                                <th>Holdername</th>
                                
                                
                                
                                <th>Country</th>
                                
                                
                                
                                <th>Isdefault</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.payout_methods_user && Array.isArray(users.payout_methods_user) &&
                              users.payout_methods_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/payout_methods/payout_methods-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="method_type">
                                        { item.method_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="method_label">
                                        { item.method_label }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="account_identifier">
                                        { item.account_identifier }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="holder_name">
                                        { item.holder_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="country">
                                        { item.country }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_default">
                                        { dataFormatter.booleanFormatter(item.is_default) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.payout_methods_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Tax_documents User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Documenttype</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Issuedat</th>
                                
                                
                                
                                <th>Expiresat</th>
                                
                                
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.tax_documents_user && Array.isArray(users.tax_documents_user) &&
                              users.tax_documents_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/tax_documents/tax_documents-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="document_type">
                                        { item.document_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="issued_at">
                                        { dataFormatter.dateTimeFormatter(item.issued_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="expires_at">
                                        { dataFormatter.dateTimeFormatter(item.expires_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.tax_documents_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Notifications User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Channel</th>
                                
                                
                                
                                <th>Eventtype</th>
                                
                                
                                
                                <th>Title</th>
                                
                                
                                
                                <th>Message</th>
                                
                                
                                
                                <th>Scheduledat</th>
                                
                                
                                
                                <th>Sentat</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Providerreference</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.notifications_user && Array.isArray(users.notifications_user) &&
                              users.notifications_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/notifications/notifications-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="channel">
                                        { item.channel }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="event_type">
                                        { item.event_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="message">
                                        { item.message }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="scheduled_at">
                                        { dataFormatter.dateTimeFormatter(item.scheduled_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sent_at">
                                        { dataFormatter.dateTimeFormatter(item.sent_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="provider_reference">
                                        { item.provider_reference }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.notifications_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Notification_preferences User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Emailenabled</th>
                                
                                
                                
                                <th>Pushenabled</th>
                                
                                
                                
                                <th>Telegramenabled</th>
                                
                                
                                
                                <th>SMSenabled</th>
                                
                                
                                
                                <th>Inappenabled</th>
                                
                                
                                
                                <th>Releaseupdatesenabled</th>
                                
                                
                                
                                <th>Financeupdatesenabled</th>
                                
                                
                                
                                <th>Playlistupdatesenabled</th>
                                
                                
                                
                                <th>Marketingupdatesenabled</th>
                                
                                
                                
                                <th>Quiethours</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.notification_preferences_user && Array.isArray(users.notification_preferences_user) &&
                              users.notification_preferences_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/notification_preferences/notification_preferences-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="email_enabled">
                                        { dataFormatter.booleanFormatter(item.email_enabled) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="push_enabled">
                                        { dataFormatter.booleanFormatter(item.push_enabled) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="telegram_enabled">
                                        { dataFormatter.booleanFormatter(item.telegram_enabled) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sms_enabled">
                                        { dataFormatter.booleanFormatter(item.sms_enabled) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="in_app_enabled">
                                        { dataFormatter.booleanFormatter(item.in_app_enabled) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="release_updates_enabled">
                                        { dataFormatter.booleanFormatter(item.release_updates_enabled) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="finance_updates_enabled">
                                        { dataFormatter.booleanFormatter(item.finance_updates_enabled) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="playlist_updates_enabled">
                                        { dataFormatter.booleanFormatter(item.playlist_updates_enabled) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="marketing_updates_enabled">
                                        { dataFormatter.booleanFormatter(item.marketing_updates_enabled) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="quiet_hours">
                                        { item.quiet_hours }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.notification_preferences_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Api_keys User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Keyname</th>
                                
                                
                                
                                <th>Keyprefix</th>
                                
                                
                                
                                <th>Keyhash</th>
                                
                                
                                
                                <th>Scopes</th>
                                
                                
                                
                                <th>Lastusedat</th>
                                
                                
                                
                                <th>Expiresat</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.api_keys_user && Array.isArray(users.api_keys_user) &&
                              users.api_keys_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/api_keys/api_keys-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="key_prefix">
                                        { item.key_prefix }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="key_hash">
                                        { item.key_hash }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="scopes">
                                        { item.scopes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="last_used_at">
                                        { dataFormatter.dateTimeFormatter(item.last_used_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="expires_at">
                                        { dataFormatter.dateTimeFormatter(item.expires_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.api_keys_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Dashboard_widgets User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Widgettype</th>
                                
                                
                                
                                <th>Sortorder</th>
                                
                                
                                
                                <th>Isvisible</th>
                                
                                
                                
                                <th>SettingsJSON</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.dashboard_widgets_user && Array.isArray(users.dashboard_widgets_user) &&
                              users.dashboard_widgets_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/dashboard_widgets/dashboard_widgets-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="widget_type">
                                        { item.widget_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sort_order">
                                        { item.sort_order }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_visible">
                                        { dataFormatter.booleanFormatter(item.is_visible) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="settings_json">
                                        { item.settings_json }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.dashboard_widgets_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Activity_events User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Eventkind</th>
                                
                                
                                
                                <th>Headline</th>
                                
                                
                                
                                <th>Details</th>
                                
                                
                                
                                <th>Occurredat</th>
                                
                                
                                
                                <th>Entityname</th>
                                
                                
                                
                                <th>Entitykey</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.activity_events_user && Array.isArray(users.activity_events_user) &&
                              users.activity_events_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/activity_events/activity_events-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="event_kind">
                                        { item.event_kind }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="headline">
                                        { item.headline }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="details">
                                        { item.details }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="occurred_at">
                                        { dataFormatter.dateTimeFormatter(item.occurred_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_name">
                                        { item.entity_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_key">
                                        { item.entity_key }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.activity_events_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Referral_links Referreruser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Code</th>
                                
                                
                                
                                <th>LandingURL</th>
                                
                                
                                
                                <th>Isactive</th>
                                
                                
                                
                                <th>Createdon</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.referral_links_referrer_user && Array.isArray(users.referral_links_referrer_user) &&
                              users.referral_links_referrer_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/referral_links/referral_links-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="code">
                                        { item.code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="landing_url">
                                        { item.landing_url }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="created_on">
                                        { dataFormatter.dateTimeFormatter(item.created_on) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.referral_links_referrer_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Referral_conversions Referreduser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Convertedat</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Commissionamount</th>
                                
                                
                                
                                <th>Currency</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.referral_conversions_referred_user && Array.isArray(users.referral_conversions_referred_user) &&
                              users.referral_conversions_referred_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/referral_conversions/referral_conversions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="converted_at">
                                        { dataFormatter.dateTimeFormatter(item.converted_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="commission_amount">
                                        { item.commission_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.referral_conversions_referred_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;