diff --git a/frontend/src/components/Profiles/index.js b/frontend/src/components/Profiles/index.js index 304d9e66..45e300ab 100644 --- a/frontend/src/components/Profiles/index.js +++ b/frontend/src/components/Profiles/index.js @@ -6,6 +6,9 @@ import { getProfileImageSrcString } from '../../squeakimages/images'; import Loader from '../Loader' import SqueakCard from '../SqueakCard' +import { Form, Input, Select, Checkbox, Relevant, Debug, TextArea, Option } from 'informed'; + + import { unwrapResult } from '@reduxjs/toolkit' import { useDispatch } from 'react-redux' @@ -19,225 +22,216 @@ import { const Profiles = (props) => { - const [tab, setTab] = useState('Signing Profiles') - const [signingProfileModalOpen, setSigningProfileModalOpen] = useState(false) - const [contactProfileModalOpen, setContactProfileModalOpen] = useState(false) - const [styleBody, setStyleBody] = useState(false) - const [newProfileName, setNewProfileName] = useState('') - const [newProfilePubkey, setNewProfilePubkey] = useState('') - const [usePrivKey, setUsePrivKey] = useState(false) - const [newProfilePrivkey, setNewProfilePrivkey] = useState('') + const [tab, setTab] = useState('Signing Profiles') + const [signingProfileModalOpen, setSigningProfileModalOpen] = useState(false) + const [contactProfileModalOpen, setContactProfileModalOpen] = useState(false) + const [styleBody, setStyleBody] = useState(false) + const dispatch = useDispatch() - const dispatch = useDispatch() - - const searchOnChange = (param) => { - if(tab !== 'Search'){setTab('Search')} - if(param.length>0){ - // TODO: search for a profile by name. - } + const searchOnChange = (param) => { + if(tab !== 'Search'){setTab('Search')} + if(param.length>0){ + // TODO: search for a profile by name. } + } - const toggleSigningProfileModal = (param, type) => { - setStyleBody(!styleBody) - setTimeout(()=>{ setSigningProfileModalOpen(!signingProfileModalOpen) },20) + const toggleSigningProfileModal = (param, type) => { + setStyleBody(!styleBody) + setTimeout(()=>{ setSigningProfileModalOpen(!signingProfileModalOpen) },20) + } + + const toggleContactProfileModal = (param, type) => { + setStyleBody(!styleBody) + setTimeout(()=>{ setContactProfileModalOpen(!contactProfileModalOpen) },20) + } + + const createSigningProfile = ({values}) => { + console.log(values); + if (values.importExisting) { + console.log('Import signing profile with name:', values.name); + dispatch(setImportSigningProfile({profileName: values.name, privateKey: values.privateKey})) + .then(unwrapResult) + .then((pubkey) => { + console.log('Created profile with pubkey', pubkey); + props.history.push(`/app/profile/${pubkey}`); + }) + .catch((err) => { + alert(err.message); + }); + } else { + console.log('Create signing profile with name:', values.name); + dispatch(setCreateSigningProfile({profileName: values.name})) + .then(unwrapResult) + .then((pubkey) => { + console.log('Created profile with pubkey', pubkey); + props.history.push(`/app/profile/${pubkey}`); + }) + .catch((err) => { + alert(err.message); + }); } + toggleSigningProfileModal(); + } - const toggleContactProfileModal = (param, type) => { - setStyleBody(!styleBody) - setTimeout(()=>{ setContactProfileModalOpen(!contactProfileModalOpen) },20) - } + const createContactProfile = ({values}) => { + dispatch(setCreateContactProfile({profileName: values.name, pubkey: values.pubkey})) + .then(unwrapResult) + .then((pubkey) => { + console.log('Created profile with pubkey', pubkey); + props.history.push(`/app/profile/${pubkey}`); + }) + .catch((err) => { + alert(err.message); + }); + toggleContactProfileModal(); + } - const createSigningProfile = () => { - if (usePrivKey) { - console.log('Import signing profile with name:', newProfileName); - dispatch(setImportSigningProfile({profileName: newProfileName, privateKey: newProfilePrivkey})) - .then(unwrapResult) - .then((pubkey) => { - console.log('Created profile with pubkey', pubkey); - props.history.push(`/app/profile/${pubkey}`); - }) - .catch((err) => { - alert(err.message); - }); - } else { - console.log('Create signing profile with name:', newProfileName); - dispatch(setCreateSigningProfile({profileName: newProfileName})) - .then(unwrapResult) - .then((pubkey) => { - console.log('Created profile with pubkey', pubkey); - props.history.push(`/app/profile/${pubkey}`); - }) - .catch((err) => { - alert(err.message); - }); - } - toggleSigningProfileModal(); - } + const handleModalClick = (e) => { + e.stopPropagation() + } - const createContactProfile = () => { - dispatch(setCreateContactProfile({profileName: newProfileName, pubkey: newProfilePubkey})) - .then(unwrapResult) - .then((pubkey) => { - console.log('Created profile with pubkey', pubkey); - props.history.push(`/app/profile/${pubkey}`); - }) - .catch((err) => { - alert(err.message); - }); - toggleContactProfileModal(); - } + const CreateSigningProfileForm = () => ( +
+ ); - const handleChangeUsePrivKey = () => { - setUsePrivKey(!usePrivKey); - }; + const CreateContactProfileForm = () => ( + + ); - return( -Add Signing Profile
Add Signing Profile
- -Add Contact Profile
Add Contact Profile
- -Add Twitter Account
- -