Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
hive
wallet
Commits
118dafa0
Commit
118dafa0
authored
Aug 31, 2019
by
/ /\ / /\/
Browse files
feat, complete community creation form
parent
245defd0
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/app/components/elements/CreateCommunity.jsx
View file @
118dafa0
...
...
@@ -29,6 +29,7 @@ const CreateCommunity = ({
updateCommunityOwnerAccountName
,
updateCommunityOwnerWifPassword
,
})
=>
{
console
.
log
(
'
success:
'
,
communityCreateSuccess
);
const
handleCommunityTitleInput
=
e
=>
{
if
(
e
.
target
.
value
.
length
>
32
)
{
return
;
...
...
@@ -118,57 +119,73 @@ const CreateCommunity = ({
<
input
type
=
"submit"
value
=
"Submit"
/>
);
const
createCommunitySuccessMessage
=
(
<
div
>
Your community was created!
<
a
href
=
{
`https://steemitdev.com/trending/
${
communityOwnerName
}
`
}
>
Visit your community.
</
a
>
</
div
>
);
const
createCommunityLoading
=
<
div
>
Creating the community.
</
div
>;
const
createCommunityForm
=
(
<
form
onSubmit
=
{
handleCommunitySubmit
}
>
<
div
>
CREATE A COMMUNITY
</
div
>
<
label
htmlFor
=
"community_title"
>
Title
<
input
id
=
"community_title"
name
=
"community_title"
type
=
"text"
minLength
=
"4"
maxLength
=
"30"
onChange
=
{
handleCommunityTitleInput
}
value
=
{
communityTitle
}
required
/>
</
label
>
<
label
htmlFor
=
"community_description"
>
Description
<
input
id
=
"community_description"
name
=
"community_description"
type
=
"text"
minLength
=
"10"
maxLength
=
"140"
onChange
=
{
handleCommunityDescriptionInput
}
value
=
{
communityDescription
}
required
/>
</
label
>
<
label
id
=
"is_nsfw"
htmlFor
=
"is_nsfw"
>
Is NSFW.
<
input
type
=
"checkbox"
name
=
"is_nsfw"
checked
=
{
communityNSFW
}
onChange
=
{
handleCommunityNSFWInput
}
/>
</
label
>
{
communityOwnerWifPassword
.
length
<=
0
&&
generateCommunityCredentialsButton
}
{
communityOwnerWifPassword
.
length
>
0
&&
rememberCredentialsPrompt
}
{
communityOwnerWifPassword
.
length
>
0
&&
rememberCredentialsCheckbox1
}
{
communityOwnerWifPassword
.
length
>
0
&&
rememberCredentialsCheckbox2
}
{
communityOwnerWifPassword
.
length
>
0
&&
submitCreateCommunityFormButton
}
</
form
>
);
return
(
<
div
className
=
"row"
>
<
div
className
=
"column large-6 small-12"
>
<
form
onSubmit
=
{
handleCommunitySubmit
}
>
<
div
>
CREATE A COMMUNITY
</
div
>
<
label
htmlFor
=
"community_title"
>
Title
<
input
id
=
"community_title"
name
=
"community_title"
type
=
"text"
minLength
=
"4"
maxLength
=
"30"
onChange
=
{
handleCommunityTitleInput
}
value
=
{
communityTitle
}
required
/>
</
label
>
<
label
htmlFor
=
"community_description"
>
Description
<
input
id
=
"community_description"
name
=
"community_description"
type
=
"text"
minLength
=
"10"
maxLength
=
"140"
onChange
=
{
handleCommunityDescriptionInput
}
value
=
{
communityDescription
}
required
/>
</
label
>
<
label
id
=
"is_nsfw"
htmlFor
=
"is_nsfw"
>
Is NSFW.
<
input
type
=
"checkbox"
name
=
"is_nsfw"
checked
=
{
communityNSFW
}
onChange
=
{
handleCommunityNSFWInput
}
/>
</
label
>
{
communityOwnerWifPassword
.
length
<=
0
&&
generateCommunityCredentialsButton
}
{
communityOwnerWifPassword
.
length
>
0
&&
rememberCredentialsPrompt
}
{
communityOwnerWifPassword
.
length
>
0
&&
rememberCredentialsCheckbox1
}
{
communityOwnerWifPassword
.
length
>
0
&&
rememberCredentialsCheckbox2
}
{
communityOwnerWifPassword
.
length
>
0
&&
submitCreateCommunityFormButton
}
</
form
>
{
communityCreatePending
?
createCommunityLoading
:
createCommunityForm
}
{
communityCreateSuccess
&&
createCommunitySuccessMessage
}
</
div
>
</
div
>
);
...
...
src/app/redux/CommunityReducer.js
View file @
118dafa0
...
...
@@ -11,11 +11,11 @@ const SET_COMMUNITY_OWNER_WIF_PASSWORD =
'
community/SET_COMMUNITY_OWNER_MASTER_PASSWORD
'
;
export
const
CREATE_COMMUNITY_ACCOUNT
=
'
community/CREATE_COMMUNITY_ACCOUNT
'
;
// Has saga.
const
CREATE_COMMUNITY_ACCOUNT_PENDING
=
export
const
CREATE_COMMUNITY_ACCOUNT_PENDING
=
'
community/CREATE_COMMUNITY_ACCOUNT_PENDING
'
;
const
CREATE_COMMUNITY_ACCOUNT_ERROR
=
export
const
CREATE_COMMUNITY_ACCOUNT_ERROR
=
'
community/CREATE_COMMUNITY_ACCOUNT_ERROR
'
;
const
CREATE_COMMUNITY_SUCCESS
=
'
community/CREATE_COMMUNITY_SUCCESS
'
;
export
const
CREATE_COMMUNITY_SUCCESS
=
'
community/CREATE_COMMUNITY_SUCCESS
'
;
const
COMMUNITY_HIVEMIND_OPERATION
=
'
community/COMMUNITY_HIVEMIND_OPERATION
'
;
// Has saga.
const
COMMUNITY_HIVEMIND_OPERATION_PENDING
=
...
...
@@ -133,10 +133,11 @@ export const createCommunityAccountError = payload => ({
type
:
CREATE_COMMUNITY_ACCOUNT_ERROR
,
payload
,
});
export
const
createCommunity
Account
Success
=
payload
=>
({
export
const
createCommunitySuccess
=
payload
=>
({
type
:
CREATE_COMMUNITY_SUCCESS
,
payload
,
});
export
const
communityHivemindOperation
=
payload
=>
({
type
:
COMMUNITY_HIVEMIND_OPERATION
,
payload
,
...
...
src/app/redux/CommunitySaga.js
View file @
118dafa0
...
...
@@ -4,6 +4,7 @@ import { PrivateKey, PublicKey } from '@steemit/steem-js/lib/auth/ecc';
import
steem
,
{
api
,
broadcast
,
auth
,
memo
}
from
'
@steemit/steem-js
'
;
import
*
as
communityActions
from
'
./CommunityReducer
'
;
import
{
wait
}
from
'
./MarketSaga
'
;
import
{
send
}
from
'
@steemit/steem-js/lib/broadcast
'
;
// TODO: use steem endpoint from env var.
const
dSteemClient
=
new
dsteem
.
Client
(
'
https://api.steemit.com
'
);
...
...
@@ -45,7 +46,7 @@ export const communityWatches = [
export
function
*
createCommunityAccount
(
createCommunityAction
)
{
yield
put
({
type
:
communityActions
.
createCommunityAccountPending
,
type
:
communityActions
.
CREATE_COMMUNITY_ACCOUNT_PENDING
,
payload
:
true
,
});
const
{
...
...
@@ -59,7 +60,6 @@ export function* createCommunityAccount(createCommunityAction) {
try
{
// Get the currently logged in user active key.
const
creatorActiveKey
=
yield
select
(
activeKeySelector
);
const
op
=
{
fee
:
'
3.00 STEEM
'
,
creator
:
accountName
,
...
...
@@ -100,28 +100,19 @@ export function* createCommunityAccount(createCommunityAction) {
// The client cannot submit custom_json and account_create in the same block. The easiest way around this, for now, is to pause for 3 seconds after the account is created before submitting the ops.
yield
call
(
wait
,
3000
);
debugger
;
/*
const communityOwnerPosting = dsteem.PrivateKey.fromLogin(
communityOwnerName,
communityOwnerWifPassword,
'posting'
);
*/
const
communityOwnerPosting
=
yield
call
(
[
api
,
auth
.
getPrivateKeys
],
const
communityOwnerPosting
=
auth
.
getPrivateKeys
(
communityOwnerName
,
communityOwnerWifPassword
,
'
posting
'
[
'
posting
'
]
);
debugger
;
const
setRoleOperation
=
generateHivemindOperation
(
'
setRole
'
,
{
communityOwnerName
,
account
:
accountName
,
role
:
'
admin
'
},
communityOwnerName
,
communityOwnerPosting
);
// TODO: Should this op update the community description and NSFW prop?
const
updatePropsOperation
=
generateHivemindOperation
(
'
updateProps
'
,
...
...
@@ -130,24 +121,23 @@ export function* createCommunityAccount(createCommunityAction) {
communityOwnerPosting
);
yield
call
(
[
dSteemClient
,
dSteemClient
.
broadcast
.
send
Operations
],
[
api
,
broadcast
.
send
],
[
setRoleOperation
,
updatePropsOperation
]
);
debugger
;
yield
put
({
type
:
communityActions
.
createCommunitySuccess
,
type
:
communityActions
.
CREATE_COMMUNITY_SUCCESS
,
payload
:
true
,
});
}
catch
(
error
)
{
debugger
;
console
.
log
(
error
);
console
.
log
(
'
ERR!:
'
,
error
);
yield
put
({
type
:
communityActions
.
createCommunityAccountError
,
type
:
communityActions
.
CREATE_COMMUNITY_ACCOUNT_ERROR
,
payload
:
true
,
});
}
yield
put
({
type
:
communityActions
.
createCommunityAccountPending
,
type
:
communityActions
.
CREATE_COMMUNITY_ACCOUNT_PENDING
,
payload
:
false
,
});
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment