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


const Brand_voice_profilesView = () => {
    const router = useRouter()
    const dispatch = useAppDispatch()
    const { brand_voice_profiles } = useAppSelector((state) => state.brand_voice_profiles)
    

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

              

              

              

              

              

              

              

              

              

              
              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Brand</p>
                    
                    
                    
                    
                    
                    
                    
                    
                        <p>{brand_voice_profiles?.brand?.brand_name ?? 'No data'}</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                </div>
                 
              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>ProfileName</p>
                    <p>{brand_voice_profiles?.profile_name}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

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

              

              

              

              

              

              

              

              

              

              
              

              

              
                <FormField label='Multi Text' hasTextareaHeight>
                  <textarea className={'w-full'} disabled value={brand_voice_profiles?.do_say_examples} />
                </FormField>
              

              

              

              

              

              

              

              

              

              

              

              
              

              

              
                <FormField label='Multi Text' hasTextareaHeight>
                  <textarea className={'w-full'} disabled value={brand_voice_profiles?.dont_say_examples} />
                </FormField>
              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>EnglishVariant</p>
                    <p>{brand_voice_profiles?.english_variant ?? 'No data'}</p>
                </div>
              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>ReadingLevelTarget</p>
                  <p>{brand_voice_profiles?.reading_level_target || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>FormalityLevel</p>
                  <p>{brand_voice_profiles?.formality_level || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>EmpathyLevel</p>
                  <p>{brand_voice_profiles?.empathy_level || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>EnergyLevel</p>
                  <p>{brand_voice_profiles?.energy_level || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>HumorLevel</p>
                  <p>{brand_voice_profiles?.humor_level || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>RiskTolerance</p>
                  <p>{brand_voice_profiles?.risk_tolerance || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

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

              

              

              

              
              

              

              

              

              

              

              

              

              

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

              

              

              

              
              

                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Ad_projects BrandVoiceProfile</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ProjectName</th>
                                
                                
                                
                                <th>Channel</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {brand_voice_profiles.ad_projects_brand_voice_profile && Array.isArray(brand_voice_profiles.ad_projects_brand_voice_profile) &&
                              brand_voice_profiles.ad_projects_brand_voice_profile.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/ad_projects/ad_projects-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="project_name">
                                        { item.project_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="channel">
                                        { item.channel }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!brand_voice_profiles?.ad_projects_brand_voice_profile?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                
                
                
                
                
                

                <BaseDivider />

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

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

export default Brand_voice_profilesView;