From 622a5eff8a158a2d05d24f0d0e3c637279a9693d Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Tue, 13 Feb 2024 16:19:15 +0400 Subject: [PATCH 01/23] change Add to cart in proejct to donate --- apps/potlock/widget/Project/Actions.jsx | 41 ++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/apps/potlock/widget/Project/Actions.jsx b/apps/potlock/widget/Project/Actions.jsx index ab499863..5c24bc8a 100644 --- a/apps/potlock/widget/Project/Actions.jsx +++ b/apps/potlock/widget/Project/Actions.jsx @@ -1,3 +1,6 @@ +const [isModalDonationOpen, setIsModalDonationOpen] = useState(false); +const [isModalDonationSucessOpen, setIsModalDonationSucessOpen] = useState(false); + const { ownerId } = props; const Container = styled.div` display: flex; @@ -43,6 +46,22 @@ const SubRow2 = styled.div` } `; +const DonationButton = styled.button` + padding: 12px 16px; + font-size: 14px; + font-style: normal; + font-weight: 500; + line-height: 20px; + background: #fef6ee; + border-radius: 6px; + border: none; + box-shadow: 0px -2px 0px 0px #464646 inset, 0px 0px 0px 1px #464646; + &:hover { + background: #dd3345; + color: #fff; + } +`; + // const FollowingMobile = styled.div` // display: none; @@ -80,7 +99,27 @@ return ( /> - + { + e.preventDefault(); + setIsModalDonationOpen(true); + }} + > + Donate + + setIsModalDonationOpen(false), + }} + /> + {/* */} ); From 7fff5714e04f35db208f7111a8d9eb63cabe311d Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Wed, 14 Feb 2024 16:56:59 +0400 Subject: [PATCH 02/23] add profile componenets --- apps/potlock/widget/Components/Donors.jsx | 2 +- apps/potlock/widget/Components/DonorsTrx.jsx | 73 ++++--- .../potlock/widget/Components/ProfilePage.jsx | 116 ++++++++++ apps/potlock/widget/Index.jsx | 2 + apps/potlock/widget/Profile/Body.jsx | 205 ++++++++++++++++++ apps/potlock/widget/Profile/FollowButton.jsx | 46 ++++ apps/potlock/widget/Profile/FollowTabs.jsx | 64 ++++++ apps/potlock/widget/Profile/FollowersList.jsx | 39 ++++ apps/potlock/widget/Profile/FollowingList.jsx | 32 +++ apps/potlock/widget/Profile/Preview.jsx | 32 +++ apps/potlock/widget/Project/Actions.jsx | 52 +++-- apps/potlock/widget/Project/Detail.jsx | 15 ++ apps/potlock/widget/Project/FollowStats.jsx | 14 +- apps/potlock/widget/Project/Linktree.jsx | 10 +- 14 files changed, 629 insertions(+), 73 deletions(-) create mode 100644 apps/potlock/widget/Components/ProfilePage.jsx create mode 100644 apps/potlock/widget/Profile/Body.jsx create mode 100644 apps/potlock/widget/Profile/FollowButton.jsx create mode 100644 apps/potlock/widget/Profile/FollowTabs.jsx create mode 100644 apps/potlock/widget/Profile/FollowersList.jsx create mode 100644 apps/potlock/widget/Profile/FollowingList.jsx create mode 100644 apps/potlock/widget/Profile/Preview.jsx diff --git a/apps/potlock/widget/Components/Donors.jsx b/apps/potlock/widget/Components/Donors.jsx index 801cf974..820af95f 100644 --- a/apps/potlock/widget/Components/Donors.jsx +++ b/apps/potlock/widget/Components/Donors.jsx @@ -9,7 +9,7 @@ const [filter, setFilter] = useState(""); const perPage = 30; -const limit = 100; +const limit = 500; const LoadingWrapper = styled.div` font-size: 1.5rem; diff --git a/apps/potlock/widget/Components/DonorsTrx.jsx b/apps/potlock/widget/Components/DonorsTrx.jsx index c49334a9..46d351d2 100644 --- a/apps/potlock/widget/Components/DonorsTrx.jsx +++ b/apps/potlock/widget/Components/DonorsTrx.jsx @@ -1,6 +1,9 @@ const { ownerId, donations } = props; +const showDonor = props.showDonor !== undefined ? props.showDonor : true; +const showProject = props.showProject !== undefined ? props.showProject : true; const [page, setPage] = useState(0); const perPage = 30; // need to be less than 50 +console.log(donations); const nearLogo = "https://ipfs.near.social/ipfs/bafkreib2cfbayerbbnoya6z4qcywnizqrbkzt5lbqe32whm2lubw3sywr4"; @@ -84,9 +87,9 @@ return (
ID
-
Donor ID
+ {showDonor &&
Donor ID
}
Amount
-
Project ID
+ {showProject &&
Project ID
}
Date
{reverseArr(donations) @@ -97,43 +100,45 @@ return ( return (
{id}
- - {_address(donor_id)}{" "} - - ), - }} - /> + {showDonor && ( + + {_address(donor_id)}{" "} + + ), + }} + /> + )}
{calcDonations(donation).toFixed(2)} NEAR
- - {_address(recipient_id)} - - ), - }} - /> + {showProject && ( + + {_address(recipient_id)} + + ), + }} + /> + )}
{getTimePassed(donated_at_ms)} ago
); diff --git a/apps/potlock/widget/Components/ProfilePage.jsx b/apps/potlock/widget/Components/ProfilePage.jsx new file mode 100644 index 00000000..15f7a32b --- /dev/null +++ b/apps/potlock/widget/Components/ProfilePage.jsx @@ -0,0 +1,116 @@ +const accountId = props.accountId ?? context.accountId; + +const { ownerId } = props; + +if (!accountId) { + return "No account ID"; +} + +const profile = props.profile ?? Social.getr(`${accountId}/profile`); + +const fast = !props.profile; + +if (profile === null) { + return "Loading"; +} + +const Wrapper = styled.div` + display: flex; + flex-direction: column; + --primary-color: #dd3345; +`; + +const Container = styled.div` + padding: 252px 68px 68px; + display: flex; + flex-direction: row; + align-items: flex-start; + justify-content: flex-start; + + @media screen and (max-width: 768px) { + flex-direction: column; + padding: 280px 16px 32px 16px; + } +`; + +const SidebarContainer = styled.div` + width: 25%; + display: flex; + flex-direction: column; + @media screen and (max-width: 768px) { + display: none; + } +`; + +const profileLink = `/${ownerId}/widget/Index?tab=profile&accountId=${accountId}`; + +props.navOptions = [ + { + label: "Social Feed", + id: "feed", + disabled: false, + source: "mob.near/widget/MainPage.N.Feed", + href: props.hrefWithEnv(`${profileLink}&nav=feed`), + }, + { + label: "Donations", + id: "donations", + disabled: false, + source: `${ownerId}/widget/Pots.Donations`, + href: props.hrefWithEnv(`${profileLink}&nav=donations`), + }, + { + label: "Widgets", + id: "widgets", + disabled: false, + source: `mob.near/widget/LastWidgets"`, + href: props.hrefWithEnv(`${profileLink}&nav=widgets`), + }, +]; + +return ( + + + + + + {profile.linktree && ( + + )} + + + + +); diff --git a/apps/potlock/widget/Index.jsx b/apps/potlock/widget/Index.jsx index 8eea707e..8d1ed06d 100644 --- a/apps/potlock/widget/Index.jsx +++ b/apps/potlock/widget/Index.jsx @@ -13,6 +13,7 @@ const POTS_TAB = "pots"; const DEPLOY_POT_TAB = "deploypot"; const POT_DETAIL_TAB = "pot"; const DONORS_TAB = "donors"; +const PROFILE_TAB = "profile"; const Theme = styled.div` position: relative; @@ -171,6 +172,7 @@ const tabContentWidget = { [DEPLOY_POT_TAB]: "Pots.Deploy", [POT_DETAIL_TAB]: "Pots.Detail", [DONORS_TAB]: "Components.Donors", + [PROFILE_TAB]: "Components.ProfilePage", }; const getTabWidget = (tab) => { diff --git a/apps/potlock/widget/Profile/Body.jsx b/apps/potlock/widget/Profile/Body.jsx new file mode 100644 index 00000000..0ac19aac --- /dev/null +++ b/apps/potlock/widget/Profile/Body.jsx @@ -0,0 +1,205 @@ +const { profile, accountId, ownerId, profileLink } = props; +const nav = props.nav ?? "feed"; + +const tags = Object.keys(profile.tags ?? {}); + +const donations = Near.view("donate.potlock.near", "get_donations_for_donor", { + donor_id: accountId, +}); + +const Body = styled.div` + display: flex; + flex-direction: column; + gap: 2rem; + flex: 1 1 0%; +`; +const Header = styled.div` + display: flex; + flex-direction: column; + // gap: 16px; + width: 100%; +`; + +const NameContainer = styled.div` + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-between; + width: 100%; +`; + +const Name = styled.div` + font-size: 48px; + font-weight: 500; + color: #2e2e2e; + line-height: 56px; + font-family: "Lora"; + ${loraCss} + + @media screen and (max-width: 768px) { + font-size: 32px; + line-height: 40px; + } +`; + +const AccountInfoContainer = styled.div` + display: flex; + flex-direction: row; + align-items: center; + justify-content: flex-start; + margin-bottom: 16px; +`; + +const AccountId = styled.div` + color: #7b7b7b; + font-size: 16px; + font-weight: 400; + + @media screen and (max-width: 768px) { + font-size: 14px; + line-height: 24px; + } +`; + +const TagsContainer = styled.div` + display: flex; + flex-direction: row; + align-items: center; + justify-content: flex-start; + gap: 12px; +`; + +const ShareIconContainer = styled.svg` + width: 24px; + height: 24px; + + @media screen and (max-width: 768px) { + width: 16px; + height: 16px; + } +`; +const ShareIcon = ( + + + + + + +); + +return ( + +
+ + {profile.name} + {canEdit && ( + + )} + + + @{accountId} + + + {tags.length > 0 && ( +
+ +
+ )} +
+ +
+
+ +
+ +
+ {nav === "feed" && ( +
+
+ {profile.description && ( + + )} + +
+
+ )} + {nav === "widgets" && } + {nav === "donations" && ( + + )} + {(nav === "followers" || nav === "following") && ( + + )} + +); diff --git a/apps/potlock/widget/Profile/FollowButton.jsx b/apps/potlock/widget/Profile/FollowButton.jsx new file mode 100644 index 00000000..a0062465 --- /dev/null +++ b/apps/potlock/widget/Profile/FollowButton.jsx @@ -0,0 +1,46 @@ +if (!props.accountId || !context.accountId || context.accountId === props.accountId) { + return ""; +} + +const followEdge = Social.keys(`${context.accountId}/graph/follow/${props.accountId}`, undefined, { + values_only: true, +}); + +const inverseEdge = Social.keys(`${props.accountId}/graph/follow/${context.accountId}`, undefined, { + values_only: true, +}); + +const loading = followEdge === null || inverseEdge === null; +const follow = followEdge && Object.keys(followEdge).length; +const inverse = inverseEdge && Object.keys(inverseEdge).length; + +const type = follow ? "unfollow" : "follow"; + +const data = { + graph: { follow: { [props.accountId]: follow ? null : "" } }, + index: { + graph: JSON.stringify({ + key: "follow", + value: { + type, + accountId: props.accountId, + }, + }), + notify: JSON.stringify({ + key: props.accountId, + value: { + type, + }, + }), + }, +}; + +return ( + + {loading ? "Loading" : follow ? "Following" : inverse ? "Follow back" : "Follow"} + +); diff --git a/apps/potlock/widget/Profile/FollowTabs.jsx b/apps/potlock/widget/Profile/FollowTabs.jsx new file mode 100644 index 00000000..ce174a87 --- /dev/null +++ b/apps/potlock/widget/Profile/FollowTabs.jsx @@ -0,0 +1,64 @@ +const { ownerId, tab, accountId } = props; +console.log("tab", tab); +const Nav = styled.div` + .nav-pills { + background: #fbfbfb; + font-weight: 500; + --bs-nav-pills-border-radius: 0; + --bs-nav-link-color: #000; + --bs-nav-pills-link-active-color: #000; + --bs-nav-pills-link-active-bg: #fbfbfb; + --bs-nav-link-padding-y: 0.75rem; + border-bottom: 1px solid #eee; + padding-top: 3px; + } + .nav-link.active { + border-bottom: 3px solid #dd3345; + } + + .nav-item:not(:has(> .disabled)):hover { + background: #dd334456; + .nav-link { + color: #dd3345; + } + } + + margin: 0 -12px; +`; + +const profileLink = `/${ownerId}/widget/Index?tab=profile&accountId=${accountId}`; + +return ( + <> + +
+
+ +
+
+ +); diff --git a/apps/potlock/widget/Profile/FollowersList.jsx b/apps/potlock/widget/Profile/FollowersList.jsx new file mode 100644 index 00000000..533d6541 --- /dev/null +++ b/apps/potlock/widget/Profile/FollowersList.jsx @@ -0,0 +1,39 @@ +const { accountId, tab, ownerId } = props; +if (!accountId) { + return ""; +} + +const url = tab === "followers" ? `*/graph/follow/${accountId}` : `${accountId}/graph/follow/*`; + +console.log(tab); + +let followers = Social.keys(url, "final", { + return_type: "BlockHeight", + values_only: true, +}); + +if (followers === null) { + return "Loading"; +} +if (tab === "followers") { + followers = Object.entries(followers || {}); + followers.sort((a, b) => b.graph.follow[accountId][1] - a.graph.follow[accountId][1]); +} else { + followers = Object.entries(followers[accountId].graph.follow || {}); + followers.sort((a, b) => b[1] - a[1]); +} + +return ( + <> + {followers.map(([accountId], i) => ( +
+
+ +
+
+ +
+
+ ))} + +); diff --git a/apps/potlock/widget/Profile/FollowingList.jsx b/apps/potlock/widget/Profile/FollowingList.jsx new file mode 100644 index 00000000..e02658b3 --- /dev/null +++ b/apps/potlock/widget/Profile/FollowingList.jsx @@ -0,0 +1,32 @@ +const accountId = props.accountId; + +if (!accountId) { + return ""; +} + +let following = Social.keys(`${accountId}/graph/follow/*`, "final", { + return_type: "BlockHeight", + values_only: true, +}); + +if (following === null) { + return "Loading"; +} + +following = Object.entries(following[accountId].graph.follow || {}); +following.sort((a, b) => b[1] - a[1]); + +return ( + <> + {following.map(([accountId], i) => ( +
+
+ +
+
+ +
+
+ ))} + +); diff --git a/apps/potlock/widget/Profile/Preview.jsx b/apps/potlock/widget/Profile/Preview.jsx new file mode 100644 index 00000000..3298ce6e --- /dev/null +++ b/apps/potlock/widget/Profile/Preview.jsx @@ -0,0 +1,32 @@ +const accountId = props.accountId ?? context.accountId; +const ownerId = props.ownerId; +const profile = Social.getr(`${accountId}/profile`); + +const name = profile.name; +const image = profile.image; + +return ( + +); diff --git a/apps/potlock/widget/Project/Actions.jsx b/apps/potlock/widget/Project/Actions.jsx index 5c24bc8a..e47bf127 100644 --- a/apps/potlock/widget/Project/Actions.jsx +++ b/apps/potlock/widget/Project/Actions.jsx @@ -1,3 +1,5 @@ +const showDonate = props.showDonate !== undefined ? props.showDonate : true; + const [isModalDonationOpen, setIsModalDonationOpen] = useState(false); const [isModalDonationSucessOpen, setIsModalDonationSucessOpen] = useState(false); @@ -91,35 +93,37 @@ return ( - - { - e.preventDefault(); - setIsModalDonationOpen(true); - }} - > - Donate - - setIsModalDonationOpen(false), - }} - /> - {/* */} - + {showDonate && ( + + { + e.preventDefault(); + setIsModalDonationOpen(true); + }} + > + Donate + + setIsModalDonationOpen(false), + }} + /> + {/* */} + + )} ); diff --git a/apps/potlock/widget/Project/Detail.jsx b/apps/potlock/widget/Project/Detail.jsx index 288a0c36..852e9f8e 100644 --- a/apps/potlock/widget/Project/Detail.jsx +++ b/apps/potlock/widget/Project/Detail.jsx @@ -11,6 +11,13 @@ if (!profile || project == null) { if (project == undefined) { return "Project not found"; } +const donations = Near.view("donate.potlock.near", "get_donations_for_recipient", { + recipient_id: projectId, +}); +console.log("donations", donations); + +props.donations = donations; +props.showProject = false; const name = profile.name || "No-name profile"; const image = profile.image; @@ -51,6 +58,7 @@ const Container = styled.div` const BodyContainer = styled.div` flex: 1; + --primary-color: #dd3345; `; const Banner = styled.div` @@ -113,6 +121,13 @@ props.navOptions = [ source: `${ownerId}/widget/Project.Feed`, href: props.hrefWithEnv(`?tab=project&projectId=${projectId}&nav=feed`), }, + { + label: "Donations", + id: "donations", + disabled: false, + source: `${ownerId}/widget/Components.DonorsTrx`, + href: props.hrefWithEnv(`?tab=project&projectId=${projectId}&nav=donations`), + }, { label: "Pots", id: "pots", diff --git a/apps/potlock/widget/Project/FollowStats.jsx b/apps/potlock/widget/Project/FollowStats.jsx index dc66bc9a..6d39c1be 100644 --- a/apps/potlock/widget/Project/FollowStats.jsx +++ b/apps/potlock/widget/Project/FollowStats.jsx @@ -1,5 +1,5 @@ const accountId = props.accountId; - +const ownerId = props.ownerId; if (!accountId) { return ""; } @@ -17,14 +17,13 @@ const followers = Social.keys(`*/graph/follow/${accountId}`, "final", { const numFollowing = following ? Object.keys(following[accountId].graph.follow || {}).length : null; const numFollowers = followers ? Object.keys(followers || {}).length : null; +const profileLink = `/${ownerId}/widget/Index?tab=profile&accountId=${accountId}`; + return (
- + Follower{numFollowers !== 1 && "s"} diff --git a/apps/potlock/widget/Project/Linktree.jsx b/apps/potlock/widget/Project/Linktree.jsx index ac674cdb..0e6d828b 100644 --- a/apps/potlock/widget/Project/Linktree.jsx +++ b/apps/potlock/widget/Project/Linktree.jsx @@ -1,4 +1,4 @@ -const IPFS_BASE_URL = "https://nftstorage.link/ipfs/"; +const IPFS_BASE_URL = "https://ipfs.near.social/ipfs/"; const linktree = props.linktree; @@ -40,11 +40,11 @@ const LinkText = styled.a` `; const itemIconUrls = { - github: IPFS_BASE_URL + "bafkreiankcn5awmw3b5ghhhebrmxahf2bdvrsd4i74rw7s4x4ye5djpyxu", + github: IPFS_BASE_URL + "bafkreidyvuxajjhzfoqfl6jiyh43fusddutno5pntutugahfoimeqthy34", // "telegram": IPFS_BASE_URL + - twitter: IPFS_BASE_URL + "bafkreiabmokq5rsnb2nehzdktmiw57esvwz7i4baggpxyg2kg3x5quachu", - website: IPFS_BASE_URL + "bafkreibr5xstjlyyjicgz3epxv5soa7fzhu72qvukp7dpld75uwnvtbveq", - NEAR: IPFS_BASE_URL + "bafkreigogi7iyonbdjsxi3n6seplll7at6e4jsrxwpgke5b5uk5obxkdpe", + twitter: IPFS_BASE_URL + "bafkreiav6yefs6rk55hionalntoi6dea7dhser7qclwk7ld3ionh4hlecq", + website: IPFS_BASE_URL + "bafkreihhrc7sylatspibzueuuxkooamw7zg4fhdpsubwokj63dwn2m46ba", + NEAR: IPFS_BASE_URL + "bafkreigwnndzmhu3svhacqk3mvnqn7krghrix5wobbwzng5qdw5csy47bq", }; const fullUrls = { From a005dee6dc2ccea6b808ee4e1bda73db023f387e Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Wed, 14 Feb 2024 20:03:40 +0400 Subject: [PATCH 03/23] donots page --- apps/potlock/widget/Project/Detail.jsx | 191 ++++-------------- apps/potlock/widget/Project/Options.jsx | 67 ++++++ apps/potlock/widget/Project/ProjectBanner.jsx | 51 +++++ 3 files changed, 153 insertions(+), 156 deletions(-) create mode 100644 apps/potlock/widget/Project/Options.jsx create mode 100644 apps/potlock/widget/Project/ProjectBanner.jsx diff --git a/apps/potlock/widget/Project/Detail.jsx b/apps/potlock/widget/Project/Detail.jsx index 852e9f8e..10be8fc0 100644 --- a/apps/potlock/widget/Project/Detail.jsx +++ b/apps/potlock/widget/Project/Detail.jsx @@ -1,24 +1,37 @@ -const { ownerId, projectId, userIsRegistryAdmin, REGISTRY_CONTRACT_ID } = props; +const { ownerId, id, userIsRegistryAdmin, REGISTRY_CONTRACT_ID, tab } = props; -const profile = props.profile ?? Social.getr(`${projectId}/profile`); +const projectId = id; +props.projectId = projectId; +const accountId = props.id ?? context.accountId; +props.accountId = accountId; -const project = Near.view(REGISTRY_CONTRACT_ID, "get_project_by_id", { project_id: projectId }); +const { ProjectOptions, ProfileOptions } = VM.require(`${ownerId}/widget/Project.Options`); -if (!profile || project == null) { - return "Loading"; -} +let project, donations; +if (tab === "project") { + project = Near.view(REGISTRY_CONTRACT_ID, "get_project_by_id", { project_id: projectId }); + if (!profile || project == null) { + return "Loading"; + } -if (project == undefined) { - return "Project not found"; + if (project == undefined) { + return "Project not found"; + } + // Fetch Project Donations + donations = Near.view("donate.potlock.near", "get_donations_for_recipient", { + recipient_id: projectId, + }); + props.donations = donations; + props.showProject = false; // hide recepientId row + + if (!props.nav) props.nav = "home"; // default to home tab } -const donations = Near.view("donate.potlock.near", "get_donations_for_recipient", { - recipient_id: projectId, -}); -console.log("donations", donations); - -props.donations = donations; -props.showProject = false; +const profile = Social.getr(`${id}/profile`); +if (profile === null) { + return "Loading"; +} +console.log("profile", profile); const name = profile.name || "No-name profile"; const image = profile.image; const backgroundImage = profile.backgroundImage; @@ -26,23 +39,13 @@ const tags = Object.keys(profile.tags ?? {}); const Wrapper = styled.div` margin-top: calc(-1 * var(--body-top-padding, 0)); - - // @media screen and (max-width: 768px) { - // .mb-2 { - // width: 64px; - // height: 64px; - // } - // } `; - const SidebarContainer = styled.div` width: 25%; - // width: 500px; @media screen and (max-width: 768px) { display: none; } `; - const Container = styled.div` padding: 252px 68px 68px 68px; display: flex; @@ -55,27 +58,11 @@ const Container = styled.div` padding: 240px 16px 32px 16px; } `; - const BodyContainer = styled.div` flex: 1; --primary-color: #dd3345; `; -const Banner = styled.div` - width: 100%; - // max-height: 50px; - background: ${project.status === "Pending" ? "#E6B800" : "#dd3345"}; - // background: rgb(6 10 15); - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - padding: 8px 0; - margin-bottom: 8px; - border-radius: 4px; - // border-bottom: 2px rgb(96, 100, 102) solid; -`; - const BannerText = styled.div` text-align: center; color: white; @@ -83,131 +70,37 @@ const BannerText = styled.div` font-weight: 600; margin: 0 8px; word-break: break-all; - @media screen and (max-width: 768px) { font-size: 12px; margin-left: 4px; } `; -const BannerAlertSvg = styled.svg` - width: 18px; - - @media screen and (max-width: 768px) { - width: 14px; - } -`; - -const Row = styled.div` - display: flex; - flex-direction: row; - align-items: center; - justify-content: center; -`; - -// these will be passed down to child components -props.navOptions = [ - { - label: "Home", - id: "home", - disabled: false, - source: `${ownerId}/widget/Project.About`, - href: props.hrefWithEnv(`?tab=project&projectId=${projectId}&nav=home`), - }, - { - label: "Social Feed", - id: "feed", - disabled: false, - source: `${ownerId}/widget/Project.Feed`, - href: props.hrefWithEnv(`?tab=project&projectId=${projectId}&nav=feed`), - }, - { - label: "Donations", - id: "donations", - disabled: false, - source: `${ownerId}/widget/Components.DonorsTrx`, - href: props.hrefWithEnv(`?tab=project&projectId=${projectId}&nav=donations`), - }, - { - label: "Pots", - id: "pots", - disabled: true, - }, - { - label: "Attestations", - id: "attestations", - disabled: true, - }, - { - label: "Funding Raised", - id: "funding", - disabled: true, - }, -]; - -if (!props.nav) props.nav = "home"; // default to home tab - +props.navOptions = tab === "project" ? ProjectOptions(props) : ProfileOptions(props); const imageHeightPx = 120; const profileImageTranslateYPx = 220; return ( - {project.status !== "Approved" && ( - - - - - This project status is {project.status} and has not been approved. - - - {project.review_notes && ( - - Admin review notes: {project.review_notes} - - )} - - )} + {/* {project.status !== "Approved" && ( + + )} */} - {/*
*/} - + - + - {/*
*/}
- {/* -
- -
-
*/}
); diff --git a/apps/potlock/widget/Project/Options.jsx b/apps/potlock/widget/Project/Options.jsx new file mode 100644 index 00000000..2247d7cc --- /dev/null +++ b/apps/potlock/widget/Project/Options.jsx @@ -0,0 +1,67 @@ +const ProjectOptions = (props) => [ + { + label: "Home", + id: "home", + disabled: false, + source: `${props.ownerId}/widget/Project.About`, + href: props.hrefWithEnv(`?tab=project&id=${props.projectId}&nav=home`), + }, + { + label: "Social Feed", + id: "feed", + disabled: false, + source: `${props.ownerId}/widget/Project.Feed`, + href: props.hrefWithEnv(`?tab=project&id=${props.projectId}&nav=feed`), + }, + { + label: "Donations", + id: "donations", + disabled: false, + source: `${props.ownerId}/widget/Components.DonorsTrx`, + href: props.hrefWithEnv(`?tab=project&id=${props.projectId}&nav=donations`), + }, + { + label: "Pots", + id: "pots", + disabled: true, + }, + { + label: "Attestations", + id: "attestations", + disabled: true, + }, + { + label: "Funding Raised", + id: "funding", + disabled: true, + }, +]; + +const ProfileOptions = (props) => [ + { + label: "Social Feed", + id: "feed", + disabled: false, + source: `${props.ownerId}/widget/Project.Feed`, + href: props.hrefWithEnv(`?tab=profile&id=${props.accountId}&nav=feed`), + }, + { + label: "Donations", + id: "donations", + disabled: false, + source: `${props.ownerId}/widget/Components.DonorsTrx`, + href: props.hrefWithEnv(`?tab=profile&id=${props.accountId}&nav=donations`), + }, + { + label: "Widgets", + id: "widgets", + disabled: false, + source: "mob.near/widget/LastWidgets", + href: props.hrefWithEnv(`?tab=profile&id=${props.accountId}&nav=widgets`), + }, +]; + +return { + ProjectOptions, + ProfileOptions, +}; diff --git a/apps/potlock/widget/Project/ProjectBanner.jsx b/apps/potlock/widget/Project/ProjectBanner.jsx new file mode 100644 index 00000000..cb7187b4 --- /dev/null +++ b/apps/potlock/widget/Project/ProjectBanner.jsx @@ -0,0 +1,51 @@ +const Banner = styled.div` + width: 100%; + background: ${project.status === "Pending" ? "#E6B800" : "#dd3345"}; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + padding: 8px 0; + margin-bottom: 8px; + border-radius: 4px; +`; +const Row = styled.div` + display: flex; + flex-direction: row; + align-items: center; + justify-content: center; +`; + +const BannerAlertSvg = styled.svg` + width: 18px; + @media screen and (max-width: 768px) { + width: 14px; + } +`; +return ( + + + + This project status is {project.status} and has not been approved. + + {project.review_notes && ( + + Admin review notes: {project.review_notes} + + )} + +); From c167b63ef90f2aba5cea6486c37d7cc3f6ca26ba Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Sun, 18 Feb 2024 18:37:17 +0400 Subject: [PATCH 04/23] finish donations table & combine project and profile page --- apps/potlock/widget/Components/NavOptions.jsx | 2 + apps/potlock/widget/Index.jsx | 2 +- apps/potlock/widget/Profile/Body.jsx | 262 ++++++--------- apps/potlock/widget/Profile/Details.jsx | 92 ++++++ apps/potlock/widget/Profile/FollowTabs.jsx | 10 +- apps/potlock/widget/Profile/FollowersList.jsx | 8 +- .../ProfilePage.jsx => Profile/Index.jsx} | 54 +--- .../widget/{Project => Profile}/Tags.jsx | 0 apps/potlock/widget/Project/Actions.jsx | 16 +- apps/potlock/widget/Project/Body.jsx | 301 ------------------ apps/potlock/widget/Project/BodyHeader.jsx | 135 ++++++++ apps/potlock/widget/Project/Detail.jsx | 196 ++++++------ apps/potlock/widget/Project/Donations.jsx | 272 ++++++++++++++++ apps/potlock/widget/Project/Linktree.jsx | 51 ++- apps/potlock/widget/Project/Options.jsx | 29 +- .../widget/Project/SidebarContainer.jsx | 26 ++ apps/potlock/widget/Project/Team.jsx | 4 +- 17 files changed, 777 insertions(+), 683 deletions(-) create mode 100644 apps/potlock/widget/Profile/Details.jsx rename apps/potlock/widget/{Components/ProfilePage.jsx => Profile/Index.jsx} (55%) rename apps/potlock/widget/{Project => Profile}/Tags.jsx (100%) delete mode 100644 apps/potlock/widget/Project/Body.jsx create mode 100644 apps/potlock/widget/Project/BodyHeader.jsx create mode 100644 apps/potlock/widget/Project/Donations.jsx create mode 100644 apps/potlock/widget/Project/SidebarContainer.jsx diff --git a/apps/potlock/widget/Components/NavOptions.jsx b/apps/potlock/widget/Components/NavOptions.jsx index 62848647..5c257649 100644 --- a/apps/potlock/widget/Components/NavOptions.jsx +++ b/apps/potlock/widget/Components/NavOptions.jsx @@ -41,6 +41,8 @@ return ( {option.label} + ) : !option.label ? ( + "" ) : ( {selected && ( diff --git a/apps/potlock/widget/Index.jsx b/apps/potlock/widget/Index.jsx index 764c4598..d28a6d52 100644 --- a/apps/potlock/widget/Index.jsx +++ b/apps/potlock/widget/Index.jsx @@ -189,7 +189,7 @@ const tabContentWidget = { [DEPLOY_POT_TAB]: "Pots.Deploy", [POT_DETAIL_TAB]: "Pots.Detail", [DONORS_TAB]: "Components.Donors", - [PROFILE_TAB]: "Components.ProfilePage", + [PROFILE_TAB]: "Profile.Index", }; const getTabWidget = (tab) => { diff --git a/apps/potlock/widget/Profile/Body.jsx b/apps/potlock/widget/Profile/Body.jsx index 0ac19aac..ff4b351a 100644 --- a/apps/potlock/widget/Profile/Body.jsx +++ b/apps/potlock/widget/Profile/Body.jsx @@ -1,205 +1,127 @@ -const { profile, accountId, ownerId, profileLink } = props; -const nav = props.nav ?? "feed"; +const { + ownerId, + projectId, + REGISTRY_CONTRACT_ID, + userIsRegistryAdmin, + SUPPORTED_FTS: { NEAR }, + getTagsFromSocialProfileData, +} = props; -const tags = Object.keys(profile.tags ?? {}); +const accountId = props.accountId ?? context.accountId; -const donations = Near.view("donate.potlock.near", "get_donations_for_donor", { - donor_id: accountId, -}); - -const Body = styled.div` +const Wrapper = styled.div` display: flex; flex-direction: column; - gap: 2rem; - flex: 1 1 0%; -`; -const Header = styled.div` - display: flex; - flex-direction: column; - // gap: 16px; - width: 100%; -`; - -const NameContainer = styled.div` - display: flex; - flex-direction: row; - align-items: center; - justify-content: space-between; - width: 100%; -`; - -const Name = styled.div` - font-size: 48px; - font-weight: 500; - color: #2e2e2e; - line-height: 56px; - font-family: "Lora"; - ${loraCss} - - @media screen and (max-width: 768px) { - font-size: 32px; - line-height: 40px; - } `; -const AccountInfoContainer = styled.div` +const Container = styled.div` + padding-top: 252px; display: flex; flex-direction: row; - align-items: center; + align-items: flex-start; justify-content: flex-start; - margin-bottom: 16px; -`; - -const AccountId = styled.div` - color: #7b7b7b; - font-size: 16px; - font-weight: 400; @media screen and (max-width: 768px) { - font-size: 14px; - line-height: 24px; + flex-direction: column; + padding-top: 240px; } `; -const TagsContainer = styled.div` +const Details = styled.div` display: flex; - flex-direction: row; - align-items: center; - justify-content: flex-start; - gap: 12px; + flex-direction: column; + gap: 2rem; + flex: 1 1 0%; + .nav-view { + width: 100%; + padding: 24px 50px; + background: #f6f5f3; + } `; -const ShareIconContainer = styled.svg` - width: 24px; - height: 24px; - +const SidebarContainer = styled.div` + width: 15%; + padding-left: 1rem; @media screen and (max-width: 768px) { - width: 16px; - height: 16px; + display: none; } `; -const ShareIcon = ( - - - - - - -); return ( - -
- - {profile.name} - {canEdit && ( - - )} - - - @{accountId} + + + {/* Side Nav */} + + - - {tags.length > 0 && ( -
- -
- )} -
- -
-
- -
+ + -
- {nav === "feed" && ( -
-
- {profile.description && ( - - )} + {/* Body */} +
+ + {userIsRegistryAdmin && projectId && ( + ({ + value: status, + text: status, + })), + value: { text: props.project.status, value: props.project.status }, + onChange: (status) => { + if (status.value != project.status) { + setStatusReview({ ...statusReview, newStatus: status.value, modalOpen: true }); + } + }, + containerStyles: { + padding: "16px 24px", + }, + }} + /> + )} +
option.id == props.nav).source} + props={{ + ...props, + }} />
-
- )} - {nav === "widgets" && } - {nav === "donations" && ( - - )} - {(nav === "followers" || nav === "following") && ( - - )} - + + + ); diff --git a/apps/potlock/widget/Profile/Details.jsx b/apps/potlock/widget/Profile/Details.jsx new file mode 100644 index 00000000..34877085 --- /dev/null +++ b/apps/potlock/widget/Profile/Details.jsx @@ -0,0 +1,92 @@ +const { + profile, + accountId, + ownerId, + profileLink, + getTagsFromSocialProfileData, + POT_FACTORY_CONTRACT_ID, + SUPPORTED_FTS: { NEAR }, +} = props; + +const [directDonations, setDirectDonation] = useState([]); +const [sponsorship, setSponsorship] = useState([]); +const [potDonations, setPotDonations] = useState([]); + +if (!props.nav) props.nav = "feed"; + +const tags = getTagsFromSocialProfileData(profile); + +const getPotConfig = (potId) => Near.asyncView(potId, "get_config", {}); + +const getSponsorships = (potId, potDetail) => { + Near.asyncView(potId, "get_matching_pool_donations", {}).then((donations) => { + donations = donations.filter((donations) => donations.donor_id === accountId); + const updatedDonations = (donations = donations.map((donation) => ({ + ...donation, + base_currency: potDetail.base_currency, + pot_name: potDetail.pot_name, + pot_id: potId, + }))); + setSponsorship(updatedDonations); + }); +}; + +// Get Sponsorships +if (!directDonations.length) { + Near.asyncView("donate.potlock.near", "get_donations_for_donor", { + donor_id: accountId, + }).then((donations) => setDirectDonation(donations)); +} +// Get Direct Donations +if (!sponsorship.length) { + Near.asyncView(POT_FACTORY_CONTRACT_ID, "get_pots", {}).then((pots) => { + pots.forEach((pot) => { + getPotConfig(pot.id).then((potDetail) => { + getSponsorships(pot.id, potDetail); + }); + }); + }); +} + +// Get Total Donations +const [allDonations] = useMemo(() => { + const donations = [...sponsorship, ...directDonations]; + donations.sort((a, b) => b.donated_at - a.donated_at); + return [donations]; +}, [directDonations, sponsorship]); + +props.donations = allDonations; + +const Body = styled.div` + display: flex; + flex-direction: column; + gap: 2rem; + flex: 1 1 0%; + .nav-view { + width: 100%; + padding: 24px 50px; + background: #f6f5f3; + } +`; + +return ( + + + {/* body */} +
+ option.id == props.nav).source} + props={{ + ...props, + }} + /> +
+ +); diff --git a/apps/potlock/widget/Profile/FollowTabs.jsx b/apps/potlock/widget/Profile/FollowTabs.jsx index ce174a87..49c62236 100644 --- a/apps/potlock/widget/Profile/FollowTabs.jsx +++ b/apps/potlock/widget/Profile/FollowTabs.jsx @@ -1,5 +1,5 @@ -const { ownerId, tab, accountId } = props; -console.log("tab", tab); +const { ownerId, accountId, projectId, nav } = props; + const Nav = styled.div` .nav-pills { background: #fbfbfb; @@ -35,7 +35,7 @@ return (
  • Followers @@ -44,7 +44,7 @@ return (
  • Following @@ -56,7 +56,7 @@ return (
  • diff --git a/apps/potlock/widget/Profile/FollowersList.jsx b/apps/potlock/widget/Profile/FollowersList.jsx index 533d6541..011f81b0 100644 --- a/apps/potlock/widget/Profile/FollowersList.jsx +++ b/apps/potlock/widget/Profile/FollowersList.jsx @@ -1,11 +1,9 @@ -const { accountId, tab, ownerId } = props; +const { accountId, nav, ownerId } = props; if (!accountId) { return ""; } -const url = tab === "followers" ? `*/graph/follow/${accountId}` : `${accountId}/graph/follow/*`; - -console.log(tab); +const url = nav === "followers" ? `*/graph/follow/${accountId}` : `${accountId}/graph/follow/*`; let followers = Social.keys(url, "final", { return_type: "BlockHeight", @@ -15,7 +13,7 @@ let followers = Social.keys(url, "final", { if (followers === null) { return "Loading"; } -if (tab === "followers") { +if (nav === "followers") { followers = Object.entries(followers || {}); followers.sort((a, b) => b.graph.follow[accountId][1] - a.graph.follow[accountId][1]); } else { diff --git a/apps/potlock/widget/Components/ProfilePage.jsx b/apps/potlock/widget/Profile/Index.jsx similarity index 55% rename from apps/potlock/widget/Components/ProfilePage.jsx rename to apps/potlock/widget/Profile/Index.jsx index 15f7a32b..8f938655 100644 --- a/apps/potlock/widget/Components/ProfilePage.jsx +++ b/apps/potlock/widget/Profile/Index.jsx @@ -1,6 +1,7 @@ +const { ownerId } = props; const accountId = props.accountId ?? context.accountId; -const { ownerId } = props; +const { ProfileOptions } = VM.require(`${ownerId}/widget/Project.Options`); if (!accountId) { return "No account ID"; @@ -21,7 +22,7 @@ const Wrapper = styled.div` `; const Container = styled.div` - padding: 252px 68px 68px; + padding-top: 252px; display: flex; flex-direction: row; align-items: flex-start; @@ -29,7 +30,7 @@ const Container = styled.div` @media screen and (max-width: 768px) { flex-direction: column; - padding: 280px 16px 32px 16px; + padding-top: 240px; } `; @@ -44,29 +45,7 @@ const SidebarContainer = styled.div` const profileLink = `/${ownerId}/widget/Index?tab=profile&accountId=${accountId}`; -props.navOptions = [ - { - label: "Social Feed", - id: "feed", - disabled: false, - source: "mob.near/widget/MainPage.N.Feed", - href: props.hrefWithEnv(`${profileLink}&nav=feed`), - }, - { - label: "Donations", - id: "donations", - disabled: false, - source: `${ownerId}/widget/Pots.Donations`, - href: props.hrefWithEnv(`${profileLink}&nav=donations`), - }, - { - label: "Widgets", - id: "widgets", - disabled: false, - source: `mob.near/widget/LastWidgets"`, - href: props.hrefWithEnv(`${profileLink}&nav=widgets`), - }, -]; +props.navOptions = ProfileOptions(props); return ( @@ -85,25 +64,12 @@ return ( }} /> - - - {profile.linktree && ( - - )} - + {/* @@ -93,14 +87,11 @@ return ( - + - {showDonate && ( + {props.tab === "project" && ( { @@ -122,7 +113,6 @@ return ( onClose: () => setIsModalDonationOpen(false), }} /> - {/* */} )} diff --git a/apps/potlock/widget/Project/Body.jsx b/apps/potlock/widget/Project/Body.jsx deleted file mode 100644 index 486effa1..00000000 --- a/apps/potlock/widget/Project/Body.jsx +++ /dev/null @@ -1,301 +0,0 @@ -const { - ownerId, - REGISTRY_CONTRACT_ID, - userIsRegistryAdmin, - SUPPORTED_FTS: { NEAR }, - getTagsFromSocialProfileData, -} = props; - -const IPFS_BASE_URL = "https://nftstorage.link/ipfs/"; - -const profile = props.profile; - -if (!profile) return "Loading..."; - -const loraCss = fetch("https://fonts.cdnfonts.com/css/lora").body; - -const tags = getTagsFromSocialProfileData(profile); - -const BodyContainer = styled.div` - display: flex; - flex-direction: column; - align-items: flex-start; - justify-content: flex-start; - gap: 16px; - - @media screen and (max-width: 768px) { - max-width: 90vw; - } -`; - -const NameContainer = styled.div` - display: flex; - flex-direction: row; - align-items: center; - justify-content: space-between; - width: 100%; -`; - -const Name = styled.div` - font-size: 48px; - font-weight: 500; - color: #2e2e2e; - line-height: 56px; - font-family: "Lora"; - ${loraCss} - - @media screen and (max-width: 768px) { - font-size: 32px; - line-height: 40px; - } -`; - -const AccountInfoContainer = styled.div` - display: flex; - flex-direction: row; - align-items: center; - justify-content: flex-start; - margin-bottom: 16px; -`; - -const AccountId = styled.div` - color: #7b7b7b; - font-size: 16px; - font-weight: 400; - - @media screen and (max-width: 768px) { - font-size: 14px; - line-height: 24px; - } -`; - -const TagsContainer = styled.div` - display: flex; - flex-direction: row; - align-items: center; - justify-content: flex-start; - gap: 12px; -`; - -const ShareIconContainer = styled.svg` - width: 24px; - height: 24px; - - @media screen and (max-width: 768px) { - width: 16px; - height: 16px; - } -`; - -const Header = styled.div` - display: flex; - flex-direction: column; - // gap: 16px; - width: 100%; -`; - -const ModalTitle = styled.div` - color: #525252; - font-size: 16px; - font-weight: 600; - line-height: 20px; - word-wrap: break-word; - margin-bottom: 8px; -`; - -const Row = styled.div` - display: flex; - flex-direction: row; - align-items: center; -`; - -const [statusReview, setStatusReview] = useState({ modalOpen: false, notes: "", newStatus: "" }); - -const ShareIcon = ( - - - - - - -); - -const projectLink = `https://near.social/potlock.near/widget/Index?tab=project&projectId=${ - props.projectId -}${context.accountId && `&referrerId=${context.accountId}`}`; - -const Actions = () => ( - -); - -const policy = Near.view(props.projectId, "get_policy", {}); // TODO: CHANGE BACK TO PROPS.PROJECT ID -const isDao = !!policy; - -const userHasPermissions = useMemo(() => { - if (!policy) return false; - // TODO: break this out (NB: duplicated in Project.CreateForm) - const userRoles = policy.roles.filter((role) => { - if (role.kind === "Everyone") return true; - return role.kind.Group && role.kind.Group.includes(context.accountId); - }); - const kind = "call"; - const action = "AddProposal"; - // Check if the user is allowed to perform the action - const allowed = userRoles.some(({ permissions }) => { - return ( - permissions.includes(`${kind}:${action}`) || - permissions.includes(`${kind}:*`) || - permissions.includes(`*:${action}`) || - permissions.includes("*:*") - ); - }); - return allowed; -}, [policy]); - -const isOwner = props.projectId === context.accountId; -const isPermissionedMember = isDao && userHasPermissions; -const canEdit = isOwner || isPermissionedMember; - -const handleUpdateStatus = () => { - Near.call([ - { - contractName: REGISTRY_CONTRACT_ID, - methodName: "admin_set_project_status", - args: { - project_id: props.projectId, - status: statusReview.newStatus, - review_notes: statusReview.notes, - }, - deposit: NEAR.toIndivisible(0.01).toString(), - }, - ]); -}; - -// console.log("props.project: ", props.project); - -return ( - -
    - - {profile.name} - {canEdit && ( - - )} - - - @{props.projectId} - - - -
    - - {userIsRegistryAdmin && ( - ({ - value: status, - text: status, - })), - value: { text: props.project.status, value: props.project.status }, - onChange: (status) => { - if (status.value != project.status) { - setStatusReview({ ...statusReview, newStatus: status.value, modalOpen: true }); - } - }, - containerStyles: { - padding: "16px 24px", - }, - }} - /> - )} - -
    - option.id == props.nav).source} - props={{ - ...props, - }} - /> -
    - setStatusReview({ ...statusReview, modalOpen: false }), - children: ( - <> - Enter Notes for changing status to {statusReview.newStatus} - setStatusReview({ ...statusReview, notes }), - validate: () => { - // none necessary - }, - }} - /> - - - - - ), - }} - /> -
    -); diff --git a/apps/potlock/widget/Project/BodyHeader.jsx b/apps/potlock/widget/Project/BodyHeader.jsx new file mode 100644 index 00000000..443fd2ee --- /dev/null +++ b/apps/potlock/widget/Project/BodyHeader.jsx @@ -0,0 +1,135 @@ +const { profile, ownerId, accountId } = props; + +const Header = styled.div` + display: flex; + flex-direction: column; + padding: 0 50px; + width: 100%; +`; +const NameContainer = styled.div` + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-between; + width: 100%; +`; + +const Name = styled.div` + font-size: 48px; + font-weight: 500; + color: #2e2e2e; + line-height: 56px; + font-family: "Lora"; + ${loraCss} + + @media screen and (max-width: 768px) { + font-size: 32px; + line-height: 40px; + } +`; + +const AccountInfoContainer = styled.div` + display: flex; + flex-direction: row; + align-items: center; + justify-content: flex-start; + margin-bottom: 16px; +`; + +const AccountId = styled.div` + color: #7b7b7b; + font-size: 16px; + font-weight: 400; + + @media screen and (max-width: 768px) { + font-size: 14px; + line-height: 24px; + } +`; + +const ShareIconContainer = styled.img` + width: 24px; + height: 24px; + + @media screen and (max-width: 768px) { + width: 16px; + height: 16px; + } +`; + +const ShareIcon = ( + +); + +const policy = Near.view(props.projectId, "get_policy", {}); // TODO: CHANGE BACK TO PROPS.PROJECT ID +const isDao = !!policy; + +const userHasPermissions = useMemo(() => { + if (!policy) return false; + // TODO: break this out (NB: duplicated in Project.CreateForm) + const userRoles = policy.roles.filter((role) => { + if (role.kind === "Everyone") return true; + return role.kind.Group && role.kind.Group.includes(context.accountId); + }); + const kind = "call"; + const action = "AddProposal"; + // Check if the user is allowed to perform the action + const allowed = userRoles.some(({ permissions }) => { + return ( + permissions.includes(`${kind}:${action}`) || + permissions.includes(`${kind}:*`) || + permissions.includes(`*:${action}`) || + permissions.includes("*:*") + ); + }); + return allowed; +}, [policy]); + +const isOwner = props.projectId === context.accountId; +const isPermissionedMember = isDao && userHasPermissions; +const canEdit = isOwner || isPermissionedMember; + +return ( +
    + + {profile.name} + {canEdit && ( + + )} + + + @{props.id} + + + + +
    +); diff --git a/apps/potlock/widget/Project/Detail.jsx b/apps/potlock/widget/Project/Detail.jsx index 5dbc2114..229ed9e4 100644 --- a/apps/potlock/widget/Project/Detail.jsx +++ b/apps/potlock/widget/Project/Detail.jsx @@ -1,129 +1,125 @@ -const { ownerId, id, userIsRegistryAdmin, REGISTRY_CONTRACT_ID, tab } = props; +const { + ownerId, + projectId, + userIsRegistryAdmin, + REGISTRY_CONTRACT_ID, + tab, + POT_FACTORY_CONTRACT_ID, +} = props; -const projectId = id; -props.projectId = projectId; -const accountId = props.id ?? context.accountId; -props.accountId = accountId; +const { ProjectOptions } = VM.require(`${ownerId}/widget/Project.Options`); -const { ProjectOptions, ProfileOptions } = VM.require(`${ownerId}/widget/Project.Options`); +const project = Near.view(REGISTRY_CONTRACT_ID, "get_project_by_id", { project_id: projectId }); +if (!project || project == null) { + return "Loading"; +} -let project, donations; -if (tab === "project") { - project = Near.view(REGISTRY_CONTRACT_ID, "get_project_by_id", { project_id: projectId }); - if (!profile || project == null) { - return "Loading"; - } +if (project == undefined) { + return "Project not found"; +} +// Fetch Project Donations +const donations = Near.view("donate.potlock.near", "get_donations_for_recipient", { + recipient_id: projectId, +}); - if (project == undefined) { - return "Project not found"; - } - // Fetch Project Donations - donations = Near.view("donate.potlock.near", "get_donations_for_recipient", { - recipient_id: projectId, - }); - props.donations = donations; - props.showProject = false; // hide recepientId row +props.donations = donations; +props.navOptions = ProjectOptions(props); - if (!props.nav) props.nav = "home"; // default to home tab -} +if (!props.nav) props.nav = "home"; // default to home tab -const profile = Social.getr(`${id}/profile`); +const profile = Social.getr(`${projectId}/profile`); if (profile === null) { return "Loading"; } -console.log("profile", profile); -const name = profile.name || "No-name profile"; -const image = profile.image; -const backgroundImage = profile.backgroundImage; + +const [statusReview, setStatusReview] = useState({ modalOpen: false, notes: "", newStatus: "" }); + +const projectLink = `https://near.social/potlock.near/widget/Index?tab=project&projectId=${ + props.projectId +}${context.accountId && `&referrerId=${context.accountId}`}`; + +const handleUpdateStatus = () => { + Near.call([ + { + contractName: REGISTRY_CONTRACT_ID, + methodName: "admin_set_project_status", + args: { + project_id: props.projectId, + status: statusReview.newStatus, + review_notes: statusReview.notes, + }, + deposit: NEAR.toIndivisible(0.01).toString(), + }, + ]); +}; const Wrapper = styled.div` margin-top: calc(-1 * var(--body-top-padding, 0)); `; -const SidebarContainer = styled.div` - width: 25%; - @media screen and (max-width: 768px) { - display: none; - } -`; -const Container = styled.div` - padding: 252px 68px 68px 68px; - display: flex; - flex-direction: row; - align-items: flex-start; - justify-content: flex-start; - - @media screen and (max-width: 768px) { - flex-direction: column; - padding: 240px 16px 32px 16px; - } -`; -const BodyContainer = styled.div` - flex: 1; - --primary-color: #dd3345; -`; - -const BannerText = styled.div` - text-align: center; - color: white; +const ModalTitle = styled.div` + color: #525252; font-size: 16px; font-weight: 600; - margin: 0 8px; - word-break: break-all; - @media screen and (max-width: 768px) { - font-size: 12px; - margin-left: 4px; - } + line-height: 20px; + word-wrap: break-word; + margin-bottom: 8px; `; -props.navOptions = tab === "project" ? ProjectOptions(props) : ProfileOptions(props); -const imageHeightPx = 120; -const profileImageTranslateYPx = 220; +const Row = styled.div` + display: flex; + flex-direction: row; + align-items: center; +`; return ( - {/* {project.status !== "Approved" && ( - - )} */} - backgroundStyle: { - objectFit: "cover", - left: 0, - top: 0, - height: "280px", - }, + setStatusReview({ ...statusReview, modalOpen: false }), + children: ( + <> + Enter Notes for changing status to {statusReview.newStatus} + setStatusReview({ ...statusReview, notes }), + validate: () => { + // none necessary + }, + }} + /> + + + + + ), }} /> - - - - - - - - - ); diff --git a/apps/potlock/widget/Project/Donations.jsx b/apps/potlock/widget/Project/Donations.jsx new file mode 100644 index 00000000..34138173 --- /dev/null +++ b/apps/potlock/widget/Project/Donations.jsx @@ -0,0 +1,272 @@ +const { ownerId, donations, nearToUsd, SUPPORTED_FTS, hrefWithEnv } = props; + +const [page, setPage] = useState(0); +const [totalDonation, setTotalDonation] = useState(0); +const [search, setSearch] = useState(""); +const perPage = 30; // need to be less than 50 + +const nearLogo = + "https://ipfs.near.social/ipfs/bafkreicdcpxua47eddhzjplmrs23mdjt63czowfsa2jnw4krkt532pa2ha"; + +const { getTimePassed, _address, calcNetDonationAmount, reverseArr } = VM.require( + `${ownerId}/widget/Components.DonorsUtils` +); + +const Container = styled.div` + display: flex; + flex-direction: column; +`; + +const Table = styled.div` + display: flex; + flex-direction: column; + align-items: center; + gap: 2rem; + background: white; + box-shadow: 0px 4px 12px -4px rgba(82, 82, 82, 0.2), 0px 2px 4px -2px rgba(82, 82, 82, 0.3); + border: 1px solid rgba(41, 41, 41, 0.5); + + .transcation { + display: grid; + width: 100%; + overflow-x: scroll; + .header { + display: flex; + align-items: center; + justify-content: space-between; + padding: 1rem 0; + gap: 1rem; + background: #f6f5f3; + color: black; + font-weight: 600; + div { + width: 150px; + display: flex; + justify-content: center; + align-items: center; + } + } + } +`; + +const TrRow = styled.div` + display: flex; + align-items: center; + justify-content: space-between; + width: 100%; + gap: 1rem; + padding: 1rem 0; + > div, + > span { + width: 150px; + display: flex; + justify-content: center; + align-items: center; + color: #292929; + } + + .price { + display: flex; + gap: 1rem; + align-items: center; + img { + width: 1.5rem; + } + } + .address { + width: 200px; + color: #292929; + display: flex; + align-items: center; + justify-content: flex-start; + padding: 10px; + border-radius: 2px; + transition: all 200ms; + > .profile-image { + margin-right: 1rem; + margin-left: 0; + } + :hover { + background: #f6f5f3; + } + } +`; +const Stats = styled.div` + display: flex; + align-items: center; + gap: 3rem; + padding: 1rem 0; + .label { + color: #7b7b7b; + } + .item, + .count { + display: flex; + gap: 8px; + align-items: center; + } + .amount { + font-weight: 600; + } + .count { + margin-left: auto; + } + .count .amount { + color: #dd3345; + } +`; + +const Filter = styled.div` + display: flex; + position: relative; + img { + height: 1rem; + cursor: pointer; + } +`; + +const Search = styled.div` + display: flex; + position: relative; + border-bottom: 1px solid #dbdbdb; + img { + position: absolute; + left: 1rem; + top: 50%; + transform: translateY(-50%); + pointer-events: none; + } + input { + padding: 1rem 0; + padding-left: 3rem; + width: 100%; + &:focus { + border: none; + box-shadow: none; + } + } +`; + +let total = Big(0); +donations.forEach((donation) => { + total = total.plus(Big(donation.total_amount)); +}); +const totalDonationAmount = SUPPORTED_FTS["NEAR"].fromIndivisible(total.toString()); + +const stats = [{ label: "Donated", amount: (totalDonationAmount * nearToUsd).toFixed(2) }]; + +const SearchBar = () => ( + + search-icon + setSearch(e.target.value)} /> + +); + +return ( + + + {stats.map((stat) => ( +
    +
    ${stat.amount}
    +
    {stat.label}
    +
    + ))} +
    +
    All DONATIONS
    +
    {donations.length}
    + + sort-icon + +
    +
    + + +
    +
    +
    Project Name
    +
    Type
    +
    Amount
    +
    Extra Fee
    +
    + {donations + .slice(page * perPage, (page + 1) * perPage) + .filter((item) => (item.pot_name || item.recipient_id).toLowerCase().includes(search)) + .map((donation) => { + const { + recipient_id, + total_amount, + pot_id, + base_currency, + ft_id, + pot_name, + referrer_fee, + chef_fee, + protocol_fee, + } = donation; + + const isPot = !!pot_id; + + const donationAmount = + SUPPORTED_FTS[(base_currency || ft_id).toUpperCase()].fromIndivisible(total_amount); + + const projectId = recipient_id || pot_id; + const url = isPot + ? `?tab=pot&potId=${pot_id}` + : `?tab=project&projectId=${recipient_id}`; + const name = isPot ? pot_name : recipient_id; + + const fees = SUPPORTED_FTS[(base_currency || ft_id).toUpperCase()].fromIndivisible( + referrer_fee || 0 + chef_fee || 0 + protocol_fee || 0, + 3 + ); + return ( + + + {isPot ? ( + pot + ) : ( + + )} + {_address(name)}{" "} + +
    {isPot ? "Sponsorship" : "Direct Donation"}
    +
    + NEAR + {donationAmount} +
    +
    + NEAR + {fees} +
    +
    + ); + })} +
    + { + setPage(page); + }, + data: donations, + page: page, + perPage: perPage, + bgColor: "#7B7B7B", + }} + /> +
    +
    +); diff --git a/apps/potlock/widget/Project/Linktree.jsx b/apps/potlock/widget/Project/Linktree.jsx index 0e6d828b..2eeb5f2d 100644 --- a/apps/potlock/widget/Project/Linktree.jsx +++ b/apps/potlock/widget/Project/Linktree.jsx @@ -2,24 +2,19 @@ const IPFS_BASE_URL = "https://ipfs.near.social/ipfs/"; const linktree = props.linktree; -if (!linktree) return "Loading..."; +if (!linktree) return ""; const LinktreeContainer = styled.div` display: flex; - flex-direction: column; - align-items: flex-start; - justify-content: flex-start; - gap: 16px; + flex-wrap: wrap; + justify-content: space-between; + gap: 14px; width: 100%; - padding: 0px 14px; + padding-right: 2rem; `; -const LinktreeItemContainer = styled.div` - padding: 8px 0px; +const LinktreeItemContainer = styled.a` display: flex; - flex-direction: row; - align-items: center; - justify-content: flex-start; `; const Icon = styled.img` @@ -57,31 +52,25 @@ return ( {Object.entries(linktree).map(([k, v], idx) => { return k in itemIconUrls ? ( - + { + if (!v) { + e.preventDefault(); + } + }} + target="_blank" + > - { - if (!v) { - e.preventDefault(); - } - }} - > - {k[0].toUpperCase() + k.slice(1)} - ) : null; })} - + - - NEAR - ); diff --git a/apps/potlock/widget/Project/Options.jsx b/apps/potlock/widget/Project/Options.jsx index 2247d7cc..e8425648 100644 --- a/apps/potlock/widget/Project/Options.jsx +++ b/apps/potlock/widget/Project/Options.jsx @@ -4,21 +4,21 @@ const ProjectOptions = (props) => [ id: "home", disabled: false, source: `${props.ownerId}/widget/Project.About`, - href: props.hrefWithEnv(`?tab=project&id=${props.projectId}&nav=home`), + href: props.hrefWithEnv(`?tab=project&projectId=${props.projectId}&nav=home`), }, { label: "Social Feed", id: "feed", disabled: false, source: `${props.ownerId}/widget/Project.Feed`, - href: props.hrefWithEnv(`?tab=project&id=${props.projectId}&nav=feed`), + href: props.hrefWithEnv(`?tab=project&projectId=${props.projectId}&nav=feed`), }, { label: "Donations", id: "donations", disabled: false, - source: `${props.ownerId}/widget/Components.DonorsTrx`, - href: props.hrefWithEnv(`?tab=project&id=${props.projectId}&nav=donations`), + source: `${props.ownerId}/widget/Project.Donations`, + href: props.hrefWithEnv(`?tab=project&projectId=${props.projectId}&nav=donations`), }, { label: "Pots", @@ -42,22 +42,27 @@ const ProfileOptions = (props) => [ label: "Social Feed", id: "feed", disabled: false, - source: `${props.ownerId}/widget/Project.Feed`, - href: props.hrefWithEnv(`?tab=profile&id=${props.accountId}&nav=feed`), + source: `mob.near/widget/MainPage.N.Feed`, + href: props.hrefWithEnv(`?tab=profile&accountId=${props.accountId}&nav=feed`), }, { label: "Donations", id: "donations", disabled: false, - source: `${props.ownerId}/widget/Components.DonorsTrx`, - href: props.hrefWithEnv(`?tab=profile&id=${props.accountId}&nav=donations`), + source: `${props.ownerId}/widget/Project.Donations`, + href: props.hrefWithEnv(`?tab=profile&accountId=${props.accountId}&nav=donations`), + }, + { + label: "", + id: "followers", + disabled: false, + source: `${props.ownerId}/widget/Profile.FollowTabs`, }, { - label: "Widgets", - id: "widgets", + label: "", + id: "following", disabled: false, - source: "mob.near/widget/LastWidgets", - href: props.hrefWithEnv(`?tab=profile&id=${props.accountId}&nav=widgets`), + source: `${props.ownerId}/widget/Profile.FollowTabs`, }, ]; diff --git a/apps/potlock/widget/Project/SidebarContainer.jsx b/apps/potlock/widget/Project/SidebarContainer.jsx new file mode 100644 index 00000000..441fe8c4 --- /dev/null +++ b/apps/potlock/widget/Project/SidebarContainer.jsx @@ -0,0 +1,26 @@ +const { ownerId } = props; + +const SidebarContainer = styled.div` + width: 15%; + padding-left: 1rem; + @media screen and (max-width: 768px) { + display: none; + } +`; + +return ( + + + + +); diff --git a/apps/potlock/widget/Project/Team.jsx b/apps/potlock/widget/Project/Team.jsx index 920afb1f..499d2730 100644 --- a/apps/potlock/widget/Project/Team.jsx +++ b/apps/potlock/widget/Project/Team.jsx @@ -1,3 +1,5 @@ +const { ownerId } = props; + const Container = styled.div` display: flex; flex-direction: row; @@ -118,7 +120,7 @@ return ( if (teamMember.match(/.near/i).length > 0) { return ( Date: Mon, 19 Feb 2024 11:32:55 +0400 Subject: [PATCH 05/23] organized profile & project dir --- apps/potlock/widget/Components/Feed.jsx | 2 +- .../{Project => Profile}/BannerHeader.jsx | 6 ++- apps/potlock/widget/Profile/Body.jsx | 7 +-- .../{Project => Profile}/BodyHeader.jsx | 10 ++-- .../DonationsTable.jsx} | 1 - .../widget/{Project => Profile}/Feed.jsx | 1 + apps/potlock/widget/Profile/Index.jsx | 52 ++----------------- .../widget/{Project => Profile}/Linktree.jsx | 0 apps/potlock/widget/Profile/Tags.jsx | 7 ++- apps/potlock/widget/Project/Card.jsx | 2 +- apps/potlock/widget/Project/CreateForm.jsx | 2 +- apps/potlock/widget/Project/Detail.jsx | 2 + apps/potlock/widget/Project/Options.jsx | 20 +++++-- .../widget/Project/SidebarContainer.jsx | 26 ---------- 14 files changed, 44 insertions(+), 94 deletions(-) rename apps/potlock/widget/{Project => Profile}/BannerHeader.jsx (99%) rename apps/potlock/widget/{Project => Profile}/BodyHeader.jsx (94%) rename apps/potlock/widget/{Project/Donations.jsx => Profile/DonationsTable.jsx} (99%) rename apps/potlock/widget/{Project => Profile}/Feed.jsx (86%) rename apps/potlock/widget/{Project => Profile}/Linktree.jsx (100%) delete mode 100644 apps/potlock/widget/Project/SidebarContainer.jsx diff --git a/apps/potlock/widget/Components/Feed.jsx b/apps/potlock/widget/Components/Feed.jsx index a3493700..3db0b6de 100644 --- a/apps/potlock/widget/Components/Feed.jsx +++ b/apps/potlock/widget/Components/Feed.jsx @@ -16,6 +16,6 @@ const Container = styled.div` return ( - + ); diff --git a/apps/potlock/widget/Project/BannerHeader.jsx b/apps/potlock/widget/Profile/BannerHeader.jsx similarity index 99% rename from apps/potlock/widget/Project/BannerHeader.jsx rename to apps/potlock/widget/Profile/BannerHeader.jsx index 4cc777ff..04724020 100644 --- a/apps/potlock/widget/Project/BannerHeader.jsx +++ b/apps/potlock/widget/Profile/BannerHeader.jsx @@ -1,5 +1,7 @@ -const { ownerId } = props; -const accountId = props.projectId; +const { ownerId, accountId } = props; + +console.log("accountId", accountId); + if (!accountId) { return "No account ID"; } diff --git a/apps/potlock/widget/Profile/Body.jsx b/apps/potlock/widget/Profile/Body.jsx index ff4b351a..aa9f4246 100644 --- a/apps/potlock/widget/Profile/Body.jsx +++ b/apps/potlock/widget/Profile/Body.jsx @@ -50,9 +50,10 @@ const SidebarContainer = styled.div` return ( {profile.name} - {canEdit && ( + {canEdit && projectId && ( )} - @{props.id} + @{id} diff --git a/apps/potlock/widget/Project/Donations.jsx b/apps/potlock/widget/Profile/DonationsTable.jsx similarity index 99% rename from apps/potlock/widget/Project/Donations.jsx rename to apps/potlock/widget/Profile/DonationsTable.jsx index 34138173..39838901 100644 --- a/apps/potlock/widget/Project/Donations.jsx +++ b/apps/potlock/widget/Profile/DonationsTable.jsx @@ -211,7 +211,6 @@ return ( } = donation; const isPot = !!pot_id; - const donationAmount = SUPPORTED_FTS[(base_currency || ft_id).toUpperCase()].fromIndivisible(total_amount); diff --git a/apps/potlock/widget/Project/Feed.jsx b/apps/potlock/widget/Profile/Feed.jsx similarity index 86% rename from apps/potlock/widget/Project/Feed.jsx rename to apps/potlock/widget/Profile/Feed.jsx index cadf07b5..075795a6 100644 --- a/apps/potlock/widget/Project/Feed.jsx +++ b/apps/potlock/widget/Profile/Feed.jsx @@ -1,3 +1,4 @@ +console.log(accounts); return ( - - - - ); diff --git a/apps/potlock/widget/Project/Linktree.jsx b/apps/potlock/widget/Profile/Linktree.jsx similarity index 100% rename from apps/potlock/widget/Project/Linktree.jsx rename to apps/potlock/widget/Profile/Linktree.jsx diff --git a/apps/potlock/widget/Profile/Tags.jsx b/apps/potlock/widget/Profile/Tags.jsx index f5c7cc6f..7f3d77e5 100644 --- a/apps/potlock/widget/Profile/Tags.jsx +++ b/apps/potlock/widget/Profile/Tags.jsx @@ -1,3 +1,5 @@ +const { profile } = props; + const Tags = styled.div` display: flex; gap: 8px; @@ -12,11 +14,12 @@ const Tag = styled.span` color: #2e2e2e; `; -if (!props.tags || props.tags.length === 0) return "No tags"; +const tags = Object.keys(profile.tags ?? {}); +if (!tags || tags.length === 0) return "No tags"; return ( - {props.tags.map((tag, tagIndex) => ( + {tags.map((tag, tagIndex) => ( {tag} ))} diff --git a/apps/potlock/widget/Project/Card.jsx b/apps/potlock/widget/Project/Card.jsx index 85dd51a5..8fc681df 100644 --- a/apps/potlock/widget/Project/Card.jsx +++ b/apps/potlock/widget/Project/Card.jsx @@ -124,7 +124,7 @@ const projectUrl = props.hrefWithEnv(`?tab=project&projectId=${projectId}`); return ( diff --git a/apps/potlock/widget/Project/Options.jsx b/apps/potlock/widget/Project/Options.jsx index e8425648..2ad36067 100644 --- a/apps/potlock/widget/Project/Options.jsx +++ b/apps/potlock/widget/Project/Options.jsx @@ -10,14 +10,14 @@ const ProjectOptions = (props) => [ label: "Social Feed", id: "feed", disabled: false, - source: `${props.ownerId}/widget/Project.Feed`, + source: `${props.ownerId}/widget/Profile.Feed`, href: props.hrefWithEnv(`?tab=project&projectId=${props.projectId}&nav=feed`), }, { label: "Donations", id: "donations", disabled: false, - source: `${props.ownerId}/widget/Project.Donations`, + source: `${props.ownerId}/widget/Profile.DonationsTable`, href: props.hrefWithEnv(`?tab=project&projectId=${props.projectId}&nav=donations`), }, { @@ -35,6 +35,18 @@ const ProjectOptions = (props) => [ id: "funding", disabled: true, }, + { + label: "", + id: "followers", + disabled: false, + source: `${props.ownerId}/widget/Profile.FollowTabs`, + }, + { + label: "", + id: "following", + disabled: false, + source: `${props.ownerId}/widget/Profile.FollowTabs`, + }, ]; const ProfileOptions = (props) => [ @@ -42,14 +54,14 @@ const ProfileOptions = (props) => [ label: "Social Feed", id: "feed", disabled: false, - source: `mob.near/widget/MainPage.N.Feed`, + source: `${props.ownerId}/widget/Profile.Feed`, href: props.hrefWithEnv(`?tab=profile&accountId=${props.accountId}&nav=feed`), }, { label: "Donations", id: "donations", disabled: false, - source: `${props.ownerId}/widget/Project.Donations`, + source: `${props.ownerId}/widget/Profile.DonationsTable`, href: props.hrefWithEnv(`?tab=profile&accountId=${props.accountId}&nav=donations`), }, { diff --git a/apps/potlock/widget/Project/SidebarContainer.jsx b/apps/potlock/widget/Project/SidebarContainer.jsx deleted file mode 100644 index 441fe8c4..00000000 --- a/apps/potlock/widget/Project/SidebarContainer.jsx +++ /dev/null @@ -1,26 +0,0 @@ -const { ownerId } = props; - -const SidebarContainer = styled.div` - width: 15%; - padding-left: 1rem; - @media screen and (max-width: 768px) { - display: none; - } -`; - -return ( - - - - -); From 851685935a20201a33d18d0df249f123e12a2a18 Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Mon, 19 Feb 2024 15:13:32 +0400 Subject: [PATCH 06/23] fix donations table --- apps/potlock/widget/Profile/BannerHeader.jsx | 2 - apps/potlock/widget/Profile/Details.jsx | 3 +- apps/potlock/widget/Profile/Index.jsx | 57 +++++++++++++++++++- apps/potlock/widget/Project/Card.jsx | 2 +- 4 files changed, 59 insertions(+), 5 deletions(-) diff --git a/apps/potlock/widget/Profile/BannerHeader.jsx b/apps/potlock/widget/Profile/BannerHeader.jsx index 04724020..0fd2d09e 100644 --- a/apps/potlock/widget/Profile/BannerHeader.jsx +++ b/apps/potlock/widget/Profile/BannerHeader.jsx @@ -1,7 +1,5 @@ const { ownerId, accountId } = props; -console.log("accountId", accountId); - if (!accountId) { return "No account ID"; } diff --git a/apps/potlock/widget/Profile/Details.jsx b/apps/potlock/widget/Profile/Details.jsx index 34877085..ab596443 100644 --- a/apps/potlock/widget/Profile/Details.jsx +++ b/apps/potlock/widget/Profile/Details.jsx @@ -5,6 +5,7 @@ const { profileLink, getTagsFromSocialProfileData, POT_FACTORY_CONTRACT_ID, + DONATION_CONTRACT_ID, SUPPORTED_FTS: { NEAR }, } = props; @@ -33,7 +34,7 @@ const getSponsorships = (potId, potDetail) => { // Get Sponsorships if (!directDonations.length) { - Near.asyncView("donate.potlock.near", "get_donations_for_donor", { + Near.asyncView(DONATION_CONTRACT_ID, "get_donations_for_donor", { donor_id: accountId, }).then((donations) => setDirectDonation(donations)); } diff --git a/apps/potlock/widget/Profile/Index.jsx b/apps/potlock/widget/Profile/Index.jsx index 414514f1..1583087c 100644 --- a/apps/potlock/widget/Profile/Index.jsx +++ b/apps/potlock/widget/Profile/Index.jsx @@ -1,4 +1,9 @@ -const { ownerId } = props; +const { + ownerId, + POT_FACTORY_CONTRACT_ID, + DONATION_CONTRACT_ID, + SUPPORTED_FTS: { NEAR }, +} = props; const accountId = props.accountId ?? context.accountId; const { ProfileOptions } = VM.require(`${ownerId}/widget/Project.Options`); @@ -7,6 +12,56 @@ if (!accountId) { return "No account ID"; } +const [pots, setPots] = useState(null); +const [directDonations, setDirectDonation] = useState(null); +const [sponsorship, setSponsorship] = useState(null); +const [potDonations, setPotDonations] = useState([]); + +const getPotConfig = (potId) => Near.asyncView(potId, "get_config", {}); + +const getSponsorships = (potId, potDetail) => { + return Near.asyncView(potId, "get_matching_pool_donations", {}).then((donations) => { + donations = donations.filter((donations) => donations.donor_id === accountId); + const updatedDonations = donations.map((donation) => ({ + ...donation, + base_currency: potDetail.base_currency, + pot_name: potDetail.pot_name, + pot_id: potId, + })); + if (updatedDonations.length) { + setSponsorship([...(sponsorship || []), ...updatedDonations]); + } + }); +}; + +// Get Direct Donations +if (!directDonations) { + Near.asyncView(DONATION_CONTRACT_ID, "get_donations_for_donor", { + donor_id: accountId, + }).then((donations) => setDirectDonation(donations)); +} +// Get Sponsorships +if (!pots) { + Near.asyncView(POT_FACTORY_CONTRACT_ID, "get_pots", {}).then((pots) => { + setPots(pots || []); + }); +} else if (pots.length && !sponsorship) { + pots.forEach((pot) => { + getPotConfig(pot.id).then((potDetail) => { + getSponsorships(pot.id, potDetail); + }); + }); +} + +// Get Total Donations +const [allDonations] = useMemo(() => { + const allDonations = [...(sponsorship || []), ...(directDonations || [])]; + allDonations.sort((a, b) => b.donated_at - a.donated_at); + return [allDonations]; +}, [directDonations, sponsorship, potDonations]); + +props.donations = allDonations; + const profile = props.profile ?? Social.getr(`${accountId}/profile`); const fast = !props.profile; diff --git a/apps/potlock/widget/Project/Card.jsx b/apps/potlock/widget/Project/Card.jsx index 8fc681df..300c71aa 100644 --- a/apps/potlock/widget/Project/Card.jsx +++ b/apps/potlock/widget/Project/Card.jsx @@ -127,7 +127,7 @@ return ( src={`${ownerId}/widget/Profile.BannerHeader`} props={{ ...props, - projectId, + accountId: projectId, profile: projectProfile, profileImageTranslateYPx: 145, profileImageTranslateYPxMobile: 122, From af5730f32c810f3a34748fc342bd7f6eb24f26f1 Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Mon, 19 Feb 2024 15:20:47 +0400 Subject: [PATCH 07/23] fix linktree website url --- apps/potlock/widget/Profile/Linktree.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/potlock/widget/Profile/Linktree.jsx b/apps/potlock/widget/Profile/Linktree.jsx index 2eeb5f2d..336adffd 100644 --- a/apps/potlock/widget/Profile/Linktree.jsx +++ b/apps/potlock/widget/Profile/Linktree.jsx @@ -1,6 +1,6 @@ const IPFS_BASE_URL = "https://ipfs.near.social/ipfs/"; -const linktree = props.linktree; +const linktree = props.profile?.linktree; if (!linktree) return ""; @@ -45,9 +45,9 @@ const itemIconUrls = { const fullUrls = { twitter: (handle) => `https://twitter.com/${handle}`, github: (username) => `https://github.com/${username}`, - website: (url) => url, + website: (url) => `https://${url}`, }; - +console.log(linktree); return ( {Object.entries(linktree).map(([k, v], idx) => { From abdd759287fc3f684be17e410f6589e49c8878e8 Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Mon, 19 Feb 2024 15:34:40 +0400 Subject: [PATCH 08/23] hide nav label if it is empty --- apps/potlock/widget/Project/NavOptionsMobile.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/potlock/widget/Project/NavOptionsMobile.jsx b/apps/potlock/widget/Project/NavOptionsMobile.jsx index 1fae355c..ac1fa9c4 100644 --- a/apps/potlock/widget/Project/NavOptionsMobile.jsx +++ b/apps/potlock/widget/Project/NavOptionsMobile.jsx @@ -55,6 +55,8 @@ return ( {option.label} + ) : !option.label ? ( + "" ) : ( Date: Mon, 19 Feb 2024 15:52:04 +0400 Subject: [PATCH 09/23] fix profile mobile view --- apps/potlock/widget/Profile/Body.jsx | 26 +++++++++++++------ apps/potlock/widget/Profile/BodyHeader.jsx | 3 +++ .../potlock/widget/Profile/DonationsTable.jsx | 7 ++--- apps/potlock/widget/Project/Options.jsx | 2 +- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/apps/potlock/widget/Profile/Body.jsx b/apps/potlock/widget/Profile/Body.jsx index aa9f4246..9117679c 100644 --- a/apps/potlock/widget/Profile/Body.jsx +++ b/apps/potlock/widget/Profile/Body.jsx @@ -23,6 +23,7 @@ const Container = styled.div` @media screen and (max-width: 768px) { flex-direction: column; + gap: 1rem; padding-top: 240px; } `; @@ -32,10 +33,15 @@ const Details = styled.div` flex-direction: column; gap: 2rem; flex: 1 1 0%; + width: 100%; + overflow-x: scroll; .nav-view { width: 100%; padding: 24px 50px; background: #f6f5f3; + @media screen and (max-width: 768px) { + padding: 24px 1rem; + } } `; @@ -43,7 +49,10 @@ const SidebarContainer = styled.div` width: 15%; padding-left: 1rem; @media screen and (max-width: 768px) { - display: none; + width: fit-content; + > div:first-of-type { + display: none; + } } `; @@ -62,8 +71,14 @@ return ( }, }} /> - {/* Side Nav */} + {/* Side Nav */} + - + {/* Body */}
    ( src="https://ipfs.near.social/ipfs/bafkreiaayazawvdxdt2f4ahyh3yy3sz622bwwxdnrj32jzkoec7k7jaxza" alt="search-icon" /> - setSearch(e.target.value)} /> + setSearch(e.target.value)} /> ); diff --git a/apps/potlock/widget/Project/Options.jsx b/apps/potlock/widget/Project/Options.jsx index 2ad36067..bcae5a8a 100644 --- a/apps/potlock/widget/Project/Options.jsx +++ b/apps/potlock/widget/Project/Options.jsx @@ -14,7 +14,7 @@ const ProjectOptions = (props) => [ href: props.hrefWithEnv(`?tab=project&projectId=${props.projectId}&nav=feed`), }, { - label: "Donations", + label: "", id: "donations", disabled: false, source: `${props.ownerId}/widget/Profile.DonationsTable`, From 414cb9fb8d19678b5b071b4d8761488b4f4a006f Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Mon, 19 Feb 2024 16:50:32 +0400 Subject: [PATCH 10/23] bugs fix --- apps/potlock/widget/Index.jsx | 2 +- .../widget/Profile/{Index.jsx => Detail.jsx} | 1 + apps/potlock/widget/Profile/Details.jsx | 93 ------------------- apps/potlock/widget/Profile/FollowButton.jsx | 46 --------- apps/potlock/widget/Profile/FollowTabs.jsx | 11 ++- apps/potlock/widget/Profile/FollowersList.jsx | 25 ++++- apps/potlock/widget/Profile/FollowingList.jsx | 32 ------- apps/potlock/widget/Profile/Linktree.jsx | 4 +- apps/potlock/widget/Project/Card.jsx | 6 +- 9 files changed, 38 insertions(+), 182 deletions(-) rename apps/potlock/widget/Profile/{Index.jsx => Detail.jsx} (99%) delete mode 100644 apps/potlock/widget/Profile/Details.jsx delete mode 100644 apps/potlock/widget/Profile/FollowButton.jsx delete mode 100644 apps/potlock/widget/Profile/FollowingList.jsx diff --git a/apps/potlock/widget/Index.jsx b/apps/potlock/widget/Index.jsx index d28a6d52..ca25d7a3 100644 --- a/apps/potlock/widget/Index.jsx +++ b/apps/potlock/widget/Index.jsx @@ -189,7 +189,7 @@ const tabContentWidget = { [DEPLOY_POT_TAB]: "Pots.Deploy", [POT_DETAIL_TAB]: "Pots.Detail", [DONORS_TAB]: "Components.Donors", - [PROFILE_TAB]: "Profile.Index", + [PROFILE_TAB]: "Profile.Detail", }; const getTabWidget = (tab) => { diff --git a/apps/potlock/widget/Profile/Index.jsx b/apps/potlock/widget/Profile/Detail.jsx similarity index 99% rename from apps/potlock/widget/Profile/Index.jsx rename to apps/potlock/widget/Profile/Detail.jsx index 1583087c..f7dea8a8 100644 --- a/apps/potlock/widget/Profile/Index.jsx +++ b/apps/potlock/widget/Profile/Detail.jsx @@ -25,6 +25,7 @@ const getSponsorships = (potId, potDetail) => { const updatedDonations = donations.map((donation) => ({ ...donation, base_currency: potDetail.base_currency, + pot_name: potDetail.pot_name, pot_id: potId, })); diff --git a/apps/potlock/widget/Profile/Details.jsx b/apps/potlock/widget/Profile/Details.jsx deleted file mode 100644 index ab596443..00000000 --- a/apps/potlock/widget/Profile/Details.jsx +++ /dev/null @@ -1,93 +0,0 @@ -const { - profile, - accountId, - ownerId, - profileLink, - getTagsFromSocialProfileData, - POT_FACTORY_CONTRACT_ID, - DONATION_CONTRACT_ID, - SUPPORTED_FTS: { NEAR }, -} = props; - -const [directDonations, setDirectDonation] = useState([]); -const [sponsorship, setSponsorship] = useState([]); -const [potDonations, setPotDonations] = useState([]); - -if (!props.nav) props.nav = "feed"; - -const tags = getTagsFromSocialProfileData(profile); - -const getPotConfig = (potId) => Near.asyncView(potId, "get_config", {}); - -const getSponsorships = (potId, potDetail) => { - Near.asyncView(potId, "get_matching_pool_donations", {}).then((donations) => { - donations = donations.filter((donations) => donations.donor_id === accountId); - const updatedDonations = (donations = donations.map((donation) => ({ - ...donation, - base_currency: potDetail.base_currency, - pot_name: potDetail.pot_name, - pot_id: potId, - }))); - setSponsorship(updatedDonations); - }); -}; - -// Get Sponsorships -if (!directDonations.length) { - Near.asyncView(DONATION_CONTRACT_ID, "get_donations_for_donor", { - donor_id: accountId, - }).then((donations) => setDirectDonation(donations)); -} -// Get Direct Donations -if (!sponsorship.length) { - Near.asyncView(POT_FACTORY_CONTRACT_ID, "get_pots", {}).then((pots) => { - pots.forEach((pot) => { - getPotConfig(pot.id).then((potDetail) => { - getSponsorships(pot.id, potDetail); - }); - }); - }); -} - -// Get Total Donations -const [allDonations] = useMemo(() => { - const donations = [...sponsorship, ...directDonations]; - donations.sort((a, b) => b.donated_at - a.donated_at); - return [donations]; -}, [directDonations, sponsorship]); - -props.donations = allDonations; - -const Body = styled.div` - display: flex; - flex-direction: column; - gap: 2rem; - flex: 1 1 0%; - .nav-view { - width: 100%; - padding: 24px 50px; - background: #f6f5f3; - } -`; - -return ( - - - {/* body */} -
    - option.id == props.nav).source} - props={{ - ...props, - }} - /> -
    - -); diff --git a/apps/potlock/widget/Profile/FollowButton.jsx b/apps/potlock/widget/Profile/FollowButton.jsx deleted file mode 100644 index a0062465..00000000 --- a/apps/potlock/widget/Profile/FollowButton.jsx +++ /dev/null @@ -1,46 +0,0 @@ -if (!props.accountId || !context.accountId || context.accountId === props.accountId) { - return ""; -} - -const followEdge = Social.keys(`${context.accountId}/graph/follow/${props.accountId}`, undefined, { - values_only: true, -}); - -const inverseEdge = Social.keys(`${props.accountId}/graph/follow/${context.accountId}`, undefined, { - values_only: true, -}); - -const loading = followEdge === null || inverseEdge === null; -const follow = followEdge && Object.keys(followEdge).length; -const inverse = inverseEdge && Object.keys(inverseEdge).length; - -const type = follow ? "unfollow" : "follow"; - -const data = { - graph: { follow: { [props.accountId]: follow ? null : "" } }, - index: { - graph: JSON.stringify({ - key: "follow", - value: { - type, - accountId: props.accountId, - }, - }), - notify: JSON.stringify({ - key: props.accountId, - value: { - type, - }, - }), - }, -}; - -return ( - - {loading ? "Loading" : follow ? "Following" : inverse ? "Follow back" : "Follow"} - -); diff --git a/apps/potlock/widget/Profile/FollowTabs.jsx b/apps/potlock/widget/Profile/FollowTabs.jsx index 49c62236..abbca3a5 100644 --- a/apps/potlock/widget/Profile/FollowTabs.jsx +++ b/apps/potlock/widget/Profile/FollowTabs.jsx @@ -1,5 +1,12 @@ const { ownerId, accountId, projectId, nav } = props; +const Container = styled.div` + display: flex; + flex-direction: column; + .tab-content { + padding: 1rem 0; + } +`; const Nav = styled.div` .nav-pills { background: #fbfbfb; @@ -29,7 +36,7 @@ const Nav = styled.div` const profileLink = `/${ownerId}/widget/Index?tab=profile&accountId=${accountId}`; return ( - <> +
    - + ); diff --git a/apps/potlock/widget/Profile/FollowersList.jsx b/apps/potlock/widget/Profile/FollowersList.jsx index 011f81b0..58325c15 100644 --- a/apps/potlock/widget/Profile/FollowersList.jsx +++ b/apps/potlock/widget/Profile/FollowersList.jsx @@ -20,11 +20,30 @@ if (nav === "followers") { followers = Object.entries(followers[accountId].graph.follow || {}); followers.sort((a, b) => b[1] - a[1]); } +const Container = styled.div` + display: flex; + flex-direction: column; + gap: 1rem; + .profile-row { + display: flex; + width: 100%; + justify-content: space-between; + align-items: center; + } + .btn-primary { + background-color: #dd3345; + border: none; + transition: all 300ms; + :hover { + opacity: 0.8; + } + } +`; return ( - <> + {followers.map(([accountId], i) => ( -
    +
    @@ -33,5 +52,5 @@ return (
    ))} - +
    ); diff --git a/apps/potlock/widget/Profile/FollowingList.jsx b/apps/potlock/widget/Profile/FollowingList.jsx deleted file mode 100644 index e02658b3..00000000 --- a/apps/potlock/widget/Profile/FollowingList.jsx +++ /dev/null @@ -1,32 +0,0 @@ -const accountId = props.accountId; - -if (!accountId) { - return ""; -} - -let following = Social.keys(`${accountId}/graph/follow/*`, "final", { - return_type: "BlockHeight", - values_only: true, -}); - -if (following === null) { - return "Loading"; -} - -following = Object.entries(following[accountId].graph.follow || {}); -following.sort((a, b) => b[1] - a[1]); - -return ( - <> - {following.map(([accountId], i) => ( -
    -
    - -
    -
    - -
    -
    - ))} - -); diff --git a/apps/potlock/widget/Profile/Linktree.jsx b/apps/potlock/widget/Profile/Linktree.jsx index 336adffd..d2bd269e 100644 --- a/apps/potlock/widget/Profile/Linktree.jsx +++ b/apps/potlock/widget/Profile/Linktree.jsx @@ -68,7 +68,9 @@ return ( })} diff --git a/apps/potlock/widget/Project/Card.jsx b/apps/potlock/widget/Project/Card.jsx index 300c71aa..c90931b9 100644 --- a/apps/potlock/widget/Project/Card.jsx +++ b/apps/potlock/widget/Project/Card.jsx @@ -91,8 +91,6 @@ const { name, description, plCategories } = projectProfile; // const description = projectProfile?.description || "No description"; // const category = projectProfile?.category || "No category"; -const tags = getTagsFromSocialProfileData(projectProfile); - const donationsForProject = Near.view( potId || donationContractId, potId ? "get_donations_for_project" : "get_donations_for_recipient", @@ -158,10 +156,10 @@ return ( : description} From 8566619c5d61b40cc5f964ac1ff2532e080f074e Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Mon, 19 Feb 2024 16:56:17 +0400 Subject: [PATCH 11/23] update linktree to match main --- apps/potlock/widget/Profile/Linktree.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/potlock/widget/Profile/Linktree.jsx b/apps/potlock/widget/Profile/Linktree.jsx index d2bd269e..901be752 100644 --- a/apps/potlock/widget/Profile/Linktree.jsx +++ b/apps/potlock/widget/Profile/Linktree.jsx @@ -43,9 +43,9 @@ const itemIconUrls = { }; const fullUrls = { - twitter: (handle) => `https://twitter.com/${handle}`, - github: (username) => `https://github.com/${username}`, - website: (url) => `https://${url}`, + twitter: (handle) => `https://twitter.com/${handle.trim()}`, + github: (username) => `https://github.com/${username.trim()}`, + website: (url) => (url.includes("http") ? url : `https://${url.trim()}`), }; console.log(linktree); return ( From f726310e1c1ada091d7220a041791dd6de4d59f0 Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Mon, 19 Feb 2024 17:45:55 +0400 Subject: [PATCH 12/23] add filter logic to donations table --- .../potlock/widget/Profile/DonationsTable.jsx | 191 ++++++++++++------ 1 file changed, 125 insertions(+), 66 deletions(-) diff --git a/apps/potlock/widget/Profile/DonationsTable.jsx b/apps/potlock/widget/Profile/DonationsTable.jsx index bce5eccb..c6240f4c 100644 --- a/apps/potlock/widget/Profile/DonationsTable.jsx +++ b/apps/potlock/widget/Profile/DonationsTable.jsx @@ -1,7 +1,8 @@ const { ownerId, donations, nearToUsd, SUPPORTED_FTS, hrefWithEnv } = props; const [page, setPage] = useState(0); -const [totalDonation, setTotalDonation] = useState(0); +const [totalDonations, setTotalDonation] = useState(donations); +const [filteredDonations, setFilteredDonations] = useState(donations); const [search, setSearch] = useState(""); const perPage = 30; // need to be less than 50 @@ -15,6 +16,9 @@ const { getTimePassed, _address, calcNetDonationAmount, reverseArr } = VM.requir const Container = styled.div` display: flex; flex-direction: column; + .search-bar > div { + background: white; + } `; const Table = styled.div` @@ -34,7 +38,7 @@ const Table = styled.div` display: flex; align-items: center; justify-content: space-between; - padding: 1rem 0; + padding: 1rem; gap: 1rem; background: #f6f5f3; color: black; @@ -55,7 +59,7 @@ const TrRow = styled.div` justify-content: space-between; width: 100%; gap: 1rem; - padding: 1rem 0; + padding: 1rem; > div, > span { width: 150px; @@ -156,6 +160,11 @@ const totalDonationAmount = SUPPORTED_FTS["NEAR"].fromIndivisible(total.toString const stats = [{ label: "Donated", amount: (totalDonationAmount * nearToUsd).toFixed(2) }]; +useMemo(() => { + setTotalDonation(donations); + setFilteredDonations(donations); +}, [donations]); + const SearchBar = () => ( ( ); +const APPLICATIONS_FILTERS = { + ALL: "All donations", + DIRECT: "Direct Donation", + SPONSORSHIP: "Sponsorship", +}; + +const searchDonations = (searchTerm) => { + const filteredApplications = totalDonations.filter((item) => + (item.pot_name || item.recipient_id).toLowerCase().includes(searchTerm) + ); + return filteredApplications; +}; + +const sortDonations = (sortVal) => { + const displayedDonations = searchDonations(search); + let filtered; + switch (sortVal) { + case APPLICATIONS_FILTERS[ALL]: + return displayedDonations; + + case APPLICATIONS_FILTERS["DIRECT"]: + filtered = displayedDonations.filter((donation) => { + return !donation.pot_id; + }); + return filtered; + + case APPLICATIONS_FILTERS["SPONSORSHIP"]: + filtered = displayedDonations.filter((donation) => { + return !!donation.pot_id; + }); + return filtered; + + default: + return displayedDonations; + } +}; + return ( @@ -178,15 +224,30 @@ return (
    All DONATIONS
    {donations.length}
    - - sort-icon -
    - + {/* */} +
    + { + setSearch(value); + const filtered = searchDonations(value); + setFilteredDonations(filtered); + }, + handleSortChange: (sortVal) => { + const filtered = sortDonations(sortVal); + setFilteredDonations(filtered); + }, + }} + /> +
    @@ -195,71 +256,69 @@ return (
    Amount
    Extra Fee
    - {donations - .slice(page * perPage, (page + 1) * perPage) - .filter((item) => (item.pot_name || item.recipient_id).toLowerCase().includes(search)) - .map((donation) => { - const { - recipient_id, - total_amount, - pot_id, - base_currency, - ft_id, - pot_name, - referrer_fee, - chef_fee, - protocol_fee, - } = donation; + {!filteredDonations.length &&
    No donations to display
    } + {filteredDonations.map((donation) => { + const { + recipient_id, + total_amount, + pot_id, + base_currency, + ft_id, + pot_name, + referrer_fee, + chef_fee, + protocol_fee, + } = donation; - const isPot = !!pot_id; - const donationAmount = - SUPPORTED_FTS[(base_currency || ft_id).toUpperCase()].fromIndivisible(total_amount); + const isPot = !!pot_id; + const donationAmount = + SUPPORTED_FTS[(base_currency || ft_id).toUpperCase()].fromIndivisible(total_amount); - const projectId = recipient_id || pot_id; - const url = isPot - ? `?tab=pot&potId=${pot_id}` - : `?tab=project&projectId=${recipient_id}`; - const name = isPot ? pot_name : recipient_id; + const projectId = recipient_id || pot_id; + const url = isPot ? `?tab=pot&potId=${pot_id}` : `?tab=project&projectId=${recipient_id}`; + const name = isPot ? pot_name : recipient_id; - const fees = SUPPORTED_FTS[(base_currency || ft_id).toUpperCase()].fromIndivisible( - referrer_fee || 0 + chef_fee || 0 + protocol_fee || 0, - 3 - ); - return ( - - - {isPot ? ( - pot - ) : ( - - )} - {_address(name)}{" "} - -
    {isPot ? "Sponsorship" : "Direct Donation"}
    -
    - NEAR - {donationAmount} -
    -
    - NEAR - {fees} -
    -
    - ); - })} + const fees = SUPPORTED_FTS[(base_currency || ft_id).toUpperCase()].fromIndivisible( + referrer_fee || 0 + chef_fee || 0 + protocol_fee || 0, + 3 + ); + return ( + + + {isPot ? ( + pot + ) : ( + + )} + {_address(name)}{" "} + +
    {isPot ? "Sponsorship" : "Direct Donation"}
    +
    + NEAR + {donationAmount} +
    +
    + NEAR + {fees} +
    +
    + ); + })}
    { setPage(page); + setTotalDonation(donations.slice(page * perPage, (page + 1) * perPage)); + sortDonations(); }, data: donations, page: page, From 7e29c0c5fa8bb943e3d975fc66efc59b1efaa83b Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Mon, 19 Feb 2024 21:18:28 +0400 Subject: [PATCH 13/23] fix donation fetch err --- apps/potlock/widget/Profile/Detail.jsx | 18 +++++++----------- apps/potlock/widget/Profile/Linktree.jsx | 1 - 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/apps/potlock/widget/Profile/Detail.jsx b/apps/potlock/widget/Profile/Detail.jsx index f7dea8a8..cc535e33 100644 --- a/apps/potlock/widget/Profile/Detail.jsx +++ b/apps/potlock/widget/Profile/Detail.jsx @@ -14,8 +14,9 @@ if (!accountId) { const [pots, setPots] = useState(null); const [directDonations, setDirectDonation] = useState(null); -const [sponsorship, setSponsorship] = useState(null); +const [sponsorship, setSponsorship] = useState([]); const [potDonations, setPotDonations] = useState([]); +const [isComplete, setISComplete] = useState(false); const getPotConfig = (potId) => Near.asyncView(potId, "get_config", {}); @@ -25,16 +26,15 @@ const getSponsorships = (potId, potDetail) => { const updatedDonations = donations.map((donation) => ({ ...donation, base_currency: potDetail.base_currency, - pot_name: potDetail.pot_name, pot_id: potId, })); if (updatedDonations.length) { - setSponsorship([...(sponsorship || []), ...updatedDonations]); + setSponsorship((sponsorship) => [...sponsorship, ...updatedDonations]); + if (potId === pots[pots.length - 1].id) setISComplete(true); } }); }; - // Get Direct Donations if (!directDonations) { Near.asyncView(DONATION_CONTRACT_ID, "get_donations_for_donor", { @@ -46,7 +46,7 @@ if (!pots) { Near.asyncView(POT_FACTORY_CONTRACT_ID, "get_pots", {}).then((pots) => { setPots(pots || []); }); -} else if (pots.length && !sponsorship) { +} else if (pots.length && !isComplete) { pots.forEach((pot) => { getPotConfig(pot.id).then((potDetail) => { getSponsorships(pot.id, potDetail); @@ -54,12 +54,8 @@ if (!pots) { }); } -// Get Total Donations -const [allDonations] = useMemo(() => { - const allDonations = [...(sponsorship || []), ...(directDonations || [])]; - allDonations.sort((a, b) => b.donated_at - a.donated_at); - return [allDonations]; -}, [directDonations, sponsorship, potDonations]); +const allDonations = [...(directDonations || []), ...sponsorship]; +allDonations.sort((a, b) => b.donated_at - a.donated_at); props.donations = allDonations; diff --git a/apps/potlock/widget/Profile/Linktree.jsx b/apps/potlock/widget/Profile/Linktree.jsx index 901be752..3faed558 100644 --- a/apps/potlock/widget/Profile/Linktree.jsx +++ b/apps/potlock/widget/Profile/Linktree.jsx @@ -47,7 +47,6 @@ const fullUrls = { github: (username) => `https://github.com/${username.trim()}`, website: (url) => (url.includes("http") ? url : `https://${url.trim()}`), }; -console.log(linktree); return ( {Object.entries(linktree).map(([k, v], idx) => { From 4cc621bc68dd7ab2c192d12fdaf3576933051cd1 Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Mon, 19 Feb 2024 21:43:44 +0400 Subject: [PATCH 14/23] update profile links across the app --- apps/potlock/widget/Components/DonorsCard.jsx | 2 +- apps/potlock/widget/Components/DonorsLeaderboard.jsx | 2 +- apps/potlock/widget/Components/DonorsTrx.jsx | 4 ++-- apps/potlock/widget/Profile/FollowTabs.jsx | 2 +- apps/potlock/widget/Profile/Preview.jsx | 2 +- apps/potlock/widget/Project/FollowStats.jsx | 7 ++++++- apps/potlock/widget/Project/Team.jsx | 2 +- 7 files changed, 13 insertions(+), 8 deletions(-) diff --git a/apps/potlock/widget/Components/DonorsCard.jsx b/apps/potlock/widget/Components/DonorsCard.jsx index 3953b922..1b212f0f 100644 --- a/apps/potlock/widget/Components/DonorsCard.jsx +++ b/apps/potlock/widget/Components/DonorsCard.jsx @@ -79,7 +79,7 @@ return ( }} />{" "} diff --git a/apps/potlock/widget/Components/DonorsLeaderboard.jsx b/apps/potlock/widget/Components/DonorsLeaderboard.jsx index bf6d2b74..75f930c3 100644 --- a/apps/potlock/widget/Components/DonorsLeaderboard.jsx +++ b/apps/potlock/widget/Components/DonorsLeaderboard.jsx @@ -109,7 +109,7 @@ return (
    #{idx + 1 + page * perPage}
    diff --git a/apps/potlock/widget/Components/DonorsTrx.jsx b/apps/potlock/widget/Components/DonorsTrx.jsx index d2371ac8..a88ebafb 100644 --- a/apps/potlock/widget/Components/DonorsTrx.jsx +++ b/apps/potlock/widget/Components/DonorsTrx.jsx @@ -107,7 +107,7 @@ return ( accountId: donor_id, children: ( @@ -129,7 +129,7 @@ return ( accountId: recipient_id, children: ( diff --git a/apps/potlock/widget/Profile/FollowTabs.jsx b/apps/potlock/widget/Profile/FollowTabs.jsx index abbca3a5..55329c7d 100644 --- a/apps/potlock/widget/Profile/FollowTabs.jsx +++ b/apps/potlock/widget/Profile/FollowTabs.jsx @@ -33,7 +33,7 @@ const Nav = styled.div` margin: 0 -12px; `; -const profileLink = `/${ownerId}/widget/Index?tab=profile&accountId=${accountId}`; +const profileLink = props.hrefWithEnv(`?tab=profile&accountId=${accountId}`); return ( diff --git a/apps/potlock/widget/Profile/Preview.jsx b/apps/potlock/widget/Profile/Preview.jsx index 3298ce6e..f71d03fd 100644 --- a/apps/potlock/widget/Profile/Preview.jsx +++ b/apps/potlock/widget/Profile/Preview.jsx @@ -8,7 +8,7 @@ const image = profile.image; return (
    diff --git a/apps/potlock/widget/Project/Team.jsx b/apps/potlock/widget/Project/Team.jsx index 499d2730..135f4279 100644 --- a/apps/potlock/widget/Project/Team.jsx +++ b/apps/potlock/widget/Project/Team.jsx @@ -120,7 +120,7 @@ return ( if (teamMember.match(/.near/i).length > 0) { return ( Date: Mon, 19 Feb 2024 21:53:00 +0400 Subject: [PATCH 15/23] fix pagination --- apps/potlock/widget/Profile/DonationsTable.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/potlock/widget/Profile/DonationsTable.jsx b/apps/potlock/widget/Profile/DonationsTable.jsx index c6240f4c..35fc6b50 100644 --- a/apps/potlock/widget/Profile/DonationsTable.jsx +++ b/apps/potlock/widget/Profile/DonationsTable.jsx @@ -318,7 +318,7 @@ return ( onClick: (page) => { setPage(page); setTotalDonation(donations.slice(page * perPage, (page + 1) * perPage)); - sortDonations(); + setFilteredDonations(donations.slice(page * perPage, (page + 1) * perPage)); }, data: donations, page: page, From 8120a1674b4313927f1c333389259a066071ceca Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Mon, 19 Feb 2024 21:58:07 +0400 Subject: [PATCH 16/23] logs cleanup --- apps/potlock/widget/Components/DonorsTrx.jsx | 71 +++++++++----------- apps/potlock/widget/Profile/Feed.jsx | 1 - 2 files changed, 32 insertions(+), 40 deletions(-) diff --git a/apps/potlock/widget/Components/DonorsTrx.jsx b/apps/potlock/widget/Components/DonorsTrx.jsx index a88ebafb..8a484834 100644 --- a/apps/potlock/widget/Components/DonorsTrx.jsx +++ b/apps/potlock/widget/Components/DonorsTrx.jsx @@ -1,9 +1,6 @@ const { ownerId, donations } = props; -const showDonor = props.showDonor !== undefined ? props.showDonor : true; -const showProject = props.showProject !== undefined ? props.showProject : true; const [page, setPage] = useState(0); const perPage = 30; // need to be less than 50 -console.log(donations); const nearLogo = "https://ipfs.near.social/ipfs/bafkreib2cfbayerbbnoya6z4qcywnizqrbkzt5lbqe32whm2lubw3sywr4"; @@ -87,9 +84,9 @@ return (
    ID
    - {showDonor &&
    Donor ID
    } +
    Donor ID
    Amount
    - {showProject &&
    Project ID
    } +
    Project ID
    Date
    {reverseArr(donations) @@ -100,45 +97,41 @@ return ( return (
    {id}
    - {showDonor && ( - - {_address(donor_id)}{" "} -
    - ), - }} - /> - )} + + {_address(donor_id)}{" "} + + ), + }} + />
    {calcNetDonationAmount(donation).toFixed(2)} NEAR
    - {showProject && ( - - {_address(recipient_id)} - - ), - }} - /> - )} + + {_address(recipient_id)} + + ), + }} + />
    {getTimePassed(donated_at_ms)} ago
    ); diff --git a/apps/potlock/widget/Profile/Feed.jsx b/apps/potlock/widget/Profile/Feed.jsx index 075795a6..cadf07b5 100644 --- a/apps/potlock/widget/Profile/Feed.jsx +++ b/apps/potlock/widget/Profile/Feed.jsx @@ -1,4 +1,3 @@ -console.log(accounts); return ( Date: Mon, 19 Feb 2024 22:34:58 +0400 Subject: [PATCH 17/23] fix multiple renders on donations table --- apps/potlock/widget/Profile/Detail.jsx | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/apps/potlock/widget/Profile/Detail.jsx b/apps/potlock/widget/Profile/Detail.jsx index cc535e33..ed6bdcf6 100644 --- a/apps/potlock/widget/Profile/Detail.jsx +++ b/apps/potlock/widget/Profile/Detail.jsx @@ -14,9 +14,8 @@ if (!accountId) { const [pots, setPots] = useState(null); const [directDonations, setDirectDonation] = useState(null); -const [sponsorship, setSponsorship] = useState([]); +const [sponsorship, setSponsorship] = useState({}); const [potDonations, setPotDonations] = useState([]); -const [isComplete, setISComplete] = useState(false); const getPotConfig = (potId) => Near.asyncView(potId, "get_config", {}); @@ -29,12 +28,13 @@ const getSponsorships = (potId, potDetail) => { pot_name: potDetail.pot_name, pot_id: potId, })); - if (updatedDonations.length) { - setSponsorship((sponsorship) => [...sponsorship, ...updatedDonations]); - if (potId === pots[pots.length - 1].id) setISComplete(true); - } + if (sponsorship[potId]) return ""; + setSponsorship((sponsorship) => { + return { ...sponsorship, [potId]: updatedDonations }; + }); }); }; + // Get Direct Donations if (!directDonations) { Near.asyncView(DONATION_CONTRACT_ID, "get_donations_for_donor", { @@ -46,7 +46,8 @@ if (!pots) { Near.asyncView(POT_FACTORY_CONTRACT_ID, "get_pots", {}).then((pots) => { setPots(pots || []); }); -} else if (pots.length && !isComplete) { +} +if (pots.length && !sponsorship[pots[pots.length - 1].id]) { pots.forEach((pot) => { getPotConfig(pot.id).then((potDetail) => { getSponsorships(pot.id, potDetail); @@ -54,8 +55,12 @@ if (!pots) { }); } -const allDonations = [...(directDonations || []), ...sponsorship]; -allDonations.sort((a, b) => b.donated_at - a.donated_at); +const allDonations = useMemo(() => { + const sponsorshipsValue = Object.values(sponsorship).flat(); + const allDonations = [...(directDonations || []), ...sponsorshipsValue]; + allDonations.sort((a, b) => b.donated_at - a.donated_at); + return allDonations; +}, [sponsorship, directDonations]); props.donations = allDonations; From 9a4c54cc7832f7c0edbe6c21109fb0e9427d808e Mon Sep 17 00:00:00 2001 From: Lachlan Glen <54282009+lachlanglen@users.noreply.github.com> Date: Mon, 19 Feb 2024 16:51:15 -0500 Subject: [PATCH 18/23] use getTagsFromSocialProfileData in Profile.Tags --- apps/potlock/widget/Profile/Tags.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/potlock/widget/Profile/Tags.jsx b/apps/potlock/widget/Profile/Tags.jsx index 7f3d77e5..59a9e004 100644 --- a/apps/potlock/widget/Profile/Tags.jsx +++ b/apps/potlock/widget/Profile/Tags.jsx @@ -1,4 +1,4 @@ -const { profile } = props; +const { profile, getTagsFromSocialProfileData } = props; const Tags = styled.div` display: flex; @@ -14,8 +14,8 @@ const Tag = styled.span` color: #2e2e2e; `; -const tags = Object.keys(profile.tags ?? {}); -if (!tags || tags.length === 0) return "No tags"; +const tags = getTagsFromSocialProfileData(profile); +if (!tags.length) return "No tags"; return ( From 0320779a3e6005e03d1ddd06a42d2e67de756f2f Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Tue, 20 Feb 2024 08:41:23 +0400 Subject: [PATCH 19/23] move profile nav options to a seprate file --- apps/potlock/widget/Profile/Detail.jsx | 2 +- apps/potlock/widget/Profile/Options.jsx | 32 +++++++++++++++++++++++++ apps/potlock/widget/Project/Options.jsx | 30 ----------------------- 3 files changed, 33 insertions(+), 31 deletions(-) create mode 100644 apps/potlock/widget/Profile/Options.jsx diff --git a/apps/potlock/widget/Profile/Detail.jsx b/apps/potlock/widget/Profile/Detail.jsx index ed6bdcf6..5e12b6aa 100644 --- a/apps/potlock/widget/Profile/Detail.jsx +++ b/apps/potlock/widget/Profile/Detail.jsx @@ -6,7 +6,7 @@ const { } = props; const accountId = props.accountId ?? context.accountId; -const { ProfileOptions } = VM.require(`${ownerId}/widget/Project.Options`); +const { ProfileOptions } = VM.require(`${ownerId}/widget/Profile.Options`); if (!accountId) { return "No account ID"; diff --git a/apps/potlock/widget/Profile/Options.jsx b/apps/potlock/widget/Profile/Options.jsx new file mode 100644 index 00000000..888b4edd --- /dev/null +++ b/apps/potlock/widget/Profile/Options.jsx @@ -0,0 +1,32 @@ +const ProfileOptions = (props) => [ + { + label: "Social Feed", + id: "feed", + disabled: false, + source: `${props.ownerId}/widget/Profile.Feed`, + href: props.hrefWithEnv(`?tab=profile&accountId=${props.accountId}&nav=feed`), + }, + { + label: "Donations", + id: "donations", + disabled: false, + source: `${props.ownerId}/widget/Profile.DonationsTable`, + href: props.hrefWithEnv(`?tab=profile&accountId=${props.accountId}&nav=donations`), + }, + { + label: "", + id: "followers", + disabled: false, + source: `${props.ownerId}/widget/Profile.FollowTabs`, + }, + { + label: "", + id: "following", + disabled: false, + source: `${props.ownerId}/widget/Profile.FollowTabs`, + }, +]; + +return { + ProfileOptions, +}; diff --git a/apps/potlock/widget/Project/Options.jsx b/apps/potlock/widget/Project/Options.jsx index bcae5a8a..f837d5f4 100644 --- a/apps/potlock/widget/Project/Options.jsx +++ b/apps/potlock/widget/Project/Options.jsx @@ -49,36 +49,6 @@ const ProjectOptions = (props) => [ }, ]; -const ProfileOptions = (props) => [ - { - label: "Social Feed", - id: "feed", - disabled: false, - source: `${props.ownerId}/widget/Profile.Feed`, - href: props.hrefWithEnv(`?tab=profile&accountId=${props.accountId}&nav=feed`), - }, - { - label: "Donations", - id: "donations", - disabled: false, - source: `${props.ownerId}/widget/Profile.DonationsTable`, - href: props.hrefWithEnv(`?tab=profile&accountId=${props.accountId}&nav=donations`), - }, - { - label: "", - id: "followers", - disabled: false, - source: `${props.ownerId}/widget/Profile.FollowTabs`, - }, - { - label: "", - id: "following", - disabled: false, - source: `${props.ownerId}/widget/Profile.FollowTabs`, - }, -]; - return { ProjectOptions, - ProfileOptions, }; From 315fc356be5bccefae3ee1be4207792ac4b38102 Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Tue, 20 Feb 2024 09:40:53 +0400 Subject: [PATCH 20/23] fix after review --- apps/potlock/widget/Profile/Body.jsx | 71 ++++++++++++++ apps/potlock/widget/Profile/BodyHeader.jsx | 7 +- apps/potlock/widget/Profile/Detail.jsx | 38 ++++---- .../potlock/widget/Profile/DonationsTable.jsx | 18 ++-- apps/potlock/widget/Project/Card.jsx | 18 ++-- apps/potlock/widget/Project/Detail.jsx | 93 ++----------------- apps/potlock/widget/Project/ProjectBanner.jsx | 14 +++ 7 files changed, 138 insertions(+), 121 deletions(-) diff --git a/apps/potlock/widget/Profile/Body.jsx b/apps/potlock/widget/Profile/Body.jsx index 9117679c..7fa55134 100644 --- a/apps/potlock/widget/Profile/Body.jsx +++ b/apps/potlock/widget/Profile/Body.jsx @@ -9,6 +9,23 @@ const { const accountId = props.accountId ?? context.accountId; +const [statusReview, setStatusReview] = useState({ modalOpen: false, notes: "", newStatus: "" }); + +const handleUpdateStatus = () => { + Near.call([ + { + contractName: REGISTRY_CONTRACT_ID, + methodName: "admin_set_project_status", + args: { + project_id: projectId, + status: statusReview.newStatus, + review_notes: statusReview.notes, + }, + deposit: NEAR.toIndivisible(0.01).toString(), + }, + ]); +}; + const Wrapper = styled.div` display: flex; flex-direction: column; @@ -56,6 +73,21 @@ const SidebarContainer = styled.div` } `; +const ModalTitle = styled.div` + color: #525252; + font-size: 16px; + font-weight: 600; + line-height: 20px; + word-wrap: break-word; + margin-bottom: 8px; +`; + +const Row = styled.div` + display: flex; + flex-direction: row; + align-items: center; +`; + return ( + setStatusReview({ ...statusReview, modalOpen: false }), + children: ( + <> + Enter Notes for changing status to {statusReview.newStatus} + setStatusReview({ ...statusReview, notes }), + validate: () => { + // none necessary + }, + }} + /> + + + + + ), + }} + /> ); diff --git a/apps/potlock/widget/Profile/BodyHeader.jsx b/apps/potlock/widget/Profile/BodyHeader.jsx index 5c8adf2b..af83d1b5 100644 --- a/apps/potlock/widget/Profile/BodyHeader.jsx +++ b/apps/potlock/widget/Profile/BodyHeader.jsx @@ -96,6 +96,11 @@ const isOwner = props.projectId === context.accountId; const isPermissionedMember = isDao && userHasPermissions; const canEdit = isOwner || isPermissionedMember; +const projectLink = `https://near.social/potlock.near/widget/Index?tab=project&projectId=${projectId}${ + context.accountId && `&referrerId=${context.accountId}` +}`; +const profileLink = `https://near.social/potlock.near/widget/Index?tab=profile&accountId=${accountId}`; + return (
    @@ -117,7 +122,7 @@ return ( diff --git a/apps/potlock/widget/Profile/Detail.jsx b/apps/potlock/widget/Profile/Detail.jsx index 5e12b6aa..f0a691f8 100644 --- a/apps/potlock/widget/Profile/Detail.jsx +++ b/apps/potlock/widget/Profile/Detail.jsx @@ -13,13 +13,14 @@ if (!accountId) { } const [pots, setPots] = useState(null); -const [directDonations, setDirectDonation] = useState(null); -const [sponsorship, setSponsorship] = useState({}); +const [directDonations, setDirectDonations] = useState(null); +// mapping of pot IDs to array of sponsorship (matching pool) donations to this pot for this user +const [sponsorshipDonations, setSponsorshipDonations] = useState({}); const [potDonations, setPotDonations] = useState([]); const getPotConfig = (potId) => Near.asyncView(potId, "get_config", {}); -const getSponsorships = (potId, potDetail) => { +const getSponsorshipDonations = (potId, potDetail) => { return Near.asyncView(potId, "get_matching_pool_donations", {}).then((donations) => { donations = donations.filter((donations) => donations.donor_id === accountId); const updatedDonations = donations.map((donation) => ({ @@ -28,9 +29,9 @@ const getSponsorships = (potId, potDetail) => { pot_name: potDetail.pot_name, pot_id: potId, })); - if (sponsorship[potId]) return ""; - setSponsorship((sponsorship) => { - return { ...sponsorship, [potId]: updatedDonations }; + if (sponsorshipDonations[potId]) return ""; + setSponsorshipDonations((prevSponsorshipDonations) => { + return { ...prevSponsorshipDonations, [potId]: updatedDonations }; }); }); }; @@ -39,35 +40,31 @@ const getSponsorships = (potId, potDetail) => { if (!directDonations) { Near.asyncView(DONATION_CONTRACT_ID, "get_donations_for_donor", { donor_id: accountId, - }).then((donations) => setDirectDonation(donations)); + }).then((donations) => setDirectDonations(donations)); } -// Get Sponsorships +// Get Sponsorship Donations if (!pots) { Near.asyncView(POT_FACTORY_CONTRACT_ID, "get_pots", {}).then((pots) => { setPots(pots || []); }); } -if (pots.length && !sponsorship[pots[pots.length - 1].id]) { +if (pots.length && !sponsorshipDonations[pots[pots.length - 1].id]) { pots.forEach((pot) => { getPotConfig(pot.id).then((potDetail) => { - getSponsorships(pot.id, potDetail); + getSponsorshipDonations(pot.id, potDetail); }); }); } const allDonations = useMemo(() => { - const sponsorshipsValue = Object.values(sponsorship).flat(); - const allDonations = [...(directDonations || []), ...sponsorshipsValue]; + const sponsorshipDonationsValue = Object.values(sponsorshipDonations).flat(); + const allDonations = [...(directDonations || []), ...sponsorshipDonationsValue]; allDonations.sort((a, b) => b.donated_at - a.donated_at); return allDonations; -}, [sponsorship, directDonations]); - -props.donations = allDonations; +}, [sponsorshipDonations, directDonations]); const profile = props.profile ?? Social.getr(`${accountId}/profile`); -const fast = !props.profile; - if (profile === null) { return "Loading"; } @@ -77,10 +74,6 @@ const Wrapper = styled.div` flex-direction: column; `; -props.navOptions = ProfileOptions(props); - -if (!props.nav) props.nav = "feed"; - return ( diff --git a/apps/potlock/widget/Profile/DonationsTable.jsx b/apps/potlock/widget/Profile/DonationsTable.jsx index 35fc6b50..77f62701 100644 --- a/apps/potlock/widget/Profile/DonationsTable.jsx +++ b/apps/potlock/widget/Profile/DonationsTable.jsx @@ -9,9 +9,7 @@ const perPage = 30; // need to be less than 50 const nearLogo = "https://ipfs.near.social/ipfs/bafkreicdcpxua47eddhzjplmrs23mdjt63czowfsa2jnw4krkt532pa2ha"; -const { getTimePassed, _address, calcNetDonationAmount, reverseArr } = VM.require( - `${ownerId}/widget/Components.DonorsUtils` -); +const { _address } = VM.require(`${ownerId}/widget/Components.DonorsUtils`); const Container = styled.div` display: flex; @@ -152,15 +150,19 @@ const Search = styled.div` } `; -let total = Big(0); -donations.forEach((donation) => { - total = total.plus(Big(donation.total_amount)); -}); +const total = useMemo(() => { + let total = Big(0); + donations.forEach((donation) => { + total = total.plus(Big(donation.total_amount)); + }); + return total; +}, [donations]); + const totalDonationAmount = SUPPORTED_FTS["NEAR"].fromIndivisible(total.toString()); const stats = [{ label: "Donated", amount: (totalDonationAmount * nearToUsd).toFixed(2) }]; -useMemo(() => { +useEffect(() => { setTotalDonation(donations); setFilteredDonations(donations); }, [donations]); diff --git a/apps/potlock/widget/Project/Card.jsx b/apps/potlock/widget/Project/Card.jsx index 17eccadf..ae46c66e 100644 --- a/apps/potlock/widget/Project/Card.jsx +++ b/apps/potlock/widget/Project/Card.jsx @@ -263,6 +263,8 @@ const profileImageStyle = { pointerEvents: "none", }; +const tags = getTagsFromSocialProfileData(profile); + return ( @@ -322,13 +324,15 @@ return ( ? description.slice(0, MAX_DESCRIPTION_LENGTH) + "..." : description} - {" "} + {!tags.length ? ( + "No tags" + ) : ( + + {tags.map((tag, tagIndex) => ( + {tag} + ))} + + )} diff --git a/apps/potlock/widget/Project/Detail.jsx b/apps/potlock/widget/Project/Detail.jsx index 6b49c5f3..28d036a5 100644 --- a/apps/potlock/widget/Project/Detail.jsx +++ b/apps/potlock/widget/Project/Detail.jsx @@ -5,6 +5,7 @@ const { REGISTRY_CONTRACT_ID, tab, POT_FACTORY_CONTRACT_ID, + DONATION_CONTRACT_ID, } = props; const { ProjectOptions } = VM.require(`${ownerId}/widget/Project.Options`); @@ -18,109 +19,33 @@ if (project == undefined) { return "Project not found"; } // Fetch Project Donations -const donations = Near.view("donate.potlock.near", "get_donations_for_recipient", { - recipient_id: projectId, -}); - -props.donations = donations; -props.navOptions = ProjectOptions(props); - -if (!props.nav) props.nav = "home"; // default to home tab +// const donations = Near.view(DONATION_CONTRACT_ID, "get_donations_for_recipient", { +// recipient_id: projectId, +// }); const profile = Social.getr(`${projectId}/profile`); if (profile === null) { return "Loading"; } -const [statusReview, setStatusReview] = useState({ modalOpen: false, notes: "", newStatus: "" }); - -const projectLink = `https://near.social/potlock.near/widget/Index?tab=project&projectId=${ - props.projectId -}${context.accountId && `&referrerId=${context.accountId}`}`; - -const handleUpdateStatus = () => { - Near.call([ - { - contractName: REGISTRY_CONTRACT_ID, - methodName: "admin_set_project_status", - args: { - project_id: props.projectId, - status: statusReview.newStatus, - review_notes: statusReview.notes, - }, - deposit: NEAR.toIndivisible(0.01).toString(), - }, - ]); -}; - const Wrapper = styled.div` margin-top: calc(-1 * var(--body-top-padding, 0)); `; -const ModalTitle = styled.div` - color: #525252; - font-size: 16px; - font-weight: 600; - line-height: 20px; - word-wrap: break-word; - margin-bottom: 8px; -`; - -const Row = styled.div` - display: flex; - flex-direction: row; - align-items: center; -`; return ( + {project.status !== "Approved" && ( + + )} - - setStatusReview({ ...statusReview, modalOpen: false }), - children: ( - <> - Enter Notes for changing status to {statusReview.newStatus} - setStatusReview({ ...statusReview, notes }), - validate: () => { - // none necessary - }, - }} - /> - - - - - ), + nav: props.nav ?? "home", + navOptions: ProjectOptions(props), }} /> diff --git a/apps/potlock/widget/Project/ProjectBanner.jsx b/apps/potlock/widget/Project/ProjectBanner.jsx index cb7187b4..35408080 100644 --- a/apps/potlock/widget/Project/ProjectBanner.jsx +++ b/apps/potlock/widget/Project/ProjectBanner.jsx @@ -1,3 +1,5 @@ +const { project } = props; + const Banner = styled.div` width: 100%; background: ${project.status === "Pending" ? "#E6B800" : "#dd3345"}; @@ -15,7 +17,19 @@ const Row = styled.div` align-items: center; justify-content: center; `; +const BannerText = styled.div` + text-align: center; + color: white; + font-size: 16px; + font-weight: 600; + margin: 0 8px; + word-break: break-all; + @media screen and (max-width: 768px) { + font-size: 12px; + margin-left: 4px; + } +`; const BannerAlertSvg = styled.svg` width: 18px; @media screen and (max-width: 768px) { From 94eb1beed12a6370468f0024535b97ee198937f5 Mon Sep 17 00:00:00 2001 From: Lachlan Glen <54282009+lachlanglen@users.noreply.github.com> Date: Tue, 20 Feb 2024 09:44:18 -0500 Subject: [PATCH 21/23] remove id prop from BodyHeader; require accounts prop in Feed --- apps/potlock/widget/Profile/Body.jsx | 2 +- apps/potlock/widget/Profile/BodyHeader.jsx | 12 ++++++------ apps/potlock/widget/Profile/Feed.jsx | 8 +++----- apps/potlock/widget/Project/Detail.jsx | 1 - 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/apps/potlock/widget/Profile/Body.jsx b/apps/potlock/widget/Profile/Body.jsx index 7fa55134..7144ae39 100644 --- a/apps/potlock/widget/Profile/Body.jsx +++ b/apps/potlock/widget/Profile/Body.jsx @@ -132,7 +132,7 @@ return ( src={`${ownerId}/widget/Profile.BodyHeader`} props={{ ...props, - id: projectId || accountId, + accountId, }} /> {userIsRegistryAdmin && projectId && ( diff --git a/apps/potlock/widget/Profile/BodyHeader.jsx b/apps/potlock/widget/Profile/BodyHeader.jsx index af83d1b5..d8ea794b 100644 --- a/apps/potlock/widget/Profile/BodyHeader.jsx +++ b/apps/potlock/widget/Profile/BodyHeader.jsx @@ -1,4 +1,4 @@ -const { profile, ownerId, accountId, id, projectId } = props; +const { profile, ownerId, accountId, projectId } = props; const Header = styled.div` display: flex; @@ -68,7 +68,7 @@ const ShareIcon = ( /> ); -const policy = Near.view(props.projectId, "get_policy", {}); // TODO: CHANGE BACK TO PROPS.PROJECT ID +const policy = Near.view(props.projectId, "get_policy", {}); const isDao = !!policy; const userHasPermissions = useMemo(() => { @@ -92,7 +92,7 @@ const userHasPermissions = useMemo(() => { return allowed; }, [policy]); -const isOwner = props.projectId === context.accountId; +const isOwner = projectId === context.accountId; const isPermissionedMember = isDao && userHasPermissions; const canEdit = isOwner || isPermissionedMember; @@ -105,20 +105,20 @@ return (
    {profile.name} - {canEdit && projectId && ( + {canEdit && ( )} - @{id} + @{projectId || accountId} + ); diff --git a/apps/potlock/widget/Project/Detail.jsx b/apps/potlock/widget/Project/Detail.jsx index 28d036a5..4f6924ef 100644 --- a/apps/potlock/widget/Project/Detail.jsx +++ b/apps/potlock/widget/Project/Detail.jsx @@ -42,7 +42,6 @@ return ( props={{ ...props, profile, - accounts: [projectId], project, nav: props.nav ?? "home", navOptions: ProjectOptions(props), From acb2f53ee6fb9ba5043889353408e44c8d41a0e5 Mon Sep 17 00:00:00 2001 From: Lachlan Glen <54282009+lachlanglen@users.noreply.github.com> Date: Tue, 20 Feb 2024 10:18:36 -0500 Subject: [PATCH 22/23] use updated ModalDonation on project page, remove deprecated modal --- .../Components/DEPRECATED/ModalDonation.jsx | 838 ------------------ apps/potlock/widget/Index.jsx | 4 +- apps/potlock/widget/Project/Actions.jsx | 21 +- apps/potlock/widget/Project/ModalDonation.jsx | 2 +- 4 files changed, 17 insertions(+), 848 deletions(-) delete mode 100644 apps/potlock/widget/Components/DEPRECATED/ModalDonation.jsx diff --git a/apps/potlock/widget/Components/DEPRECATED/ModalDonation.jsx b/apps/potlock/widget/Components/DEPRECATED/ModalDonation.jsx deleted file mode 100644 index 926025ca..00000000 --- a/apps/potlock/widget/Components/DEPRECATED/ModalDonation.jsx +++ /dev/null @@ -1,838 +0,0 @@ -const { - ownerId, - setAmount, - setProjectId, - setNote, - setReferrerId, - setCurrency, - DONATION_CONTRACT_ID, -} = props; -const [amount, setAmounts] = useState("1"); -const [isBreakDown, setIsBreakDown] = useState(true); -const [msg, setMsg] = useState(""); -const [note, setNotes] = useState(""); -const [isNote, setIsNote] = useState(false); -const [action, setAction] = useState([]); -const isReferrerId = props.referrerId; -const [onSelect, setOnSelect] = useState("near"); - -const MIN_REQUIRED_DONATION_AMOUNT_PER_PROJECT = 0.1; -const cardData = Social.getr(`${props.projectId}/profile`); - -// State.init({ -// isModalDonationOpen: false, -// isModalDonationSucessOpen: false, -// }); - -const getBalance = () => { - const res = fetch(`https://api.nearblocks.io/v1/account/${context.accountId}`); - - if (!(res && res.body)) return "..."; - - const native_balance = res.body.account[0].amount / 1e24; - const unspendable_balance = 0.05 + res.body.account[0].storage_usage / 1e5; - const spendable_balance = native_balance - unspendable_balance; - return spendable_balance.toFixed(4); -}; - -const getInputValidation = () => { - if (onSelect == "near") { - if (Number(amount) > getBalance()) { - return "1px solid var(--Neutral-200,#ff1232)"; - } else { - return "1px solid var(--Neutral-200, #dbdbdb)"; - } - } else { - if (Number(amount) > Number(getBalance()) * Number(getPriceUSD())) { - return "1px solid var(--Neutral-200,#ff1232)"; - } else { - return "1px solid var(--Neutral-200, #dbdbdb)"; - } - } -}; - -const ModalDonate = ({ isOpen, onClose, children }) => { - if (!isOpen) return ""; - return ( - - e.stopPropagation()}>{children} - - ); -}; - -const getPriceUSD = () => { - //https://api.nearblocks.io/v1/stats - const res = fetch(`https://api.nearblocks.io/v1/stats`, { mode: "cors" }); - return res.body.stats[0].near_price; -}; - -const handleChangeBreakDown = () => { - setIsBreakDown(() => !isBreakDown); -}; - -const Modal = styled.div` - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; - background: rgba(0, 0, 0, 0.1); - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - padding-top: ${0.8 + 50}px; - padding-right: 32px; - // padding-right: 500px; - z-index: 1000; - - @media screen and (max-width: 768px) { - padding-right: 8px; - } -`; - -const ModalContainer = styled.div` - width: 500px; - padding: 24px 0px; - background: white; - border-radius: 10px; - box-shadow: 20px 20px 32px -4px rgba(93, 93, 93, 0.06); - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - position: relative; - max-height: 90vh; - max-width: 90vw; - z-index: 1000; -`; - -const ModalHeader = styled.div` - width: 100%; - height: 100%; - padding: 10px 0px; - padding-right: 20px; - background: #fafafa; - border-radius: 6px; - justify-content: center; - align-items: flex-start; - gap: 173px; - display: inline-flex; -`; - -const CloseHeader = styled.div` - width: 24px; - height: 24px; - position: absolute; - top: 10px; - right: 10px; -`; - -const CloseButton = styled.div` - width: 14px; - height: 14px; - font-size: 25px; - font-weight: 300; - color: rgba(112, 107, 107, 0.8); - cursor: pointer; -`; - -const ModalHeaderText = styled.div` - text-align: center; - color: #292929; - font-size: 20px; - font-family: Mona Sans; - font-weight: 600; - line-height: 24px; - word-wrap: break-word; -`; - -const ModalBody = styled.div` - width: 100%; - height: 100%; - padding: 20px 20px; - flex-direction: column; - justify-content: flex-start; - align-items: flex-start; - gap: 24px; - display: inline-flex; -`; - -const ContentMedia = styled.div` - display: flex; - align-items: center; - gap: 16px; - align-self: stretch; -`; - -const Icon = styled.img` - width: 20px; - height: 20px; - margin-top: -5px; -`; - -const ContentMediaImage = styled.img` - width: 24px; - height: 24px; - border-radius: 24px; -`; -const ContentMediaText = styled.div` - display: flex; - flex-direction: column; - align-items: flex-start; - flex: 1 0 0; -`; - -const TextDecMedia = styled.div` - color: var(--Neutral-950, #292929); - font-feature-settings: "ss01" on, "salt" on; - - /* Title/small/14px:semibold */ - font-family: "Mona Sans"; - font-size: 18px; - font-style: normal; - font-weight: 600; - line-height: 24px; /* 171.429% */ -`; - -const TextDesMedia = styled.div` - display: -webkit-box; - -webkit-box-orient: vertical; - -webkit-line-clamp: 1; - align-self: stretch; - overflow: hidden; - color: var(--Neutral-500, #7b7b7b); - font-feature-settings: "ss01" on, "salt" on; - text-overflow: ellipsis; - - /* Body/Medium/14px:regular */ - font-family: "Mona Sans"; - font-size: 18px; - font-style: normal; - font-weight: 400; - line-height: 24px; /* 171.429% */ -`; - -const FormAmountHeader = styled.div` - display: flex; - align-items: baseline; - align-self: stretch; - margin-bottom: -20px; -`; - -const LabelAmount = styled.label` - color: var(--Neutral-950, #292929); - font-feature-settings: "ss01" on, "salt" on; - - /* Label/Large/14px:Medium */ - font-family: "Mona Sans"; - font-size: 18px; - font-style: normal; - font-weight: 500; -`; - -const FormInputAmount = styled.div` - display: flex; - flex-direction: row; - align-items: flex-start; - align-self: stretch; - border: ${getInputValidation()}; - border-radius: 6px; -`; - -const CboxSelect = styled.select` - display: flex; - padding: 10px 16px; - justify-content: center; - align-items: center; - gap: 10px; - border-radius: 25px; - border: none; - width: 100px; - background: #fff; - outline: none; -`; -const CboxSelectOption = styled.option` - color: var(--Neutral-950, #292929); - font-feature-settings: "salt" on; - font-family: "Mona Sans"; - font-size: 14px; - font-style: normal; - font-weight: 400; - line-height: 24px; /* 171.429% */ -`; -const FormInput = styled.div` - display: flex; - align-items: center; - align-self: stretch; - border-radius: 6px; - border-left: 1px solid var(--Neutral-200, #dbdbdb); - background: #fff; - width: 100%; - height: 100%; - outline: none; -`; -const AmountInput = styled.input` - flex: 1 0 0; - color: var(--Neutral-500, #7b7b7b); - text-align: left; - font-feature-settings: "ss01" on, "salt" on, "liga" off; - - /* Label/Large/14px:regular */ - font-family: "Mona Sans"; - font-size: 18px; - font-style: normal; - font-weight: 400; - line-height: 20px; /* 142.857% */ - border: none; - padding: 5px 10px; - width: 100%; - outline: none; -`; - -const NoteInput = styled.input` - margin-top: 20px; - margin-left: 10px; - flex: 1 0 0; - color: var(--Neutral-500, ${note.length > 150 ? "#ff1232" : "#7b7b7b"}); - text-align: left; - font-feature-settings: "ss01" on, "salt" on, "liga" off; - font-family: "Mona Sans"; - font-size: 18px; - font-style: normal; - font-weight: 400; - line-height: 20px; /* 142.857% */ - border: 1px solid var(--Neutral-200, ${note.length > 150 ? "#ff1232" : "#dbdbdb"}); - border-radius: 6px; - padding: 5px 10px; - width: 100%; - outline: none; -`; -const FormSubNumer = styled.div` - display: flex; - justify-content: flex-end; - align-items: flex-end; - align-self: stretch; -`; -const SubNumber = styled.span` - margin-top: -15px; - color: var(--Neutral-500, #7b7b7b); - font-feature-settings: "ss01" on, "salt" on; - /* Label/Medium/11px:regular */ - font-family: "Mona Sans"; - font-size: 13px; - font-style: normal; - font-weight: 400; - line-height: 16px; /* 145.455% */ -`; - -const SubTitleBalance = styled.div` - display: flex; - justify-content: space-between; - align-items: flex-start; - align-self: stretch; - margin-top: -10px; -`; - -const LabelPrice = styled.label` - color: var(--Neutral-500, #7b7b7b); - text-align: right; - font-feature-settings: "ss01" on, "salt" on; - /* Label/Medium/11px:regular */ - font-family: "Mona Sans"; - font-size: 16px; - font-style: normal; - font-weight: 400; - line-height: 16px; /* 145.455% */ -`; - -const LabelBalance = styled.label` - color: var(--Neutral-500, #7b7b7b); - text-align: right; - font-feature-settings: "ss01" on, "salt" on; - - /* Label/Medium/11px:regular */ - font-family: "Mona Sans"; - font-size: 16px; - font-style: normal; - font-weight: 400; - line-height: 16px; /* 145.455% */ -`; - -const BreakDownContainer = styled.div` - display: flex; - flex-direction: column; - align-items: flex-start; - gap: 8px; - align-self: stretch; -`; - -const BreakDownButton = styled.button` - display: flex; - padding: 10px 0px; - justify-content: flex-end; - align-items: flex-end; - gap: 8px; - align-self: stretch; - outline: none; - background: none; - border: none; -`; - -const TextBreakDown = styled.div` - color: var(--Neutral-950, #292929); - text-align: right; - font-feature-settings: "ss01" on, "salt" on; - - /* Label/Large/14px:Medium */ - font-family: "Mona Sans"; - font-size: 14px; - font-style: normal; - font-weight: 500; - line-height: 20px; /* 142.857% */ -`; - -const IconBreakDown = styled.img` - width: 18px; - height: 18px; -`; - -const ContentBreakDown = styled.div` - display: flex; - padding: 16px; - flex-direction: column; - align-items: flex-start; - gap: 12px; - align-self: stretch; - border-radius: 8px; - border: 1px solid var(--Neutral-100, #f0f0f0); - background: var(--Colors-Grey-SystemWhite, #fff); -`; - -const FormContentBreakDown = styled.div` - display: flex; - height: 22px; - align-items: center; - gap: 16px; - align-self: stretch; -`; - -const TextFormBreakDown = styled.div` - color: var(--Neutral-500, #7b7b7b); - font-feature-settings: "ss01" on, "salt" on, "liga" off; - - /* Label/Large/14px:regular */ - font-family: "Mona Sans"; - font-size: 14px; - font-style: normal; - font-weight: 400; - line-height: 20px; /* 142.857% */ -`; - -const AmountBreakDown = styled.div` - display: flex; - justify-content: flex-end; - align-items: center; - gap: 8px; - flex: 1 0 0; -`; - -const IconNearBreakDown = styled.img` - width: 20px; - height: 20px; - border-radius: 20px; - filter: grayscale(120%); -`; -const TextNote = styled.div` - width: 100%; - height: 1px; - display: flex; - border-top: 1px solid var(--Neutral-200, #dbdbdb); - padding-top: 40px; - justify-content: flex-start; - align-items: flex-start; - gap: 8px; -`; -const IconNear = styled.img` - width: 18px; - height: 18px; - border-radius: 28px; - filter: grayscale(120%); - margin-top: -5px; -`; -const FtIconNear = styled.img` - width: 22px; - height: 22px; - border-radius: 28px; - filter: grayscale(120%); -`; -const ButtonNote = styled.button` - color: var(--Neutral-950, #292929); - font-feature-settings: "ss01" on, "salt" on; - - /* Label/Large/14px:Medium */ - font-family: "Mona Sans"; - font-size: 18px; - font-style: normal; - font-weight: 500; - line-height: 20px; /* 142.857% */ - outline: none; - background: none; - border: none; - margin-left: 10px; -`; - -const FooterModal = styled.div` - display: flex; - justify-content: flex-end; - align-items: center; - gap: 16px; - align-self: stretch; -`; - -const DonateButton = styled.button` - display: flex; - padding: 12px 16px; - justify-content: center; - align-items: center; - gap: 8px; - border-radius: 6px; - background: var(--Primary-600, #dd3345); - - /* Button/main shadow */ - box-shadow: 0px -2px 0px 0px #464646 inset, 0px 0px 0px 1px #464646; - outline: none; - border: none; - color: #fff; - &:hover { - background: #fef6ee; - color: #000000; - } -`; -const AddToCartButton = styled.button` - border: none; - background: none; - color: #dd3345; - text-decoration: none; - &:hover { - text-decoration: underline; - } - padding: 12px 16px; -`; - -const TitleMsg = styled.span` - color: red; -`; - -const changeSelect = (e) => { - setOnSelect(e.target.value); -}; - -const onChangeAmount = (e) => { - const amount = e.target.value; - amount = amount.replace(/[^\d,.]/g, ""); // remove all non-numeric characters except for decimal - if (amount === ".") amount = "0."; - onSelect == "near" - ? Number(amount) > getBalance() - ? setMsg("The amount of money in your account is not enough.") - : setMsg("") - : Number(amount) > Number(getBalance()) * Number(getPriceUSD()) - ? setMsg("The amount of money in your account is not enough.") - : setMsg(""); - setAmounts(amount); -}; - -const projectAllocation = () => { - const amount = Number(amount); - const ref = isReferrerId == undefined ? 0.95 : 0.925; - return (amount * ref).toFixed(3); -}; - -const protocalFees = () => { - const amount = Number(amount); - return (amount * 0.05).toFixed(3); -}; - -const referrerFees = () => { - const amount = Number(amount); - if (isReferrerId) { - return (amount * 0.25).toFixed(3); - } -}; -// console.log(props); -const handleDonate = () => { - setAmount(amount); - setProjectId(props.projectId); - setNote(note); - setReferrerId(props.referrerId); - setCurrency(onSelect); - if (Number(amount) > 0) { - const transactions = []; - const amountFloat = onSelect == "near" ? amount : Number(amount).toFixed(3); - const amountIndivisible = new Big(parseFloat(amountFloat)).mul(new Big(10).pow(24)); - const donateContractArgs = {}; - donateContractArgs.recipient_id = props.projectId; - donateContractArgs.referrer_id = props.referrerId; - if (note) { - donateContractArgs.message = note; - } - transactions.push({ - contractName: DONATION_CONTRACT_ID, - methodName: "donate", - args: donateContractArgs, - deposit: amountIndivisible.toString(), - }); - Near.call(transactions); - } -}; - -return ( - <> - State.update({ isModalDonationOpen: false }) - } - > - - Donate to project - - { - state.isModalDonationOpen == true - ? State.update({ isModalDonationOpen: false }) - : props.onClose(); - }} - > - X - - - - - - - - {cardData.name} - {cardData.description} - - - - Amount - - - { - setOnSelect(value); - }, - inputStyles: { - border: "none", - borderRight: "1px #F0F0F0 solid", - boxShadow: "none", - borderRadius: "4px 0px 0px 4px", - width: "auto", - padding: "12px 16px", - boxShadow: "0px -2px 0px rgba(93, 93, 93, 0.24) inset", - }, - iconLeft: - onSelect == "near" ? ( - - ) : ( - "$" - ), - }} - /> - - onChangeAmount(e)} - autoFocus={isNote ? false : true} - /> - - - - 1 NEAR = ${Number(getPriceUSD()).toFixed(2)} - {onSelect == "near" ? ( - - Account balance: {getBalance().toString()} - - - ) : ( - - Account balance: {(Number(getBalance()) * Number(getPriceUSD())).toFixed(2)} $ - - )} - - {msg} - - - {!isBreakDown ? "Hide breakdown" : "Show breakdown"} - {isBreakDown ? ( - - ) : ( - - )} - - {!isBreakDown && ( - - - - Project allocation ({isReferrerId == undefined ? "95%" : "92.5%"}) - - - {projectAllocation()} - {onSelect == "near" ? ( - - ) : ( - "$" - )} - - - - Protocol fees (5%) - - {protocalFees()} - {onSelect == "near" ? ( - - ) : ( - "$" - )} - - - - - Referral fees ({isReferrerId == undefined ? "0%" : "2.5%"}) - - - {referrerFees()} - {onSelect == "near" ? ( - - ) : ( - "$" - )} - - - - )} - - - setIsNote(true)}> - - Add Note - - - {isNote && ( - setNotes(e.target.value)} - autoFocus - /> - )} - {isNote && ( - - {note.length}/150 - - )} - - { - e.preventDefault(); - if (existsInCart) { - props.removeProjectsFromCart([props.projectId]); - } else { - props.addProjectsToCart([ - { - id: props.projectId, - amount: amount, - ft: onSelect == "near" ? "NEAR" : "USD", - price: getPriceUSD(), - note: note, - referrerId: props.referrerId, - }, - ]); - if (props.showModal) { - props.onClose(); - props.setIsCartModalOpen(true); - } - } - }} - > - Add to cart - - Donate - - - - State.update({ isModalDonationOpen: false }), - onOpen: () => State.update({ isModalDonationOpen: true }), - onDonation: { - priceNear: Number(getPriceUSD()).toFixed(2), - }, - }} - /> - -); diff --git a/apps/potlock/widget/Index.jsx b/apps/potlock/widget/Index.jsx index 4d5d0e63..56334f30 100644 --- a/apps/potlock/widget/Index.jsx +++ b/apps/potlock/widget/Index.jsx @@ -80,7 +80,9 @@ State.init({ potDetail: null, }, donationSuccessModal: { - isOpen: (!props.tab || props.tab === PROJECTS_LIST_TAB) && props.transactionHashes, + isOpen: + (!props.tab || props.tab === PROJECTS_LIST_TAB || props.tab === PROJECT_DETAIL_TAB) && + props.transactionHashes, successfulDonation: null, }, }); diff --git a/apps/potlock/widget/Project/Actions.jsx b/apps/potlock/widget/Project/Actions.jsx index 45267942..0af59552 100644 --- a/apps/potlock/widget/Project/Actions.jsx +++ b/apps/potlock/widget/Project/Actions.jsx @@ -1,7 +1,12 @@ const [isModalDonationOpen, setIsModalDonationOpen] = useState(false); const [isModalDonationSucessOpen, setIsModalDonationSucessOpen] = useState(false); -const { ownerId } = props; +const { ownerId, registeredProjects, projectId } = props; + +const projectIsApproved = useMemo(() => { + return registeredProjects.some((p) => p.id === projectId && p.status === "Approved"); +}, [registeredProjects, projectId]); + const Container = styled.div` display: flex; flex-direction: row; @@ -91,7 +96,7 @@ return ( /> - {props.tab === "project" && ( + {props.tab === "project" && projectIsApproved && ( { @@ -102,15 +107,15 @@ return ( Donate setIsModalDonationOpen(false), + recipientId: props.projectId, + referrerId: props.referrerId, + openDonateToProjectModal: () => setIsModalDonationOpen(true), + // potId: state.donateToProjectModal.potId, // TODO: add this in if project is in a pot? }} /> diff --git a/apps/potlock/widget/Project/ModalDonation.jsx b/apps/potlock/widget/Project/ModalDonation.jsx index 3af3ca2b..f442d712 100644 --- a/apps/potlock/widget/Project/ModalDonation.jsx +++ b/apps/potlock/widget/Project/ModalDonation.jsx @@ -1,7 +1,7 @@ const { ownerId, registeredProjects, - recipientId, + recipientId, // TODO: change this to projectId referrerId, potId, potDetail, From 93b2f1c657c94706daf9f1a31499ea40ab68adf3 Mon Sep 17 00:00:00 2001 From: Lachlan Glen <54282009+lachlanglen@users.noreply.github.com> Date: Tue, 20 Feb 2024 10:19:37 -0500 Subject: [PATCH 23/23] remove console logs --- apps/potlock/widget/Pots/Applications.jsx | 2 +- apps/potlock/widget/Project/ButtonDonateRandomly.jsx | 1 - apps/potlock/widget/Project/CreateForm.jsx | 2 -- apps/potlock/widget/Project/ModalDonation.jsx | 1 - 4 files changed, 1 insertion(+), 5 deletions(-) diff --git a/apps/potlock/widget/Pots/Applications.jsx b/apps/potlock/widget/Pots/Applications.jsx index 01d9e352..15466e74 100644 --- a/apps/potlock/widget/Pots/Applications.jsx +++ b/apps/potlock/widget/Pots/Applications.jsx @@ -207,7 +207,7 @@ return ( ) : ( state.filteredApplications.map((application, index) => { const { project_id, message, status, submitted_at, review_notes } = application; - console.log("status: ", status); + // console.log("status: ", status); return ( { - console.log("openDonationSuccessModal", donation); State.update({ isModalOpen: false, successfulDonation: donation, diff --git a/apps/potlock/widget/Project/CreateForm.jsx b/apps/potlock/widget/Project/CreateForm.jsx index 6802097c..87d92caf 100644 --- a/apps/potlock/widget/Project/CreateForm.jsx +++ b/apps/potlock/widget/Project/CreateForm.jsx @@ -1607,8 +1607,6 @@ return ( }, handleAddAccount: handleAddTeamMember, handleRemoveAccount: (accountId) => { - console.log("accountId: ", accountId); - console.log("state.teamMembers: ", state.teamMembers); State.update({ teamMembers: state.teamMembers.filter((tm) => tm != accountId), }); diff --git a/apps/potlock/widget/Project/ModalDonation.jsx b/apps/potlock/widget/Project/ModalDonation.jsx index f442d712..c7b4fc42 100644 --- a/apps/potlock/widget/Project/ModalDonation.jsx +++ b/apps/potlock/widget/Project/ModalDonation.jsx @@ -287,7 +287,6 @@ const handleDonate = () => { gas: "300000000000000", }, ]; - console.log("transactions: ", transactions); const now = Date.now(); Near.call(transactions);