Skip to content

Commit

Permalink
HF 30 - Private group, some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
1aerostorm committed Jul 6, 2024
1 parent 8dfa1f4 commit 5d150a8
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 4 deletions.
45 changes: 44 additions & 1 deletion src/components/elements/common/AccountName/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ import Userpic from 'app/components/elements/Userpic'
class AccountName extends React.Component {
constructor(props) {
super(props)
this.state = {
defaultOptions: [],
isLoading: true,
}
this.ref = React.createRef()
}

lookupAccounts = async (value) => {
try {
//await new Promise(resolve => setTimeout(resolve, 2000))
const { includeFrozen, filterAccounts } = this.props
const accNames = await api.lookupAccountsAsync(value.toLowerCase(), 6, {
include_frozen: includeFrozen,
Expand All @@ -33,16 +39,53 @@ class AccountName extends React.Component {
}
}

onMenuOpen = async (e) => {
const { current } = this.ref
if (!current) { console.warn('No AsyncSelect ref'); return; }
const target = current.inputRef
if (!target) { console.warn('No inputRef'); return; }
const { value } = target
if (!value) {
this.setState({
isLoading: true,
defaultOptions: []
}, async () => {
const defaultOptions = await this.lookupAccounts('')
this.setState({
isLoading: false,
defaultOptions
})
})
}
}

testIt = (e) => {
e.preventDefault()
console.log(this.state.dop)
if (this.state.dop === true)
this.setState({
dop: []
}); else this.setState({
dop: true
})
}

render() {
const { onChange, className, ...rest } = this.props
const { defaultOptions, isLoading } = this.state
// isOptionSelected = false disables blue bg if opened not first time
return <AsyncSelect
placeholder={tt('g.name')}
loadingMessage={() => tt('account_name_jsx.loading')}
noOptionsMessage={() => tt('account_name_jsx.no_options')}

loadOptions={this.lookupAccounts}
defaultOptions={true}
isLoading={isLoading}
defaultOptions={defaultOptions}
cacheOptions={false}
onMenuOpen={this.onMenuOpen}
ref={this.ref}
isOptionSelected={() => false}

className={'AccountName ' + (className || ' ')}
getOptionLabel={(option) => {
Expand Down
5 changes: 3 additions & 2 deletions src/components/modules/CreateGroup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class CreateGroup extends React.Component {
const gbgBalance = Asset(sbd_balance)
if (gbgBalance.gte(cost)) {
this.setState({
cost,
loaded: true
})
return
Expand Down Expand Up @@ -179,7 +180,7 @@ class CreateGroup extends React.Component {
}

render() {
const { step, loaded, createError, validators, submitError } = this.state
const { step, loaded, createError, validators, submitError, cost } = this.state

let form
if (!loaded) {
Expand Down Expand Up @@ -218,7 +219,7 @@ class CreateGroup extends React.Component {
return (
<Form>

{!isSubmitting ? (step === 'name' ? <GroupName values={values} applyFieldValue={applyFieldValue} /> :
{!isSubmitting ? (step === 'name' ? <GroupName values={values} applyFieldValue={applyFieldValue} cost={cost} /> :
step === 'logo' ? <GroupLogo isValidating={!!validators} values={values} errors={errors} applyFieldValue={applyFieldValue} /> :
step === 'members' ? <GroupMembers newGroup={values} applyFieldValue={applyFieldValue} /> :
step === 'final' ? <GroupFinal submitError={submitError} /> :
Expand Down
14 changes: 13 additions & 1 deletion src/components/modules/groups/GroupName.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default class GroupName extends React.Component {
}

render() {
const { values } = this.props
const { values, cost } = this.props
return <React.Fragment>
<div className='row' style={{ marginTop: '1.0rem', marginBottom: '1.0rem' }}>
<div className='column small-5' style={{paddingTop: 5}}>
Expand Down Expand Up @@ -147,6 +147,18 @@ export default class GroupName extends React.Component {
<ErrorMessage name='is_encrypted' component='div' className='error' />
</div>
</div>

{cost ? <div className='row' style={{ marginTop: '1.0rem', marginBottom: '1.0rem' }}>
<div className='column small-12'>
<b style={{ fontSize: '100%' }}>
<Icon name='editor/coin' size='1x' />
<span style={{ marginLeft: '0.35rem', verticalAlign: 'middle' }}>
{tt('create_group_jsx.gbg_too_low')}
<span style={{ color: '#0078C4' }}>{cost.floatString}</span>.
</span>
</b>
</div>
</div> : null}
</React.Fragment>
}
}

0 comments on commit 5d150a8

Please sign in to comment.