import React, { useEffect, useState } from 'react'; import { useStore } from 'App/mstore'; import { observer } from 'mobx-react-lite'; import { Loader } from 'UI'; import { Switch, Checkbox, Tag } from 'antd'; import GDPR from 'App/mstore/types/gdpr'; import cn from 'classnames'; import Select from 'Shared/Select'; import CodeSnippet from 'Shared/CodeSnippet'; import CircleNumber from 'Components/Onboarding/components/CircleNumber'; import Project from '@/mstore/types/project'; import stl from './projectCodeSnippet.module.css'; import { useTranslation } from 'react-i18next'; import { TFunction } from 'i18next'; interface InputModeOption { label: string; value: string; } const inputModeOptions: (t: TFunction) => InputModeOption[] = (t) => [ { label: t('Record all inputs'), value: 'plain' }, { label: t('Ignore all inputs'), value: 'obscured' }, { label: t('Obscure all inputs'), value: 'hidden' }, ]; interface Props { project: Project; } const ProjectCodeSnippet: React.FC = (props) => { const { t } = useTranslation(); const { projectsStore } = useStore(); const { siteId } = projectsStore; const site = props.project; const gdpr = site.gdpr as GDPR; const sites = projectsStore.list; const { editGDPR } = projectsStore; const onSaveGDPR = projectsStore.saveGDPR; const init = projectsStore.initProject; const [changed, setChanged] = useState(false); const [isAssistEnabled, setAssistEnabled] = useState(false); const [showLoader, setShowLoader] = useState(false); useEffect(() => { const currentSite = sites.find((s) => s.id === siteId); if (currentSite) { init(currentSite); } }, [init, siteId, sites]); const saveGDPR = () => { setChanged(true); void onSaveGDPR(site.id); }; const onChangeSelect = (data: { name: string; value: string }) => { editGDPR({ [data.name]: data.value }); saveGDPR(); }; const onChangeOption = (name: string, checked: boolean) => { editGDPR({ [name]: checked }); saveGDPR(); }; useEffect(() => { setShowLoader(true); const timer = setTimeout(() => { setShowLoader(false); }, 200); return () => clearTimeout(timer); }, [isAssistEnabled]); return (
{t('Choose data recording options')}