import React, { useEffect, useState } from 'react'; import AnimatedSVG, { ICONS } from 'Shared/AnimatedSVG/AnimatedSVG'; import { useModal } from 'App/components/Modal'; import { useStore } from 'App/mstore'; import { observer } from 'mobx-react-lite'; import { List, Space, Typography, Button, Tooltip, Empty } from 'antd'; import { PlusIcon, Tags } from 'lucide-react'; import { EditOutlined } from '@ant-design/icons'; import usePageTitle from '@/hooks/usePageTitle'; import CustomFieldForm from './CustomFieldForm'; import { useTranslation } from 'react-i18next'; function CustomFields() { usePageTitle('Metadata - OpenReplay Preferences'); const { t } = useTranslation(); const { customFieldStore: store, projectsStore } = useStore(); const currentSite = projectsStore.config.project; const { showModal } = useModal(); const fields = store.list; const [loading, setLoading] = useState(false); useEffect(() => { setLoading(true); store.fetchList(currentSite?.id).finally(() => { setLoading(false); }); }, [currentSite]); const handleInit = (field?: any) => { store.init(field); showModal(, { title: field ? t('Edit Metadata') : t('Add Metadata'), right: true, }); }; const remaining = 10 - fields.length; return (
{t('Attach key-value pairs to session replays for enhanced filtering, searching, and identifying relevant user sessions.')} {t('Learn more')} 0 ? '' : t("You've reached the limit of 10 metadata.") } > {/* {remaining === 0 && } */} {remaining === 0 ? t('You have reached the limit of 10 metadata.') : `${remaining}${t('/10 Remaining for this project')}`} } /> ), }} loading={loading} dataSource={fields} renderItem={(field: any) => ( handleInit(field)} className="cursor-pointer group hover:bg-active-blue !px-4" actions={[
); } export default observer(CustomFields);