From 1cafcdc3f7815549eb7d20dc36bca5a8fdaa8fa7 Mon Sep 17 00:00:00 2001 From: German Urrustarazu Date: Fri, 1 Jul 2022 15:46:58 -0300 Subject: [PATCH 1/3] update field validation --- .../client/src/components/CommunityCreate/StepOne.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/packages/client/src/components/CommunityCreate/StepOne.js b/frontend/packages/client/src/components/CommunityCreate/StepOne.js index 18f3ed62c..e7d856e4f 100644 --- a/frontend/packages/client/src/components/CommunityCreate/StepOne.js +++ b/frontend/packages/client/src/components/CommunityCreate/StepOne.js @@ -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, }; const isValid = Object.keys(requiredFields).every( (field) => stepData && requiredFields[field](stepData[field]) From 853e705b02df34fa10c761a63a5dfa66c4f3d533 Mon Sep 17 00:00:00 2001 From: German Urrustarazu Date: Fri, 1 Jul 2022 15:54:54 -0300 Subject: [PATCH 2/3] update logo upload --- frontend/packages/client/src/hooks/useCommunity.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/packages/client/src/hooks/useCommunity.js b/frontend/packages/client/src/hooks/useCommunity.js index da927ca90..69e58bbbf 100644 --- a/frontend/packages/client/src/hooks/useCommunity.js +++ b/frontend/packages/client/src/hooks/useCommunity.js @@ -83,9 +83,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) { try { communityLogo = await uploadFile(logo.file); } catch (err) { From bad961f7149d29588bf24d7138dbcf5184494dd2 Mon Sep 17 00:00:00 2001 From: German Urrustarazu Date: Fri, 1 Jul 2022 17:59:24 -0300 Subject: [PATCH 3/3] rem default flow logo and use blockies for community logo --- .../Community/CommunitiesPresenter.js | 3 +- .../src/components/Community/CommunityCard.js | 31 ++++++---- .../Community/CommunityEditorProfile.js | 6 +- .../client/src/hooks/useCommunityDetails.js | 8 +-- .../packages/client/src/pages/Community.js | 62 +++++++++++++------ frontend/packages/client/src/pages/Home.js | 1 - 6 files changed, 71 insertions(+), 40 deletions(-) diff --git a/frontend/packages/client/src/components/Community/CommunitiesPresenter.js b/frontend/packages/client/src/components/Community/CommunitiesPresenter.js index 7f7c3aaf9..bf993a9e9 100644 --- a/frontend/packages/client/src/components/Community/CommunitiesPresenter.js +++ b/frontend/packages/client/src/components/Community/CommunitiesPresenter.js @@ -32,7 +32,7 @@ const CommunitiesPresenter = ({

{title}

{communities.map((community, index) => { - const { logo, name, description, id, isComingSoon } = community; + const { logo, name, description, id, isComingSoon, slug } = community; return (
); diff --git a/frontend/packages/client/src/components/Community/CommunityCard.js b/frontend/packages/client/src/components/Community/CommunityCard.js index 1293c29ef..2f93855bd 100644 --- a/frontend/packages/client/src/components/Community/CommunityCard.js +++ b/frontend/packages/client/src/components/Community/CommunityCard.js @@ -3,12 +3,12 @@ import { Link } from 'react-router-dom'; import JoinCommunityButton from './JoinCommunityButton'; import WrapperResponsive from 'components/WrapperResponsive'; import { useWindowDimensions } from 'hooks'; - +import Blockies from 'react-blockies'; /** * CommunityCard will group communities on a row bases, * will use elementsPerRow to determine how many communities to render per row */ -const CommunityCard = ({ logo, name, description, id }) => { +const CommunityCard = ({ logo, name, description, id, slug }) => { const descriptionStyle = { lineHeight: '1.5em', height: '3em', @@ -55,15 +55,24 @@ const CommunityCard = ({ logo, name, description, id }) => {
-
+ {logo ? ( +
+ ) : ( + + )}
@@ -150,7 +152,7 @@ function CommunityEditorProfile({ )} - {image && ( + {image?.imageUrl && (
{community ? (
-
- community banner -
-
- community banner +
+ {logo ? ( + community banner + ) : ( + + )}

{community.name}

diff --git a/frontend/packages/client/src/pages/Home.js b/frontend/packages/client/src/pages/Home.js index d2cda7bf4..45cda8dab 100644 --- a/frontend/packages/client/src/pages/Home.js +++ b/frontend/packages/client/src/pages/Home.js @@ -15,7 +15,6 @@ export default function HomePage() { : (data || []).map((datum) => ({ ...datum, // missing fields - logo: datum.logo || 'https://i.imgur.com/RMKXPCw.png', isComingSoon: datum.isComingSoon || false, }));