import React, { useState } from 'react'; // Polotno and third party imports import { SidePanelWrap } from 'polotno'; import type { StoreType } from 'polotno/model/store'; import { SidePanel as PolotnoSidePanel, DEFAULT_SECTIONS, } from 'polotno/side-panel'; // Custom Sections / Components import CustomTemplateSection from './Templates/customTemplateSection'; import CustomFieldSection from './CustomFields/customFieldSection'; import { CustomUploadsV2Section } from './CustomUploads'; import customAddOns from './CustomAddOns'; import CustomQRCode from './CustomQRCode'; import BlockColors from './CustomBlockColors'; interface Props { store: StoreType; currentTemplateType: string; currentProductId?: number; platformName?: string | null; templateGalleryModal?: boolean; selectedSection?: string; allowSenderFields?: boolean; excludedFields?: string[] | null; designerQueryAmount?: string | number; allowPropertyFields?: boolean; allowedAddOns?: any; allowedTemplateSections?: any; propertyOfferCost?: number; customPropertyOfferCost?: number; gsvCost?: number; currentTheme?: string | null | undefined; onGetOneTemplate?: (payload: any) => Promise; onCreateCustomTemplateQuery?: (payload: any) => Promise; onGetTemplates?: (payload: any) => Promise; onGetCustomFields?: () => Promise; onGetBrandingImages?: (payload: any) => Promise; onDeleteBrandingImage?: (id: string | number) => Promise; onUploadBrandingImage?: (payload: any) => Promise; onGetQRCodes?: (payload: any) => Promise; onDeleteQRCodes?: (id: string | number) => Promise; onUploadQRCode?: (payload: any) => Promise; onEditQRCode?: (payload: any) => Promise; selectedTemplateType?: string | null; } const SidePanel: React.FC = (props) => { const [hireDesignerModal, setHireDesignerModal] = useState(false); const sections = props.currentTemplateType === 'Real Penned Letter' && props.currentProductId === 16 ? DEFAULT_SECTIONS.filter((section) => section.name === '') : DEFAULT_SECTIONS.filter( (section) => !['photos', 'size', 'templates', 'upload'].includes(section.name) ); return ( ( ), }, ...sections, ...(props.currentProductId !== 16 ? [{ ...CustomUploadsV2Section, Panel: (panelProps: any) => ( ), }] : []), { ...CustomFieldSection, Panel: (panelProps: any) => ( ), }, ...(props.currentProductId !== 16 ? [ ...(props.currentProductId !== 4 && props.currentProductId !== 5 && props.currentProductId !== 38 ? [ { ...BlockColors, Panel: (panelProps: any) => ( ), }, ] : []), { ...CustomQRCode, Panel: (panelProps: any) => ( ), }, { ...customAddOns, Panel: (panelProps: any) => ( ), }, ] : [] ) ]} defaultSection="text" /> ); }; export default SidePanel;