diff --git a/apps/potlock/widget/Index.jsx b/apps/potlock/widget/Index.jsx index 5fa198fe..79d4aac3 100644 --- a/apps/potlock/widget/Index.jsx +++ b/apps/potlock/widget/Index.jsx @@ -1,4 +1,5 @@ const ownerId = "potlock.near"; +const registryContractId = "registry.potlock.near"; const CREATE_PROJECT_TAB = "createproject"; const EDIT_PROJECT_TAB = "editproject"; @@ -46,6 +47,7 @@ State.init({ cart: null, nearToUsd: null, isCartModalOpen: false, + registryAdmins: null, }); if (state.nearToUsd === null) { @@ -54,6 +56,11 @@ if (state.nearToUsd === null) { State.update({ nearToUsd: res.body.near.usd }); } +if (state.registryAdmins === null) { + const registryAdmins = Near.view(registryContractId, "get_admins", {}); + State.update({ registryAdmins }); +} + const tabContentWidget = { [CREATE_PROJECT_TAB]: "Project.Create", [EDIT_PROJECT_TAB]: "Project.Create", diff --git a/apps/potlock/widget/Project/Card.jsx b/apps/potlock/widget/Project/Card.jsx index ca3b5878..d937f015 100644 --- a/apps/potlock/widget/Project/Card.jsx +++ b/apps/potlock/widget/Project/Card.jsx @@ -1,5 +1,6 @@ const ownerId = "potlock.near"; const donationContractId = "donation.tests.potlock.near"; // TODO: update to donate.potlock.near after testing +const registryContractId = "registry.potlock.near"; const Card = styled.a` display: flex; @@ -17,29 +18,6 @@ const Card = styled.a` } `; -// const Banner = styled.div` -// position: relative; -// width: 100%; -// height: 168; -// margin-bottom: 30px; -// `; - -// const BannerImage = styled.img` -// width: 100%; -// height: 100%; -// // border-radius: 6px; -// `; - -// const ProfileImage = styled.img` -// width: 40px; -// height: 40px; -// border-radius: 50%; -// border: 3px solid white; -// position: absolute; -// bottom: -20px; -// left: 60px; -// `; - const Info = styled.div` display: flex; flex-direction: column; @@ -116,58 +94,96 @@ const [totalAmount, totalDonors] = useMemo(() => { ]; }, [donationsForProject]); +const PROJECT_STATUSES = [ + "Submitted", + "InReview", + "Approved", + "Rejected", + "Graylisted", + "Blacklisted", +]; + return ( - - - - {name} - - {description.length > MAX_DESCRIPTION_LENGTH - ? description.slice(0, MAX_DESCRIPTION_LENGTH) + "..." - : description} - + <> + + + {name} + + {description.length > MAX_DESCRIPTION_LENGTH + ? description.slice(0, MAX_DESCRIPTION_LENGTH) + "..." + : description} + + + + + + {totalDonors || totalDonors === 0 ? totalDonors : "-"} + {totalDonors === 1 ? "Donor" : "Donors"} + + + ${totalAmount || "-"} + Raised + + + + {props.registryAdmins && props.registryAdmins.includes(context.accountId) && ( + ({ + value: status, + text: status, + })), + value: { text: props.project.status, value: props.project.status }, + onChange: (status) => { + if (status.value != project.status) { + Near.call([ + { + contractName: registryContractId, + methodName: "admin_set_project_status", + args: { project_id: id, status: status.value }, + }, + ]); + } + }, + containerStyles: { + padding: "16px 24px", + }, }} /> - - - - {totalDonors || totalDonors === 0 ? totalDonors : "-"} - {totalDonors === 1 ? "Donor" : "Donors"} - - - ${totalAmount || "-"} - Raised - - - + )} + ); diff --git a/apps/potlock/widget/Project/CreateForm.jsx b/apps/potlock/widget/Project/CreateForm.jsx index 1b650893..72786821 100644 --- a/apps/potlock/widget/Project/CreateForm.jsx +++ b/apps/potlock/widget/Project/CreateForm.jsx @@ -745,17 +745,6 @@ return ( value, text, })), - // options: [ - // Social Impact, NonProfit, Climate, Public Good - // { text: "Social Impact", value: "social-impact" }, - // { text: "NonProfit", value: "non-profit" }, - // { text: "Climate", value: "climate" }, - // { text: "Public Good", value: "public-good" }, - // { text: "DeSci", value: "de-sci" }, - // { text: "Open Source", value: "open-source" }, - // { text: "Community", value: "community" }, - // { text: "Education", value: "education" }, - // ], value: { text: CATEGORY_MAPPINGS[state.category] || "", value: state.category }, onChange: (category) => { State.update({ diff --git a/apps/potlock/widget/Project/ListPage.jsx b/apps/potlock/widget/Project/ListPage.jsx index 26cd95ab..ee17fcdc 100644 --- a/apps/potlock/widget/Project/ListPage.jsx +++ b/apps/potlock/widget/Project/ListPage.jsx @@ -132,6 +132,7 @@ if (!state.registeredProjects) { description: profileData.description ?? "", bannerImageUrl, profileImageUrl, + status: project.status, tags: [profileData.category.text ?? CATEGORY_MAPPINGS[profileData.category] ?? ""], // TODO: change this to get tags from horizon/social }; return formatted; diff --git a/build/potlock/src/Index.jsx b/build/potlock/src/Index.jsx index 5fa198fe..79d4aac3 100644 --- a/build/potlock/src/Index.jsx +++ b/build/potlock/src/Index.jsx @@ -1,4 +1,5 @@ const ownerId = "potlock.near"; +const registryContractId = "registry.potlock.near"; const CREATE_PROJECT_TAB = "createproject"; const EDIT_PROJECT_TAB = "editproject"; @@ -46,6 +47,7 @@ State.init({ cart: null, nearToUsd: null, isCartModalOpen: false, + registryAdmins: null, }); if (state.nearToUsd === null) { @@ -54,6 +56,11 @@ if (state.nearToUsd === null) { State.update({ nearToUsd: res.body.near.usd }); } +if (state.registryAdmins === null) { + const registryAdmins = Near.view(registryContractId, "get_admins", {}); + State.update({ registryAdmins }); +} + const tabContentWidget = { [CREATE_PROJECT_TAB]: "Project.Create", [EDIT_PROJECT_TAB]: "Project.Create", diff --git a/build/potlock/src/Project/Card.jsx b/build/potlock/src/Project/Card.jsx index ca3b5878..d937f015 100644 --- a/build/potlock/src/Project/Card.jsx +++ b/build/potlock/src/Project/Card.jsx @@ -1,5 +1,6 @@ const ownerId = "potlock.near"; const donationContractId = "donation.tests.potlock.near"; // TODO: update to donate.potlock.near after testing +const registryContractId = "registry.potlock.near"; const Card = styled.a` display: flex; @@ -17,29 +18,6 @@ const Card = styled.a` } `; -// const Banner = styled.div` -// position: relative; -// width: 100%; -// height: 168; -// margin-bottom: 30px; -// `; - -// const BannerImage = styled.img` -// width: 100%; -// height: 100%; -// // border-radius: 6px; -// `; - -// const ProfileImage = styled.img` -// width: 40px; -// height: 40px; -// border-radius: 50%; -// border: 3px solid white; -// position: absolute; -// bottom: -20px; -// left: 60px; -// `; - const Info = styled.div` display: flex; flex-direction: column; @@ -116,58 +94,96 @@ const [totalAmount, totalDonors] = useMemo(() => { ]; }, [donationsForProject]); +const PROJECT_STATUSES = [ + "Submitted", + "InReview", + "Approved", + "Rejected", + "Graylisted", + "Blacklisted", +]; + return ( - - - - {name} - - {description.length > MAX_DESCRIPTION_LENGTH - ? description.slice(0, MAX_DESCRIPTION_LENGTH) + "..." - : description} - + <> + + + {name} + + {description.length > MAX_DESCRIPTION_LENGTH + ? description.slice(0, MAX_DESCRIPTION_LENGTH) + "..." + : description} + + + + + + {totalDonors || totalDonors === 0 ? totalDonors : "-"} + {totalDonors === 1 ? "Donor" : "Donors"} + + + ${totalAmount || "-"} + Raised + + + + {props.registryAdmins && props.registryAdmins.includes(context.accountId) && ( + ({ + value: status, + text: status, + })), + value: { text: props.project.status, value: props.project.status }, + onChange: (status) => { + if (status.value != project.status) { + Near.call([ + { + contractName: registryContractId, + methodName: "admin_set_project_status", + args: { project_id: id, status: status.value }, + }, + ]); + } + }, + containerStyles: { + padding: "16px 24px", + }, }} /> - - - - {totalDonors || totalDonors === 0 ? totalDonors : "-"} - {totalDonors === 1 ? "Donor" : "Donors"} - - - ${totalAmount || "-"} - Raised - - - + )} + ); diff --git a/build/potlock/src/Project/CreateForm.jsx b/build/potlock/src/Project/CreateForm.jsx index 1b650893..72786821 100644 --- a/build/potlock/src/Project/CreateForm.jsx +++ b/build/potlock/src/Project/CreateForm.jsx @@ -745,17 +745,6 @@ return ( value, text, })), - // options: [ - // Social Impact, NonProfit, Climate, Public Good - // { text: "Social Impact", value: "social-impact" }, - // { text: "NonProfit", value: "non-profit" }, - // { text: "Climate", value: "climate" }, - // { text: "Public Good", value: "public-good" }, - // { text: "DeSci", value: "de-sci" }, - // { text: "Open Source", value: "open-source" }, - // { text: "Community", value: "community" }, - // { text: "Education", value: "education" }, - // ], value: { text: CATEGORY_MAPPINGS[state.category] || "", value: state.category }, onChange: (category) => { State.update({ diff --git a/build/potlock/src/Project/ListPage.jsx b/build/potlock/src/Project/ListPage.jsx index 26cd95ab..ee17fcdc 100644 --- a/build/potlock/src/Project/ListPage.jsx +++ b/build/potlock/src/Project/ListPage.jsx @@ -132,6 +132,7 @@ if (!state.registeredProjects) { description: profileData.description ?? "", bannerImageUrl, profileImageUrl, + status: project.status, tags: [profileData.category.text ?? CATEGORY_MAPPINGS[profileData.category] ?? ""], // TODO: change this to get tags from horizon/social }; return formatted;