import { useState, useEffect, useRef, Fragment } from 'react'; import { useNavigate, useOutletContext, useParams } from 'react-router'; import { Dialog, useTheme, useMediaQuery, DialogTitle, DialogActions, Stack, Button, Tabs, Tab, DialogContent, Paper, Typography, Input, TextField, Card, CardContent, Divider } from '@mui/material'; import { Box } from '@mui/system'; import { useObjectDiscoveryWithResources } from '@hyper-hyper-space/react'; import { HomeContext } from '../HomeSpace'; import { ObjectDiscoveryReply, WordCode, Identity, Hash } from '@hyper-hyper-space/core'; import CircularProgress from '@mui/material/CircularProgress'; import { Contacts, Profile } from '@hyper-hyper-space/home'; import LookupThreeWordCode from './LookupThreeWordCode'; import ImportExportedProfile from './ImportExportedProfile'; function AddContactDialog() { const navigate = useNavigate(); const params = useParams(); const urlProfile = params.profile; const [open, setOpen] = useState(true); const theme = useTheme(); const fullScreen = useMediaQuery(theme.breakpoints.down('md')); const close = () => { setOpen(false); navigate('..'); }; const [method, setMethod] = useState<'code' | 'import'>(urlProfile === undefined ? 'code' : 'import'); // discovery using entered 3-word code const { home, resourcesForDiscovery } = useOutletContext(); const cancel = () => { close(); }; const addContact = async (id: Identity) => { const profile = new Profile(id); await home?.contacts?.current?.add(profile); await home?.contacts?.current?.saveQueuedOps(); if (urlProfile === undefined) { navigate(-1); } else { navigate('/'); } }; const renderIdentity = (id?: Identity) => ( ) // import using exported profile const changeMethod = () => { }; return ( Add new contact setMethod('code')} /> setMethod('import')} /> {method === 'code' && } {method === 'import' && } ); } export default AddContactDialog;