import React, { useCallback, useState } from 'react'; import { Box, Text, Icon, Icons, Button, MenuItem } from 'folds'; import { SequenceCard } from '../../../components/sequence-card'; import { SequenceCardStyle } from '../styles.css'; import { SettingTile } from '../../../components/setting-tile'; import { useMatrixClient } from '../../../hooks/useMatrixClient'; import { useAccountDataCallback } from '../../../hooks/useAccountDataCallback'; import { CutoutCard } from '../../../components/cutout-card'; type AccountDataProps = { expand: boolean; onExpandToggle: (expand: boolean) => void; onSelect: (type: string | null) => void; }; export function AccountData({ expand, onExpandToggle, onSelect }: AccountDataProps) { const mx = useMatrixClient(); const [accountDataTypes, setAccountDataKeys] = useState(() => Array.from(mx.store.accountData.keys()) ); useAccountDataCallback( mx, useCallback(() => { setAccountDataKeys(Array.from(mx.store.accountData.keys())); }, [mx]) ); return ( Account Data onExpandToggle(!expand)} variant="Secondary" fill="Soft" size="300" radii="300" outlined before={ } > {expand ? 'Collapse' : 'Expand'} } /> {expand && ( Events Total: {accountDataTypes.length} } onClick={() => onSelect(null)} > Add New {accountDataTypes.sort().map((type) => ( } onClick={() => onSelect(type)} > {type} ))} )} ); }