import React, { useCallback, useState } from 'react'; import { Box, Text, Icon, Icons, Chip, Button } 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'; type AccountDataProps = { expand: boolean; onExpandToggle: (expand: boolean) => void; onSelect: (type: string | null) => void; }; export function AccountData({ expand, onExpandToggle, onSelect }: AccountDataProps) { const mx = useMatrixClient(); const [accountData, setAccountData] = useState(() => Array.from(mx.store.accountData.values())); useAccountDataCallback( mx, useCallback( () => setAccountData(Array.from(mx.store.accountData.values())), [mx, setAccountData] ) ); return ( Account Data onExpandToggle(!expand)} variant="Secondary" fill="Soft" size="300" radii="300" outlined before={ } > {expand ? 'Collapse' : 'Expand'} } /> {expand && ( Types } onClick={() => onSelect(null)} > Add New {accountData.map((mEvent) => ( onSelect(mEvent.getType())} > {mEvent.getType()} ))} )} ); }