import { useEffect, useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { useAIConsentStore } from '@shared/state/ai-consent';
import { AcceptTerms } from '@launch/components/BusinessInformation/AcceptTerms';
import { InfoBox } from '@launch/components/BusinessInformation/InfoBox';
import { SiteTones } from '@launch/components/BusinessInformation/Tones';
import { Title } from '@launch/components/Title';
import { PageLayout } from '@launch/layouts/PageLayout';
import { usePagesStore } from '@launch/state/Pages';
import { pageState } from '@launch/state/factory';
import { useUserSelectionStore } from '@launch/state/user-selections';
export const state = pageState('Business Information', () => ({
ready: true,
canSkip: true,
validation: null,
onRemove: () => {},
}));
export const BusinessInformation = () => (
);
const BusinessInfo = () => {
const { businessInformation, setBusinessInformation } =
useUserSelectionStore();
const [desc, setDesc] = useState(businessInformation?.description || '');
const nextPage = usePagesStore((state) => state.nextPage);
const { userGaveConsent } = useAIConsentStore();
const shouldShowAIConsent = useAIConsentStore((state) =>
state.shouldShowAIConsent('launch'),
);
useEffect(() => {
const timer = setTimeout(() => {
setBusinessInformation('description', desc);
}, 500);
state.setState({ canSkip: !desc });
return () => clearTimeout(timer);
}, [desc, setBusinessInformation]);
useEffect(() => {
if (!shouldShowAIConsent) return;
if (userGaveConsent || !businessInformation.description) {
state.setState({ validation: null });
return;
}
state.setState({
validation: {
message: __('Please accept the terms to continue', 'extendify-local'),
},
});
}, [businessInformation, userGaveConsent, shouldShowAIConsent]);
return (
);
};