From 553e38eabcfa7aa98c801ce3cfd81a6b952c5c9d Mon Sep 17 00:00:00 2001 From: root Date: Tue, 9 Jan 2024 15:04:03 -0300 Subject: [PATCH 01/11] Validating if user is community or council member --- .../widget/components/button/join-now.jsx | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/apps/builddao/widget/components/button/join-now.jsx b/apps/builddao/widget/components/button/join-now.jsx index bd702768..6821e455 100644 --- a/apps/builddao/widget/components/button/join-now.jsx +++ b/apps/builddao/widget/components/button/join-now.jsx @@ -8,11 +8,20 @@ if (policy === null) { return ""; } +const alreadyJoinedRolesNames = ["community", "council"]; + const deposit = policy.proposal_bond; const roleId = "community"; + const group = policy.roles - .filter((role) => role.name === roleId) - .map((role) => role.kind.Group); + .filter((role) => alreadyJoinedRolesNames.includes(role.name)) + .map((role) => { + return role.kind.Group; + }); + +const accounts = new Set(group[0].concat(group[1])); + +const isCommunityOrCouncilMember = accounts.has(accountId); const proposalId = Near.view(daoId, "get_last_proposal_id") - 1; @@ -26,7 +35,8 @@ if (proposal === null) { } // check if the potential member submitted last proposal -const canJoin = accountId && accountId !== proposal.proposer; +const canJoin = + accountId && accountId !== proposal.proposer && !isCommunityOrCouncilMember; const Button = styled.a` width: max-content; @@ -75,6 +85,8 @@ const Container = styled.div` return ( - {canJoin ? : props.children} + {canJoin ? ( + + ) : props.children} ); From 4b08bc7e5c597e4a52e21d7aeebe88a2ed61a2d7 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 9 Jan 2024 15:10:01 -0300 Subject: [PATCH 02/11] FIX: Removing unused consts --- apps/builddao/widget/components/button/join-now.jsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/apps/builddao/widget/components/button/join-now.jsx b/apps/builddao/widget/components/button/join-now.jsx index 6821e455..84926d51 100644 --- a/apps/builddao/widget/components/button/join-now.jsx +++ b/apps/builddao/widget/components/button/join-now.jsx @@ -10,9 +10,6 @@ if (policy === null) { const alreadyJoinedRolesNames = ["community", "council"]; -const deposit = policy.proposal_bond; -const roleId = "community"; - const group = policy.roles .filter((role) => alreadyJoinedRolesNames.includes(role.name)) .map((role) => { From 9a4a2d7c44825f32e444beb3e0a781ec6cd61766 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 9 Jan 2024 19:22:58 -0300 Subject: [PATCH 03/11] FEATURE: Adding joined bullet text if cannot join --- .../widget/components/button/join-now.jsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/apps/builddao/widget/components/button/join-now.jsx b/apps/builddao/widget/components/button/join-now.jsx index 84926d51..da6d4a17 100644 --- a/apps/builddao/widget/components/button/join-now.jsx +++ b/apps/builddao/widget/components/button/join-now.jsx @@ -35,6 +35,22 @@ if (proposal === null) { const canJoin = accountId && accountId !== proposal.proposer && !isCommunityOrCouncilMember; +const Bullet = styled.div` + width: fit-content; + display: flex; + justify-content: center; + align-items: center; + padding: 4px 12px; + background: rgba(81, 255, 234, 0.20); + color: rgba(81, 255, 234, 1); + border: 1px solid rgba(81, 255, 234, 0.20); + font-family: Satoshi, sans-serif; + font-size: 0.875rem; + font-weight: 500; + border-radius: 8px; +`; + + const Button = styled.a` width: max-content; all: unset; @@ -84,6 +100,6 @@ return ( {canJoin ? ( - ) : props.children} + ) : Joined} ); From 0bfbdd8007b4f9a4ce14a74772e59481656a0227 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 9 Jan 2024 19:30:29 -0300 Subject: [PATCH 04/11] FEATURE: Adding bullet text widget to create-something --- apps/builddao/widget/create-something.jsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/builddao/widget/create-something.jsx b/apps/builddao/widget/create-something.jsx index e2ae81f3..804dd345 100644 --- a/apps/builddao/widget/create-something.jsx +++ b/apps/builddao/widget/create-something.jsx @@ -234,9 +234,7 @@ const CreateSomethingView = (props) => { /> ) : ( <> - - {!validMember ? "Pending..." : "Joined"} - + View Activity{" "} Date: Wed, 10 Jan 2024 13:37:43 -0300 Subject: [PATCH 05/11] FEATURE: Adding ThemeProvider + Bullet component using theme --- apps/builddao/widget/components/Bullet.jsx | 22 +++++++++++++++++ .../widget/components/ThemeProvider.jsx | 24 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 apps/builddao/widget/components/Bullet.jsx create mode 100644 apps/builddao/widget/components/ThemeProvider.jsx diff --git a/apps/builddao/widget/components/Bullet.jsx b/apps/builddao/widget/components/Bullet.jsx new file mode 100644 index 00000000..94b357e6 --- /dev/null +++ b/apps/builddao/widget/components/Bullet.jsx @@ -0,0 +1,22 @@ +const { theme } = VM.require("rambo-dev.near/widget/ThemeProvider"); + +const StyledBullet = styled.div` + width: fit-content; + display: flex; + justify-content: center; + align-items: center; + padding: 4px 12px; + background: ${(props) => `${props.colors.seablue500}33`}; + color: ${(props) => props.colors.seablue500}; + border: 1px solid ${(props) => `${props.colors.seablue500}33`}; + font-family: Satoshi, sans-serif; + font-size: 0.875rem; + font-weight: 500; + border-radius: 8px; +`; + +function Bullet({ children }) { + return {children}; +} + +return { Bullet }; \ No newline at end of file diff --git a/apps/builddao/widget/components/ThemeProvider.jsx b/apps/builddao/widget/components/ThemeProvider.jsx new file mode 100644 index 00000000..d265b6fa --- /dev/null +++ b/apps/builddao/widget/components/ThemeProvider.jsx @@ -0,0 +1,24 @@ +const colors = { + yellow500: "#FFAF51", + seablue500: "#51FFEA", + blue500: "#51B6FF", + bg1: "#0B0C14", + bg2: "#23242B", + black100: "#000000", + black50: "Black/50", + white100: "#FFFFFF", + white50: "White/50", + error: "#FD2A5C", + success: "#38C793", + warning: "#F17B2C", +}; + +Storage.set("theme", { colors }); + +const theme = Storage.get("theme"); + +function ThemeProvider({ children }) { + return
{children}
; +} + +return { ThemeProvider, theme }; \ No newline at end of file From 18d926fc357831128aaf8d38e845460e110cea47 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 10 Jan 2024 13:41:11 -0300 Subject: [PATCH 06/11] Adding Bullet and ThemeProvider components --- apps/builddao/widget/components/Bullet.jsx | 22 +++++++++++++++++ .../widget/components/ThemeProvider.jsx | 24 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 apps/builddao/widget/components/Bullet.jsx create mode 100644 apps/builddao/widget/components/ThemeProvider.jsx diff --git a/apps/builddao/widget/components/Bullet.jsx b/apps/builddao/widget/components/Bullet.jsx new file mode 100644 index 00000000..94b357e6 --- /dev/null +++ b/apps/builddao/widget/components/Bullet.jsx @@ -0,0 +1,22 @@ +const { theme } = VM.require("rambo-dev.near/widget/ThemeProvider"); + +const StyledBullet = styled.div` + width: fit-content; + display: flex; + justify-content: center; + align-items: center; + padding: 4px 12px; + background: ${(props) => `${props.colors.seablue500}33`}; + color: ${(props) => props.colors.seablue500}; + border: 1px solid ${(props) => `${props.colors.seablue500}33`}; + font-family: Satoshi, sans-serif; + font-size: 0.875rem; + font-weight: 500; + border-radius: 8px; +`; + +function Bullet({ children }) { + return {children}; +} + +return { Bullet }; \ No newline at end of file diff --git a/apps/builddao/widget/components/ThemeProvider.jsx b/apps/builddao/widget/components/ThemeProvider.jsx new file mode 100644 index 00000000..d265b6fa --- /dev/null +++ b/apps/builddao/widget/components/ThemeProvider.jsx @@ -0,0 +1,24 @@ +const colors = { + yellow500: "#FFAF51", + seablue500: "#51FFEA", + blue500: "#51B6FF", + bg1: "#0B0C14", + bg2: "#23242B", + black100: "#000000", + black50: "Black/50", + white100: "#FFFFFF", + white50: "White/50", + error: "#FD2A5C", + success: "#38C793", + warning: "#F17B2C", +}; + +Storage.set("theme", { colors }); + +const theme = Storage.get("theme"); + +function ThemeProvider({ children }) { + return
{children}
; +} + +return { ThemeProvider, theme }; \ No newline at end of file From 3c1fdd271498fbb3d52ea94c1c012e631554dd10 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 10 Jan 2024 15:33:54 -0300 Subject: [PATCH 07/11] FEATURE: Adding variants according to figma pending and joined bullet text state --- apps/builddao/widget/components/Bullet.jsx | 30 +++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/apps/builddao/widget/components/Bullet.jsx b/apps/builddao/widget/components/Bullet.jsx index 94b357e6..77fdaa8e 100644 --- a/apps/builddao/widget/components/Bullet.jsx +++ b/apps/builddao/widget/components/Bullet.jsx @@ -6,17 +6,35 @@ const StyledBullet = styled.div` justify-content: center; align-items: center; padding: 4px 12px; - background: ${(props) => `${props.colors.seablue500}33`}; - color: ${(props) => props.colors.seablue500}; - border: 1px solid ${(props) => `${props.colors.seablue500}33`}; - font-family: Satoshi, sans-serif; + font-family: Aeonik, sans-serif; font-size: 0.875rem; font-weight: 500; border-radius: 8px; + ${({ variant, theme }) => { + const isDefault = variant === "default"; + + const background = isDefault + ? theme.colors.blue500 + : theme.colors.seablue500; + const color = isDefault ? theme.colors.blue500 : theme.colors.seablue500; + const border = `1px solid ${background}33`; + + return ` + background: ${background}33; + color: ${color}; + border: ${border}; + `; + }} `; -function Bullet({ children }) { - return {children}; +function Bullet({ children, variant }) { + const defaultVariant = variant || "default"; + + return ( + + {children} + + ); } return { Bullet }; \ No newline at end of file From a6a2378574bb53479f3307e1169ea78c3fd3676a Mon Sep 17 00:00:00 2001 From: root Date: Wed, 10 Jan 2024 20:06:32 -0300 Subject: [PATCH 08/11] FIX: Review items --- .../{create-something.jsx => JoinSection.jsx} | 22 +++++++++---- .../widget/components/ThemeProvider.jsx | 6 +--- .../join-now.jsx => buttons/JoinNow.jsx} | 16 ++++++--- src/components/navigation/Navbar.js | 33 ++++++------------- src/pages/JoinPage.js | 2 +- 5 files changed, 38 insertions(+), 41 deletions(-) rename apps/builddao/widget/{create-something.jsx => JoinSection.jsx} (91%) rename apps/builddao/widget/components/{button/join-now.jsx => buttons/JoinNow.jsx} (78%) diff --git a/apps/builddao/widget/create-something.jsx b/apps/builddao/widget/JoinSection.jsx similarity index 91% rename from apps/builddao/widget/create-something.jsx rename to apps/builddao/widget/JoinSection.jsx index e2ae81f3..2bc6cd88 100644 --- a/apps/builddao/widget/create-something.jsx +++ b/apps/builddao/widget/JoinSection.jsx @@ -138,6 +138,8 @@ const CTASection = styled.div` const userWidgets = Social.keys(`${context.accountId}/widget/**`) || []; +const { Bullet } = VM.require("buildhub.near/widget/components.Bullet") + const daoId = "build.sputnik-dao.near"; const accountId = context.accountId; @@ -147,12 +149,19 @@ const policy = Near.view(daoId, "get_policy"); if (policy === null) { return ""; } +const alreadyJoinedRolesNames = ["community", "council"]; const deposit = policy.proposal_bond; -const roleId = "community"; + const group = policy.roles - .filter((role) => role.name === roleId) - .map((role) => role.kind.Group); + .filter((role) => alreadyJoinedRolesNames.includes(role.name)) + .map((role) => { + return role.kind.Group; + }); + +const accounts = new Set(group[0].concat(group[1])); + +const isCommunityOrCouncilMember = accounts.has(accountId); const proposalId = Near.view(daoId, "get_last_proposal_id") - 1; @@ -165,8 +174,7 @@ if (proposal === null) { return ""; } -// check if the potential member submitted last proposal -const canJoin = accountId && accountId !== proposal.proposer; +const canJoin = accountId && accountId !== proposal.proposer && !isCommunityOrCouncilMember const groupMembers = group.join(", "); @@ -234,9 +242,9 @@ const CreateSomethingView = (props) => { /> ) : ( <> - + {!validMember ? "Pending..." : "Joined"} - +
View Activity{" "} {children}; -} - -return { ThemeProvider, theme }; \ No newline at end of file +return { theme }; \ No newline at end of file diff --git a/apps/builddao/widget/components/button/join-now.jsx b/apps/builddao/widget/components/buttons/JoinNow.jsx similarity index 78% rename from apps/builddao/widget/components/button/join-now.jsx rename to apps/builddao/widget/components/buttons/JoinNow.jsx index bd702768..93b292a1 100644 --- a/apps/builddao/widget/components/button/join-now.jsx +++ b/apps/builddao/widget/components/buttons/JoinNow.jsx @@ -7,12 +7,19 @@ const policy = Near.view(daoId, "get_policy"); if (policy === null) { return ""; } +const alreadyJoinedRolesNames = ["community", "council"]; const deposit = policy.proposal_bond; -const roleId = "community"; + const group = policy.roles - .filter((role) => role.name === roleId) - .map((role) => role.kind.Group); + .filter((role) => alreadyJoinedRolesNames.includes(role.name)) + .map((role) => { + return role.kind.Group; + }); + +const accounts = new Set(group[0].concat(group[1])); + +const isCommunityOrCouncilMember = accounts.has(accountId); const proposalId = Near.view(daoId, "get_last_proposal_id") - 1; @@ -25,8 +32,7 @@ if (proposal === null) { return ""; } -// check if the potential member submitted last proposal -const canJoin = accountId && accountId !== proposal.proposer; +const canJoin = accountId && accountId !== proposal.proposer && !isCommunityOrCouncilMember const Button = styled.a` width: max-content; diff --git a/src/components/navigation/Navbar.js b/src/components/navigation/Navbar.js index f11f34d2..94465ddf 100644 --- a/src/components/navigation/Navbar.js +++ b/src/components/navigation/Navbar.js @@ -192,28 +192,15 @@ export function Navbar(props) {
- {!props.signedIn && ( - - )} - {props.signedIn && ( -
- , - }} - /> -
- )} + , + }} + />
@@ -271,7 +258,7 @@ export function Navbar(props) { {props.signedIn && (
Date: Thu, 11 Jan 2024 13:02:35 -0300 Subject: [PATCH 09/11] Verifying existent proposals before letting user make a new one --- .../widget/components/buttons/JoinNow.jsx | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/apps/builddao/widget/components/buttons/JoinNow.jsx b/apps/builddao/widget/components/buttons/JoinNow.jsx index b20253f9..cd6d1554 100644 --- a/apps/builddao/widget/components/buttons/JoinNow.jsx +++ b/apps/builddao/widget/components/buttons/JoinNow.jsx @@ -1,13 +1,24 @@ const daoId = "build.sputnik-dao.near"; const accountId = context.accountId; +const alreadyJoinedRolesNames = ["community", "council"]; -// get DAO policy, deposit, and group const policy = Near.view(daoId, "get_policy"); +const lastProposalId = Near.view(daoId, "get_last_proposal_id") - 1; + +const lastProposals = Near.view(daoId, "get_proposals", { + from_index: lastProposalId - 99, + limit: lastProposalId, +}); + +const alreadyMadeAProposal = + lastProposals.filter((proposal) => { + return proposal.proposer === accountId; + }).length > 0; + if (policy === null) { return ""; } -const alreadyJoinedRolesNames = ["community", "council"]; const deposit = policy.proposal_bond; @@ -21,18 +32,8 @@ const accounts = new Set(group[0].concat(group[1])); const isCommunityOrCouncilMember = accounts.has(accountId); -const proposalId = Near.view(daoId, "get_last_proposal_id") - 1; - -// get data from last proposal -const proposal = Near.view(daoId, "get_proposal", { - id: proposalId, -}); - -if (proposal === null) { - return ""; -} - -const canJoin = accountId && accountId !== proposal.proposer && !isCommunityOrCouncilMember +const canJoin = + accountId && !alreadyMadeAProposal && !isCommunityOrCouncilMember; const Button = styled.a` width: max-content; @@ -83,6 +84,8 @@ return ( {canJoin ? ( - ) : Joined} + ) : ( + Joined + )} ); From 7c8bad30448d61534bc3e74128e4b8195c498d0b Mon Sep 17 00:00:00 2001 From: root Date: Thu, 11 Jan 2024 13:21:53 -0300 Subject: [PATCH 10/11] FIX: updating search range --- apps/builddao/widget/components/buttons/JoinNow.jsx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/apps/builddao/widget/components/buttons/JoinNow.jsx b/apps/builddao/widget/components/buttons/JoinNow.jsx index cd6d1554..ecfce40d 100644 --- a/apps/builddao/widget/components/buttons/JoinNow.jsx +++ b/apps/builddao/widget/components/buttons/JoinNow.jsx @@ -1,14 +1,15 @@ const daoId = "build.sputnik-dao.near"; const accountId = context.accountId; const alreadyJoinedRolesNames = ["community", "council"]; +const searchRange = 100; const policy = Near.view(daoId, "get_policy"); const lastProposalId = Near.view(daoId, "get_last_proposal_id") - 1; const lastProposals = Near.view(daoId, "get_proposals", { - from_index: lastProposalId - 99, - limit: lastProposalId, + from_index: lastProposalId - searchRange, + limit: searchRange, }); const alreadyMadeAProposal = @@ -82,10 +83,6 @@ const Container = styled.div` return ( - {canJoin ? ( - - ) : ( - Joined - )} + {canJoin ? : props.children} ); From 402e15411d290771837f77b3fefc620f95ee1bdf Mon Sep 17 00:00:00 2001 From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com> Date: Sat, 13 Jan 2024 15:20:29 -0500 Subject: [PATCH 11/11] null check --- apps/builddao/widget/components/buttons/JoinNow.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/builddao/widget/components/buttons/JoinNow.jsx b/apps/builddao/widget/components/buttons/JoinNow.jsx index ecfce40d..cff7efdb 100644 --- a/apps/builddao/widget/components/buttons/JoinNow.jsx +++ b/apps/builddao/widget/components/buttons/JoinNow.jsx @@ -10,7 +10,7 @@ const lastProposalId = Near.view(daoId, "get_last_proposal_id") - 1; const lastProposals = Near.view(daoId, "get_proposals", { from_index: lastProposalId - searchRange, limit: searchRange, -}); +}) || []; const alreadyMadeAProposal = lastProposals.filter((proposal) => {