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/organizations/organizationsSlice';
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 OrganizationsView = () => {
  const router = useRouter();
  const dispatch = useAppDispatch();
  const { organizations } = useAppSelector((state) => state.organizations);

  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 organizations')}</title>
      </Head>
      <SectionMain>
        <SectionTitleLineWithButton
          icon={mdiChartTimelineVariant}
          title={removeLastCharacter('View organizations')}
          main
        >
          <BaseButton
            color='info'
            label='Edit'
            href={`/organizations/organizations-edit/?id=${id}`}
          />
        </SectionTitleLineWithButton>
        <CardBox>
          <div className={'mb-4'}>
            <p className={'block font-bold mb-2'}>Name</p>
            <p>{organizations?.name}</p>
          </div>

          <>
            <p className={'block font-bold mb-2'}>Users Organizations</p>
            <CardBox
              className='mb-6 border border-gray-300 rounded overflow-hidden'
              hasTable
            >
              <div className='overflow-x-auto'>
                <table>
                  <thead>
                    <tr>
                      <th>First Name</th>

                      <th>Last Name</th>

                      <th>Phone Number</th>

                      <th>E-Mail</th>

                      <th>Disabled</th>
                    </tr>
                  </thead>
                  <tbody>
                    {organizations.users_organizations &&
                      Array.isArray(organizations.users_organizations) &&
                      organizations.users_organizations.map((item: any) => (
                        <tr
                          key={item.id}
                          onClick={() =>
                            router.push(`/users/users-view/?id=${item.id}`)
                          }
                        >
                          <td data-label='firstName'>{item.firstName}</td>

                          <td data-label='lastName'>{item.lastName}</td>

                          <td data-label='phoneNumber'>{item.phoneNumber}</td>

                          <td data-label='email'>{item.email}</td>

                          <td data-label='disabled'>
                            {dataFormatter.booleanFormatter(item.disabled)}
                          </td>
                        </tr>
                      ))}
                  </tbody>
                </table>
              </div>
              {!organizations?.users_organizations?.length && (
                <div className={'text-center py-4'}>No data</div>
              )}
            </CardBox>
          </>

          <>
            <p className={'block font-bold mb-2'}>
              Analytics_daily organizations
            </p>
            <CardBox
              className='mb-6 border border-gray-300 rounded overflow-hidden'
              hasTable
            >
              <div className='overflow-x-auto'>
                <table>
                  <thead>
                    <tr>
                      <th>Date</th>

                      <th>Visits</th>

                      <th>Clicks</th>

                      <th>TopReferrers</th>
                    </tr>
                  </thead>
                  <tbody>
                    {organizations.analytics_daily_organizations &&
                      Array.isArray(
                        organizations.analytics_daily_organizations,
                      ) &&
                      organizations.analytics_daily_organizations.map(
                        (item: any) => (
                          <tr
                            key={item.id}
                            onClick={() =>
                              router.push(
                                `/analytics_daily/analytics_daily-view/?id=${item.id}`,
                              )
                            }
                          >
                            <td data-label='date'>
                              {dataFormatter.dateTimeFormatter(item.date)}
                            </td>

                            <td data-label='visits'>{item.visits}</td>

                            <td data-label='clicks'>{item.clicks}</td>

                            <td data-label='top_referrers'>
                              {item.top_referrers}
                            </td>
                          </tr>
                        ),
                      )}
                  </tbody>
                </table>
              </div>
              {!organizations?.analytics_daily_organizations?.length && (
                <div className={'text-center py-4'}>No data</div>
              )}
            </CardBox>
          </>

          <>
            <p className={'block font-bold mb-2'}>
              Analytics_events organizations
            </p>
            <CardBox
              className='mb-6 border border-gray-300 rounded overflow-hidden'
              hasTable
            >
              <div className='overflow-x-auto'>
                <table>
                  <thead>
                    <tr>
                      <th>EventType</th>

                      <th>Referrer</th>

                      <th>UserAgent</th>

                      <th>IPHash</th>

                      <th>OccurredAt</th>
                    </tr>
                  </thead>
                  <tbody>
                    {organizations.analytics_events_organizations &&
                      Array.isArray(
                        organizations.analytics_events_organizations,
                      ) &&
                      organizations.analytics_events_organizations.map(
                        (item: any) => (
                          <tr
                            key={item.id}
                            onClick={() =>
                              router.push(
                                `/analytics_events/analytics_events-view/?id=${item.id}`,
                              )
                            }
                          >
                            <td data-label='event_type'>{item.event_type}</td>

                            <td data-label='referrer'>{item.referrer}</td>

                            <td data-label='user_agent'>{item.user_agent}</td>

                            <td data-label='ip_hash'>{item.ip_hash}</td>

                            <td data-label='occurred_at'>
                              {dataFormatter.dateTimeFormatter(
                                item.occurred_at,
                              )}
                            </td>
                          </tr>
                        ),
                      )}
                  </tbody>
                </table>
              </div>
              {!organizations?.analytics_events_organizations?.length && (
                <div className={'text-center py-4'}>No data</div>
              )}
            </CardBox>
          </>

          <>
            <p className={'block font-bold mb-2'}>Audit_logs organizations</p>
            <CardBox
              className='mb-6 border border-gray-300 rounded overflow-hidden'
              hasTable
            >
              <div className='overflow-x-auto'>
                <table>
                  <thead>
                    <tr>
                      <th>Action</th>

                      <th>TargetType</th>

                      <th>TargetID</th>

                      <th>Meta</th>
                    </tr>
                  </thead>
                  <tbody>
                    {organizations.audit_logs_organizations &&
                      Array.isArray(organizations.audit_logs_organizations) &&
                      organizations.audit_logs_organizations.map(
                        (item: any) => (
                          <tr
                            key={item.id}
                            onClick={() =>
                              router.push(
                                `/audit_logs/audit_logs-view/?id=${item.id}`,
                              )
                            }
                          >
                            <td data-label='action'>{item.action}</td>

                            <td data-label='target_type'>{item.target_type}</td>

                            <td data-label='target_id'>{item.target_id}</td>

                            <td data-label='meta'>{item.meta}</td>
                          </tr>
                        ),
                      )}
                  </tbody>
                </table>
              </div>
              {!organizations?.audit_logs_organizations?.length && (
                <div className={'text-center py-4'}>No data</div>
              )}
            </CardBox>
          </>

          <>
            <p className={'block font-bold mb-2'}>Blocks organizations</p>
            <CardBox
              className='mb-6 border border-gray-300 rounded overflow-hidden'
              hasTable
            >
              <div className='overflow-x-auto'>
                <table>
                  <thead>
                    <tr>
                      <th>Type</th>

                      <th>OrderIndex</th>

                      <th>Visible</th>

                      <th>Config</th>
                    </tr>
                  </thead>
                  <tbody>
                    {organizations.blocks_organizations &&
                      Array.isArray(organizations.blocks_organizations) &&
                      organizations.blocks_organizations.map((item: any) => (
                        <tr
                          key={item.id}
                          onClick={() =>
                            router.push(`/blocks/blocks-view/?id=${item.id}`)
                          }
                        >
                          <td data-label='type'>{item.type}</td>

                          <td data-label='order_index'>{item.order_index}</td>

                          <td data-label='visible'>
                            {dataFormatter.booleanFormatter(item.visible)}
                          </td>

                          <td data-label='config'>{item.config}</td>
                        </tr>
                      ))}
                  </tbody>
                </table>
              </div>
              {!organizations?.blocks_organizations?.length && (
                <div className={'text-center py-4'}>No data</div>
              )}
            </CardBox>
          </>

          <>
            <p className={'block font-bold mb-2'}>Button_links organizations</p>
            <CardBox
              className='mb-6 border border-gray-300 rounded overflow-hidden'
              hasTable
            >
              <div className='overflow-x-auto'>
                <table>
                  <thead>
                    <tr>
                      <th>Label</th>

                      <th>URL</th>

                      <th>Icon</th>

                      <th>Enabled</th>

                      <th>OrderIndex</th>

                      <th>ClickCount</th>
                    </tr>
                  </thead>
                  <tbody>
                    {organizations.button_links_organizations &&
                      Array.isArray(organizations.button_links_organizations) &&
                      organizations.button_links_organizations.map(
                        (item: any) => (
                          <tr
                            key={item.id}
                            onClick={() =>
                              router.push(
                                `/button_links/button_links-view/?id=${item.id}`,
                              )
                            }
                          >
                            <td data-label='label'>{item.label}</td>

                            <td data-label='url'>{item.url}</td>

                            <td data-label='icon'>{item.icon}</td>

                            <td data-label='enabled'>
                              {dataFormatter.booleanFormatter(item.enabled)}
                            </td>

                            <td data-label='order_index'>{item.order_index}</td>

                            <td data-label='click_count'>{item.click_count}</td>
                          </tr>
                        ),
                      )}
                  </tbody>
                </table>
              </div>
              {!organizations?.button_links_organizations?.length && (
                <div className={'text-center py-4'}>No data</div>
              )}
            </CardBox>
          </>

          <>
            <p className={'block font-bold mb-2'}>
              Domain_mappings organizations
            </p>
            <CardBox
              className='mb-6 border border-gray-300 rounded overflow-hidden'
              hasTable
            >
              <div className='overflow-x-auto'>
                <table>
                  <thead>
                    <tr>
                      <th>Domain</th>

                      <th>Status</th>

                      <th>VerificationToken</th>

                      <th>SSLStatus</th>
                    </tr>
                  </thead>
                  <tbody>
                    {organizations.domain_mappings_organizations &&
                      Array.isArray(
                        organizations.domain_mappings_organizations,
                      ) &&
                      organizations.domain_mappings_organizations.map(
                        (item: any) => (
                          <tr
                            key={item.id}
                            onClick={() =>
                              router.push(
                                `/domain_mappings/domain_mappings-view/?id=${item.id}`,
                              )
                            }
                          >
                            <td data-label='domain'>{item.domain}</td>

                            <td data-label='status'>{item.status}</td>

                            <td data-label='verification_token'>
                              {item.verification_token}
                            </td>

                            <td data-label='ssl_status'>{item.ssl_status}</td>
                          </tr>
                        ),
                      )}
                  </tbody>
                </table>
              </div>
              {!organizations?.domain_mappings_organizations?.length && (
                <div className={'text-center py-4'}>No data</div>
              )}
            </CardBox>
          </>

          <>
            <p className={'block font-bold mb-2'}>Email_logs organizations</p>
            <CardBox
              className='mb-6 border border-gray-300 rounded overflow-hidden'
              hasTable
            >
              <div className='overflow-x-auto'>
                <table>
                  <thead>
                    <tr>
                      <th>Type</th>

                      <th>ToEmail</th>

                      <th>ProviderID</th>

                      <th>Status</th>
                    </tr>
                  </thead>
                  <tbody>
                    {organizations.email_logs_organizations &&
                      Array.isArray(organizations.email_logs_organizations) &&
                      organizations.email_logs_organizations.map(
                        (item: any) => (
                          <tr
                            key={item.id}
                            onClick={() =>
                              router.push(
                                `/email_logs/email_logs-view/?id=${item.id}`,
                              )
                            }
                          >
                            <td data-label='type'>{item.type}</td>

                            <td data-label='to_email'>{item.to_email}</td>

                            <td data-label='provider_id'>{item.provider_id}</td>

                            <td data-label='status'>{item.status}</td>
                          </tr>
                        ),
                      )}
                  </tbody>
                </table>
              </div>
              {!organizations?.email_logs_organizations?.length && (
                <div className={'text-center py-4'}>No data</div>
              )}
            </CardBox>
          </>

          <>
            <p className={'block font-bold mb-2'}>
              Feature_flags organizations
            </p>
            <CardBox
              className='mb-6 border border-gray-300 rounded overflow-hidden'
              hasTable
            >
              <div className='overflow-x-auto'>
                <table>
                  <thead>
                    <tr>
                      <th>Key</th>

                      <th>Value</th>
                    </tr>
                  </thead>
                  <tbody>
                    {organizations.feature_flags_organizations &&
                      Array.isArray(
                        organizations.feature_flags_organizations,
                      ) &&
                      organizations.feature_flags_organizations.map(
                        (item: any) => (
                          <tr
                            key={item.id}
                            onClick={() =>
                              router.push(
                                `/feature_flags/feature_flags-view/?id=${item.id}`,
                              )
                            }
                          >
                            <td data-label='key'>{item.key}</td>

                            <td data-label='value'>
                              {dataFormatter.booleanFormatter(item.value)}
                            </td>
                          </tr>
                        ),
                      )}
                  </tbody>
                </table>
              </div>
              {!organizations?.feature_flags_organizations?.length && (
                <div className={'text-center py-4'}>No data</div>
              )}
            </CardBox>
          </>

          <>
            <p className={'block font-bold mb-2'}>Flags organizations</p>
            <CardBox
              className='mb-6 border border-gray-300 rounded overflow-hidden'
              hasTable
            >
              <div className='overflow-x-auto'>
                <table>
                  <thead>
                    <tr>
                      <th>Reason</th>

                      <th>Status</th>

                      <th>Notes</th>
                    </tr>
                  </thead>
                  <tbody>
                    {organizations.flags_organizations &&
                      Array.isArray(organizations.flags_organizations) &&
                      organizations.flags_organizations.map((item: any) => (
                        <tr
                          key={item.id}
                          onClick={() =>
                            router.push(`/flags/flags-view/?id=${item.id}`)
                          }
                        >
                          <td data-label='reason'>{item.reason}</td>

                          <td data-label='status'>{item.status}</td>

                          <td data-label='notes'>{item.notes}</td>
                        </tr>
                      ))}
                  </tbody>
                </table>
              </div>
              {!organizations?.flags_organizations?.length && (
                <div className={'text-center py-4'}>No data</div>
              )}
            </CardBox>
          </>

          <>
            <p className={'block font-bold mb-2'}>Media_assets organizations</p>
            <CardBox
              className='mb-6 border border-gray-300 rounded overflow-hidden'
              hasTable
            >
              <div className='overflow-x-auto'>
                <table>
                  <thead>
                    <tr>
                      <th>URL</th>

                      <th>Type</th>

                      <th>Width</th>

                      <th>Height</th>

                      <th>SizeBytes</th>
                    </tr>
                  </thead>
                  <tbody>
                    {organizations.media_assets_organizations &&
                      Array.isArray(organizations.media_assets_organizations) &&
                      organizations.media_assets_organizations.map(
                        (item: any) => (
                          <tr
                            key={item.id}
                            onClick={() =>
                              router.push(
                                `/media_assets/media_assets-view/?id=${item.id}`,
                              )
                            }
                          >
                            <td data-label='url'>{item.url}</td>

                            <td data-label='type'>{item.type}</td>

                            <td data-label='width'>{item.width}</td>

                            <td data-label='height'>{item.height}</td>

                            <td data-label='size_bytes'>{item.size_bytes}</td>
                          </tr>
                        ),
                      )}
                  </tbody>
                </table>
              </div>
              {!organizations?.media_assets_organizations?.length && (
                <div className={'text-center py-4'}>No data</div>
              )}
            </CardBox>
          </>

          <>
            <p className={'block font-bold mb-2'}>
              Payment_transactions organizations
            </p>
            <CardBox
              className='mb-6 border border-gray-300 rounded overflow-hidden'
              hasTable
            >
              <div className='overflow-x-auto'>
                <table>
                  <thead>
                    <tr>
                      <th>AmountCents</th>

                      <th>Currency</th>

                      <th>PSPProvider</th>

                      <th>PSPTransactionID</th>

                      <th>Status</th>
                    </tr>
                  </thead>
                  <tbody>
                    {organizations.payment_transactions_organizations &&
                      Array.isArray(
                        organizations.payment_transactions_organizations,
                      ) &&
                      organizations.payment_transactions_organizations.map(
                        (item: any) => (
                          <tr
                            key={item.id}
                            onClick={() =>
                              router.push(
                                `/payment_transactions/payment_transactions-view/?id=${item.id}`,
                              )
                            }
                          >
                            <td data-label='amount_cents'>
                              {item.amount_cents}
                            </td>

                            <td data-label='currency'>{item.currency}</td>

                            <td data-label='psp_provider'>
                              {item.psp_provider}
                            </td>

                            <td data-label='psp_txn_id'>{item.psp_txn_id}</td>

                            <td data-label='status'>{item.status}</td>
                          </tr>
                        ),
                      )}
                  </tbody>
                </table>
              </div>
              {!organizations?.payment_transactions_organizations?.length && (
                <div className={'text-center py-4'}>No data</div>
              )}
            </CardBox>
          </>

          <>
            <p className={'block font-bold mb-2'}>Plans organizations</p>
            <CardBox
              className='mb-6 border border-gray-300 rounded overflow-hidden'
              hasTable
            >
              <div className='overflow-x-auto'>
                <table>
                  <thead>
                    <tr>
                      <th>Key</th>

                      <th>Name</th>

                      <th>PriceCents</th>

                      <th>Currency</th>

                      <th>Features</th>

                      <th>IsActive</th>
                    </tr>
                  </thead>
                  <tbody>
                    {organizations.plans_organizations &&
                      Array.isArray(organizations.plans_organizations) &&
                      organizations.plans_organizations.map((item: any) => (
                        <tr
                          key={item.id}
                          onClick={() =>
                            router.push(`/plans/plans-view/?id=${item.id}`)
                          }
                        >
                          <td data-label='key'>{item.key}</td>

                          <td data-label='name'>{item.name}</td>

                          <td data-label='price_cents'>{item.price_cents}</td>

                          <td data-label='currency'>{item.currency}</td>

                          <td data-label='features'>{item.features}</td>

                          <td data-label='is_active'>
                            {dataFormatter.booleanFormatter(item.is_active)}
                          </td>
                        </tr>
                      ))}
                  </tbody>
                </table>
              </div>
              {!organizations?.plans_organizations?.length && (
                <div className={'text-center py-4'}>No data</div>
              )}
            </CardBox>
          </>

          <>
            <p className={'block font-bold mb-2'}>
              Profile_pages organizations
            </p>
            <CardBox
              className='mb-6 border border-gray-300 rounded overflow-hidden'
              hasTable
            >
              <div className='overflow-x-auto'>
                <table>
                  <thead>
                    <tr>
                      <th>Slug</th>

                      <th>Title</th>

                      <th>Bio</th>

                      <th>Status</th>

                      <th>PublishedAt</th>

                      <th>OGTitle</th>

                      <th>OGDescription</th>

                      <th>OGImageURL</th>
                    </tr>
                  </thead>
                  <tbody>
                    {organizations.profile_pages_organizations &&
                      Array.isArray(
                        organizations.profile_pages_organizations,
                      ) &&
                      organizations.profile_pages_organizations.map(
                        (item: any) => (
                          <tr
                            key={item.id}
                            onClick={() =>
                              router.push(
                                `/profile_pages/profile_pages-view/?id=${item.id}`,
                              )
                            }
                          >
                            <td data-label='slug'>{item.slug}</td>

                            <td data-label='title'>{item.title}</td>

                            <td data-label='bio'>{item.bio}</td>

                            <td data-label='status'>{item.status}</td>

                            <td data-label='published_at'>
                              {dataFormatter.dateTimeFormatter(
                                item.published_at,
                              )}
                            </td>

                            <td data-label='og_title'>{item.og_title}</td>

                            <td data-label='og_description'>
                              {item.og_description}
                            </td>

                            <td data-label='og_image_url'>
                              {item.og_image_url}
                            </td>
                          </tr>
                        ),
                      )}
                  </tbody>
                </table>
              </div>
              {!organizations?.profile_pages_organizations?.length && (
                <div className={'text-center py-4'}>No data</div>
              )}
            </CardBox>
          </>

          <>
            <p className={'block font-bold mb-2'}>Social_links organizations</p>
            <CardBox
              className='mb-6 border border-gray-300 rounded overflow-hidden'
              hasTable
            >
              <div className='overflow-x-auto'>
                <table>
                  <thead>
                    <tr>
                      <th>Network</th>

                      <th>Handle</th>

                      <th>URL</th>

                      <th>OrderIndex</th>
                    </tr>
                  </thead>
                  <tbody>
                    {organizations.social_links_organizations &&
                      Array.isArray(organizations.social_links_organizations) &&
                      organizations.social_links_organizations.map(
                        (item: any) => (
                          <tr
                            key={item.id}
                            onClick={() =>
                              router.push(
                                `/social_links/social_links-view/?id=${item.id}`,
                              )
                            }
                          >
                            <td data-label='network'>{item.network}</td>

                            <td data-label='handle'>{item.handle}</td>

                            <td data-label='url'>{item.url}</td>

                            <td data-label='order_index'>{item.order_index}</td>
                          </tr>
                        ),
                      )}
                  </tbody>
                </table>
              </div>
              {!organizations?.social_links_organizations?.length && (
                <div className={'text-center py-4'}>No data</div>
              )}
            </CardBox>
          </>

          <>
            <p className={'block font-bold mb-2'}>
              Subscriptions organizations
            </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>TrialEndsAt</th>

                      <th>CurrentPeriodStart</th>

                      <th>CurrentPeriodEnd</th>

                      <th>CancelAtPeriodEnd</th>

                      <th>PSPCustomerID</th>
                    </tr>
                  </thead>
                  <tbody>
                    {organizations.subscriptions_organizations &&
                      Array.isArray(
                        organizations.subscriptions_organizations,
                      ) &&
                      organizations.subscriptions_organizations.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='trial_ends_at'>
                              {dataFormatter.dateTimeFormatter(
                                item.trial_ends_at,
                              )}
                            </td>

                            <td data-label='current_period_start'>
                              {dataFormatter.dateTimeFormatter(
                                item.current_period_start,
                              )}
                            </td>

                            <td data-label='current_period_end'>
                              {dataFormatter.dateTimeFormatter(
                                item.current_period_end,
                              )}
                            </td>

                            <td data-label='cancel_at_period_end'>
                              {dataFormatter.booleanFormatter(
                                item.cancel_at_period_end,
                              )}
                            </td>

                            <td data-label='psp_customer_id'>
                              {item.psp_customer_id}
                            </td>
                          </tr>
                        ),
                      )}
                  </tbody>
                </table>
              </div>
              {!organizations?.subscriptions_organizations?.length && (
                <div className={'text-center py-4'}>No data</div>
              )}
            </CardBox>
          </>

          <>
            <p className={'block font-bold mb-2'}>Templates organizations</p>
            <CardBox
              className='mb-6 border border-gray-300 rounded overflow-hidden'
              hasTable
            >
              <div className='overflow-x-auto'>
                <table>
                  <thead>
                    <tr>
                      <th>Key</th>

                      <th>Name</th>

                      <th>Variant</th>

                      <th>Colors</th>

                      <th>IsPremium</th>
                    </tr>
                  </thead>
                  <tbody>
                    {organizations.templates_organizations &&
                      Array.isArray(organizations.templates_organizations) &&
                      organizations.templates_organizations.map((item: any) => (
                        <tr
                          key={item.id}
                          onClick={() =>
                            router.push(
                              `/templates/templates-view/?id=${item.id}`,
                            )
                          }
                        >
                          <td data-label='key'>{item.key}</td>

                          <td data-label='name'>{item.name}</td>

                          <td data-label='variant'>{item.variant}</td>

                          <td data-label='colors'>{item.colors}</td>

                          <td data-label='is_premium'>
                            {dataFormatter.booleanFormatter(item.is_premium)}
                          </td>
                        </tr>
                      ))}
                  </tbody>
                </table>
              </div>
              {!organizations?.templates_organizations?.length && (
                <div className={'text-center py-4'}>No data</div>
              )}
            </CardBox>
          </>

          <BaseDivider />

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

OrganizationsView.getLayout = function getLayout(page: ReactElement) {
  return (
    <LayoutAuthenticated permission={'READ_ORGANIZATIONS'}>
      {page}
    </LayoutAuthenticated>
  );
};

export default OrganizationsView;
