-
Notifications
You must be signed in to change notification settings - Fork 10
CAS-169 - update fields validation on community creation #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1cafcdc
853e705
bad961f
eba9d3a
66452a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,10 +107,13 @@ export default function StepOne({ | |
| useEffect(() => { | ||
| const requiredFields = { | ||
| communityName: (name) => name?.trim().length > 0, | ||
| communityDescription: (desc) => desc?.trim().length > 0, | ||
| logo: (logo) => logo?.file && logo?.imageUrl, | ||
| communityDescription: (desc) => | ||
| desc?.trim().length ? desc?.trim().length < 1000 : true, | ||
| logo: (logo) => | ||
| logo !== undefined ? logo?.file && logo?.imageUrl : true, | ||
| communityTerms: (termsUrl) => | ||
| termsUrl?.length > 0 && urlPatternValidation(termsUrl), | ||
| termsUrl?.length > 0 ? urlPatternValidation(termsUrl) : true, | ||
| category: (cat) => cat?.length > 0, | ||
| }; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. most of the important changes are here |
||
| const isValid = Object.keys(requiredFields).every( | ||
| (field) => stepData && requiredFields[field](stepData[field]) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,9 +84,9 @@ export default function useCommunity() { | |
| } = communityData; | ||
|
|
||
| let communityLogo; | ||
| // not handling upload error: there's a default image | ||
| // check for logo upload | ||
| // admins can edit later the image | ||
| if (logo.file) { | ||
| if (logo?.file) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check when creating community if logo was added or not |
||
| try { | ||
| communityLogo = await uploadFile(logo.file); | ||
| } catch (err) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,18 +18,14 @@ export default function useCommunityDetails(id) { | |
| const response = await fetch(url); | ||
| const details = await checkResponse(response); | ||
| // merging with mock data | ||
| const detailsMocked = { | ||
| logo: 'https://i.imgur.com/RMKXPCw.png', | ||
| name: 'Flow', | ||
| description: | ||
| "Flow's decentralized governance and node operations community.", | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't use the logo from flow anymore as default |
||
| const detailsUpdated = { | ||
| about: { | ||
| textAbout: details.body, | ||
| }, | ||
| ...details, | ||
| }; | ||
|
|
||
| dispatch({ type: 'SUCCESS', payload: detailsMocked }); | ||
| dispatch({ type: 'SUCCESS', payload: detailsUpdated }); | ||
| } catch (err) { | ||
| notifyError(err, url); | ||
| dispatch({ type: 'ERROR', payload: { errorData: err.message } }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -216,8 +216,16 @@ export default function Community() { | |
| return null; | ||
| } | ||
|
|
||
| const { instagramUrl, twitterUrl, websiteUrl, discordUrl, githubUrl } = | ||
| community ?? {}; | ||
| const { | ||
| instagramUrl, | ||
| twitterUrl, | ||
| websiteUrl, | ||
| discordUrl, | ||
| githubUrl, | ||
| logo, | ||
| slug, | ||
| id, | ||
| } = community ?? {}; | ||
|
|
||
| const titleClassNames = classnames( | ||
| 'is-size-5 has-text-weight-bold', | ||
|
|
@@ -233,29 +241,45 @@ export default function Community() { | |
| 'is-flex container community-header section', | ||
| { 'is-justify-content-space-between': notMobile } | ||
| ); | ||
|
|
||
| const imageContainerClasses = classnames( | ||
| { '': notMobile }, | ||
| { | ||
| 'is-flex is-flex-direction-column is-justify-content-center m-0 community-logo-wrapper': | ||
| !notMobile, | ||
| } | ||
| ); | ||
| const imageClases = classnames( | ||
| { | ||
| 'rounded-full community-logo-mobile': !notMobile, | ||
| }, | ||
| { | ||
| 'rounded-full': notMobile, | ||
| } | ||
| ); | ||
| return ( | ||
| <section className="full-height pt-0"> | ||
| {community ? ( | ||
| <div className="is-flex community-header-wrapper"> | ||
| <div className={headerContainerClassNames}> | ||
| <div className="is-flex community-specific"> | ||
| <div className="is-hidden-tablet is-mobile is-flex is-flex-direction-column is-justify-content-center m-0 community-logo-wrapper"> | ||
| <img | ||
| className="rounded-full community-logo-mobile" | ||
| alt="community banner" | ||
| src={community.logo} | ||
| height="85px" | ||
| width="85px" | ||
| /> | ||
| </div> | ||
| <div className="is-hidden-mobile"> | ||
| <img | ||
| alt="community banner" | ||
| className="rounded-full" | ||
| src={community.logo} | ||
| height="149px" | ||
| width="149px" | ||
| /> | ||
| <div className={imageContainerClasses}> | ||
| {logo ? ( | ||
| <img | ||
| className={imageClases} | ||
| alt="community banner" | ||
| src={logo} | ||
| height="85px" | ||
| width="85px" | ||
| /> | ||
| ) : ( | ||
| <Blockies | ||
| seed={slug ?? id} | ||
| size={10} | ||
| scale={9.6} | ||
| className="blockies" | ||
| /> | ||
| )} | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| </div> | ||
| <div className="column community-info is-justify-content-space-evenly"> | ||
| <h2 className={titleClassNames}>{community.name}</h2> | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.