import React, { useEffect, useState } from 'react' import useLocalStorage from '../../../tikexModule/hooks/useLocalStorageTX' import { v4 as uuid } from 'uuid' import { SzamlazzhuVatKey } from '../../../tikexModule/Types/dto/team' import { missingFieldToRunEvent } from '../../../tikexModule/checkEnableSale' import Input from '../../../tikexModule/components/inputs/Input' import Select from '../../../tikexModule/components/inputs/Select' import Switch from '../../../tikexModule/components/inputs/Switch' import SwitchBase from '../../../tikexModule/components/inputs/SwitchPass' import { useAuth } from '../../../tikexModule/hooks/useAuth' import randomString from '../../../tikexModule/utils/randomString' import slugify from '../../../tikexModule/utils/slugify' import Accordion from '../../components/Accordion' import { Plan } from '../../../tikexModule/Types/models/team' import { fetchWithBaseUrl } from '../../../utils/api' export default function EventsEditorContent({ children, }: { children?: React.ReactNode }) { const auth = useAuth() const [teamId, setSelectedTeamId] = useLocalStorage( 'teamIdDashboard', '' ) const [newProductId, setNewProductId] = useState('') const [productId, setProductId] = useLocalStorage( 'productIdDashboard', '' ) const o = auth.userDTO?.teams?.[teamId] const paymentAndInvoiceRecipients = o?.paymentAndInvoiceRecipients const product = o?.ads?.[productId] const pr = product const passTypeOptions = Object.entries(o?.passTypes ?? {}).map( ([passTypeId, passType]) => { return { value: passTypeId, label: `Ár: ${passType.price} - Kapacitás: ${passType.capacity} - Lejárat: ${passType.expirationDays}`, } } ) const missingField = missingFieldToRunEvent(product) useEffect(() => { if (productId) { setNewProductId(productId) } }, [productId]) function countInvoiceItemSchemas(pricingOption: Plan): number { if (!pricingOption || !pricingOption.paymentRecipients) { return 0 } return Object.keys(pricingOption.paymentRecipients).reduce( (totalCount, key) => { const group = pricingOption.paymentRecipients?.[key] if (group?.products) { return totalCount + Object.keys(group.products).length } return totalCount }, 0 ) } if (auth.userDTO) { return <> } else if (auth.isUpdateUserDTOCompleted) { return <>{children} } else { return <> } } /*

Termékek / Események

{productId && product && ( )}

{productId && ( <> {pr?.timeSelectionType == 'oneOrManyTime' && ( )}
[tikex_buy_ticket_form team_slug="{teamId}" program_id=" {pr?.slug}"]
{passTypeOptions?.map(({ value: passTypeId, label }) => ( ))}
{ let newPassTypeIds = [ ...(product?.passTypeIds ?? []), ] if (newSwitchValue === true) { newPassTypeIds = [...newPassTypeIds, passTypeId] } else { newPassTypeIds = newPassTypeIds.filter( (value) => value !== passTypeId ) } auth.updateClientAndServer({ keyPath: [ teamId, 'products', productId, 'passTypeIds', ], value: newPassTypeIds, operation: 'setValue', }) }} /> {label}
{Object.entries(pr?.adSubPages ?? {}) .sort((a, b) => (a[1].ind ?? 0) - (b[1].ind ?? 0)) .map(([k, v], i) => ( <> {Object.entries(pr?.adSubPages ?? {}) .length > 1 && ( <> )} {Object.entries(v.plans ?? {}) .sort((a, b) => a[0].localeCompare(b[0])) .map(([k2a, v2a], i2a) => Object.entries(v2a.paymentRecipients ?? {}) .sort( (a, b) => a[0].localeCompare(b[0]) //(b[1]?.ind ?? 0) - (a[1]?.ind ?? 0) ) .map(([k2, v2], i2) => ( <> {v2.invoiceItemQuantityType == 'flexible' ? ( <> ) : ( )} )) )} ))} {Object.entries(pr?.pricingOptions ?? {}).length > 1 && ( <> )}
{ await fetchWithBaseUrl('sendFinalInvoices', { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${auth.userDTO!.token}`, }, body: JSON.stringify({ teamSlug: teamId, productId: productId, sendOnlyOneInvoice: true, }), }) await auth.updateClientAndServer({ keyPath: [ teamId, 'products', productId, 'isRequiredToSendTestFinalInvoice', ], value: newValue, operation: 'setValue', }) }} keyPath={[ teamId, 'products', productId, 'isRequiredToSendTestFinalInvoice', ]} disabledPrio={pr?.isRequiredToSendTestFinalInvoice} />
{ await fetchWithBaseUrl('sendFinalInvoices', { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${auth.userDTO!.token}`, }, body: JSON.stringify({ teamSlug: teamId, productId: productId, }), }) await auth.updateClientAndServer({ keyPath: [ teamId, 'products', productId, 'isRequiredToStartFinalInvoicing', ], value: newValue, operation: 'setValue', }) }} keyPath={[ teamId, 'products', productId, 'isRequiredToStartFinalInvoicing', ]} disabledPrio={pr?.isRequiredToStartFinalInvoicing} />

Szép munka!{' '} {missingField ? 'Már majdnem kész is vagy' : 'Kész is vagy'}

{missingField ? (
  • Hiányzó adat

    {missingField}

) : ( <> )}
)}
*/