From 8fdec4e3927fb767402c56ff2a5303f71ce388e2 Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Fri, 26 Apr 2024 16:53:10 +0400 Subject: [PATCH 01/10] fix pagination --- src/components/Pagination/Pagination.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/Pagination/Pagination.tsx b/src/components/Pagination/Pagination.tsx index 4fbffb19..4d63b4cc 100644 --- a/src/components/Pagination/Pagination.tsx +++ b/src/components/Pagination/Pagination.tsx @@ -1,5 +1,5 @@ +import { useMemo } from "alem"; import { Container } from "./styles"; -import { useMemo } from "react"; type Props = { onPageChange: (page: number) => void; @@ -112,6 +112,7 @@ const Pagination = (props: Props) => { return (
  • onPageChange(pageNumber)} > From c554f0a7ddb4aa44fe5edc598c2555bc7d5f703a Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Mon, 29 Apr 2024 15:58:43 +0400 Subject: [PATCH 02/10] bugs fix --- src/SDK/lists.js | 5 ++ src/components/Hero/Hero.tsx | 8 +-- src/components/mob.near/ProfileImage.tsx | 50 +++++++------------ .../ConfirmDirect/ConfirmDirect.tsx | 9 ++-- .../ModalDonation/ConfirmPot/ConfirmPot.tsx | 8 +-- src/modals/ModalDonation/FormPot/FormPot.tsx | 2 +- src/modals/ModalDonation/index.tsx | 1 + .../components/CreateForm/CreateForm.tsx | 7 ++- .../components/CreateForm/styles.ts | 1 + src/pages/Donor/Donor.tsx | 13 +---- .../DonationsTable/DonationsTable.tsx | 2 +- .../Pot/components/FundModal/FundModal.tsx | 24 ++++----- .../components/BannerHeader/BannerHeader.tsx | 8 +-- .../Profile/components/BannerHeader/styles.ts | 8 +-- .../components/BodyHeader/BodyHeader.tsx | 9 +++- .../Profile/components/BodyHeader/styles.ts | 12 +++++ src/pages/Profile/components/FollowStats.tsx | 3 +- .../Profile/components/Linktree/Linktree.tsx | 1 + src/pages/Profile/components/Tabs.tsx | 5 +- .../DonationsInfo/DonationsInfo.tsx | 2 +- .../components/DonationsInfo/styles.ts | 1 + .../components/FollowButton/FollowButton.tsx | 4 +- .../PotlockFunding/PotlockFunding.tsx | 7 +-- .../components/PotlockFunding/styles.ts | 1 + src/pages/Projects/Projects.tsx | 23 ++++++++- .../components/AllProjects/AllProjects.tsx | 6 +-- .../Projects/components/AllProjects/styles.ts | 3 ++ .../DonationStats/DonationStats.tsx | 6 ++- src/services/getProjects.ts | 4 +- 29 files changed, 127 insertions(+), 106 deletions(-) diff --git a/src/SDK/lists.js b/src/SDK/lists.js index 810fd360..e0a998cb 100644 --- a/src/SDK/lists.js +++ b/src/SDK/lists.js @@ -21,6 +21,11 @@ const ListsSDK = { list_id: listId || potlockRegistryListId, }); }, + asyncGetRegistrations: (listId) => { + return Near.asyncView(_listContractId, "get_registrations_for_list", { + list_id: listId || potlockRegistryListId, + }); + }, getRegistration: (listId, registrantId) => { const registrations = Near.view(_listContractId, "get_registrations_for_registrant", { registrant_id: registrantId, diff --git a/src/components/Hero/Hero.tsx b/src/components/Hero/Hero.tsx index 94f3d6cc..c5020d06 100644 --- a/src/components/Hero/Hero.tsx +++ b/src/components/Hero/Hero.tsx @@ -17,10 +17,10 @@ const Hero = ({ projectsData }: { projectsData: any }) => { const [donateTo, setDonateTo] = useState(""); const getRandomProject = () => { - const allProjects = projectsData.allProjects; - if (allProjects) { - const randomIndex = Math.floor(Math.random() * allProjects.length); - return allProjects[randomIndex]?.registrant_id; + const approvedProjects = projectsData.approvedProjects; + if (approvedProjects) { + const randomIndex = Math.floor(Math.random() * approvedProjects.length); + return approvedProjects[randomIndex]?.registrant_id; } }; diff --git a/src/components/mob.near/ProfileImage.tsx b/src/components/mob.near/ProfileImage.tsx index efdafccd..c489f34e 100644 --- a/src/components/mob.near/ProfileImage.tsx +++ b/src/components/mob.near/ProfileImage.tsx @@ -16,40 +16,26 @@ type Props = { thumbnail?: boolean; tooltip?: boolean; fast?: boolean; + fallbackUrl?: string; }; -const ProfileImage = ({ - profile: _profile, - accountId: _accountId, - style: _style, - imageClassName: _imageClassName, - image: _image, - title: _title, - name: _name, - className: _className, - imageStyle: _imageStyle, - imageWrapperStyle: _imageWrapperStyle, - thumbnail: _thumbnail, - tooltip: _tooltip, - fast: _fast, -}: Props) => { +const ProfileImage = (profileImgProps: Props) => { // * taken from mob.near/widget/ProfileImage with minor tweaks for expanded composability * - - // const { - // profile: _profile, - // accountId: _accountId, - // style: _style, - // imageClassName: _imageClassName, - // image: _image, - // title: _title, - // name: _name, - // className: _className, - // imageStyle: _imageStyle, - // imageWrapperStyle: _imageWrapperStyle, - // thumbnail: _thumbnail, - // tooltip: _tooltip, - // fast: _fast, - // } = props; + const { + profile: _profile, + accountId: _accountId, + style: _style, + imageClassName: _imageClassName, + image: _image, + title: _title, + name: _name, + className: _className, + imageStyle: _imageStyle, + imageWrapperStyle: _imageWrapperStyle, + thumbnail: _thumbnail, + tooltip: _tooltip, + fast: _fast, + } = profileImgProps; const accountId = _accountId ?? context.accountId; const className = _className ?? "profile-image d-inline-block"; @@ -74,7 +60,7 @@ const ProfileImage = ({ accountId, }); } - const fallbackUrl = "https://ipfs.near.social/ipfs/bafkreibmiy4ozblcgv3fm3gc6q62s55em33vconbavfd2ekkuliznaq3zm"; + const fallbackUrl = props.fallbackUrl; const imageProps = { image, diff --git a/src/modals/ModalDonation/ConfirmDirect/ConfirmDirect.tsx b/src/modals/ModalDonation/ConfirmDirect/ConfirmDirect.tsx index d522b902..b0b02450 100644 --- a/src/modals/ModalDonation/ConfirmDirect/ConfirmDirect.tsx +++ b/src/modals/ModalDonation/ConfirmDirect/ConfirmDirect.tsx @@ -10,6 +10,7 @@ import Button from "@app/components/Button"; import NearIcon from "@app/assets/svgs/near-icon"; import BreakdownSummary from "@app/components/Cart/BreakdownSummary/BreakdownSummary"; import TextArea from "@app/components/Inputs/TextArea/TextArea"; +import hrefWithParams from "@app/utils/hrefWithParams"; const ConfirmDirect = ({ selectedDenomination, @@ -298,7 +299,7 @@ const ConfirmDirect = ({
    Remove {protocolFeeBasisPoints / 100 || "-"}% protocol fee
    @@ -318,11 +319,7 @@ const ConfirmDirect = ({ />
    Remove {chefFeeBasisPoints / 100 || "-"}% chef fee
    -
    + {potDetail?.chef} diff --git a/src/modals/ModalDonation/ConfirmPot/ConfirmPot.tsx b/src/modals/ModalDonation/ConfirmPot/ConfirmPot.tsx index a5c44270..67995ef2 100644 --- a/src/modals/ModalDonation/ConfirmPot/ConfirmPot.tsx +++ b/src/modals/ModalDonation/ConfirmPot/ConfirmPot.tsx @@ -235,7 +235,7 @@ const ConfirmPot = ({
    Remove {protocolFeeBasisPoints / 100 || "-"}% protocol fee
    @@ -255,11 +255,7 @@ const ConfirmPot = ({ />
    Remove {chefFeeBasisPoints / 100 || "-"}% chef fee
    -
    + {potDetail?.chef} diff --git a/src/modals/ModalDonation/FormPot/FormPot.tsx b/src/modals/ModalDonation/FormPot/FormPot.tsx index d68cd914..b6e70501 100644 --- a/src/modals/ModalDonation/FormPot/FormPot.tsx +++ b/src/modals/ModalDonation/FormPot/FormPot.tsx @@ -7,6 +7,7 @@ import { CustomButton, Content, CurrentBalance, Form, Label, ProjectAmount, Proj import ProfileImage from "@app/components/mob.near/ProfileImage"; import _address from "@app/utils/_address"; import Button from "@app/components/Button"; +import hrefWithParams from "@app/utils/hrefWithParams"; const FormPot = ({ amount, @@ -16,7 +17,6 @@ const FormPot = ({ selectedDenomination, donationType, ftBalance, - hrefWithParams, selectedProjects, }: any) => { const ProfileImg = ({ profile }: any) => ; diff --git a/src/modals/ModalDonation/index.tsx b/src/modals/ModalDonation/index.tsx index 8c4eba5f..a8707edd 100644 --- a/src/modals/ModalDonation/index.tsx +++ b/src/modals/ModalDonation/index.tsx @@ -213,6 +213,7 @@ const ModalDonation = (donationProps: DonationModalProps) => { { e.stopPropagation(); + onClose(); }} contentStyle={{ padding: "0px" }} > diff --git a/src/pages/CreateProject/components/CreateForm/CreateForm.tsx b/src/pages/CreateProject/components/CreateForm/CreateForm.tsx index 0297db1c..5c4057dd 100644 --- a/src/pages/CreateProject/components/CreateForm/CreateForm.tsx +++ b/src/pages/CreateProject/components/CreateForm/CreateForm.tsx @@ -172,7 +172,9 @@ const CreateForm = (props: { edit: boolean }) => { const userHasPermissions = policy == null ? false - : policy == undefined || doesUserHaveDaoFunctionCallProposalPermissions(context.accountId, policy); + : policy + ? doesUserHaveDaoFunctionCallProposalPermissions(context.accountId, policy) + : projectId === context.accountId; // const userHasPermissions = useMemo(() => { // if (policy == undefined) return true; @@ -201,7 +203,6 @@ const CreateForm = (props: { edit: boolean }) => { const setSocialData = (accountId: string, shouldSetTeamMembers?: any) => { Near.asyncView("social.near", "get", { keys: [`${accountId}/**`] }) .then((socialData) => { - console.log("socialData: ", socialData); if (!socialData || !socialData[accountId].profile) { State.update({ socialDataFetched: true, @@ -311,8 +312,6 @@ const CreateForm = (props: { edit: boolean }) => { } }, [state.socialDataFetched, state.isDao, state.daoAddress, context.accountId]); - console.log("state", state); - const isCreateProjectDisabled = state.daoAddressError || !state.name || diff --git a/src/pages/CreateProject/components/CreateForm/styles.ts b/src/pages/CreateProject/components/CreateForm/styles.ts index 87a7eccb..08e6e8d4 100644 --- a/src/pages/CreateProject/components/CreateForm/styles.ts +++ b/src/pages/CreateProject/components/CreateForm/styles.ts @@ -22,6 +22,7 @@ export const LowerBannerContainer = styled.div` z-index: 10; @media screen and (max-width: 768px) { top: 310px; + position: initial; align-items: flex-start; gap: 10px; flex-direction: column; diff --git a/src/pages/Donor/Donor.tsx b/src/pages/Donor/Donor.tsx index a7d7a4b2..a7c2442e 100644 --- a/src/pages/Donor/Donor.tsx +++ b/src/pages/Donor/Donor.tsx @@ -12,19 +12,10 @@ const DonorPage = () => { return ( ); diff --git a/src/pages/Pot/components/DonationsTable/DonationsTable.tsx b/src/pages/Pot/components/DonationsTable/DonationsTable.tsx index e5d4c5b5..7f6da125 100644 --- a/src/pages/Pot/components/DonationsTable/DonationsTable.tsx +++ b/src/pages/Pot/components/DonationsTable/DonationsTable.tsx @@ -149,7 +149,7 @@ const DonationsTable = (props: any) => { const projectHref = hrefWithParams(`?tab=project&projectId=${projectId}`); const profileHref = hrefWithParams(`?tab=profile&accountId=${donor_id}`); return ( - + {/* Donor */} { // <---- EXTENSION WALLET HANDLING ----> // TODO: implement }; + const disabled = + (fundAsDao && !daoAddress) || + daoAddressError || + !matchingPoolDonationAmountNear || + !!matchingPoolDonationAmountNearError || + !parseFloat(matchingPoolDonationAmountNear); + return ( {