-
-
-
-
-
-
-
+ {!registeredProject ? (
+
Project not found
+ ) : (
+ <>
+
+
-
-
+ >
+ )}
);
diff --git a/build/potlock/src/Index.jsx b/build/potlock/src/Index.jsx
index 56ea1018..437cc797 100644
--- a/build/potlock/src/Index.jsx
+++ b/build/potlock/src/Index.jsx
@@ -1,6 +1,8 @@
const ownerId = "potlock.near";
const CREATE_PROJECT_TAB = "createproject";
+const EDIT_PROJECT_TAB = "editproject";
+const PROJECTS_LIST_TAB = "projects";
const PROJECT_DETAIL_TAB = "project";
const monaSansCss = fetch("https://fonts.cdnfonts.com/css/mona-sans").body;
@@ -22,7 +24,8 @@ State.init({
const tabContentWidget = {
[CREATE_PROJECT_TAB]: "Project.Create",
- projects: "Project.ListPage",
+ [EDIT_PROJECT_TAB]: "Project.Create",
+ [PROJECTS_LIST_TAB]: "Project.ListPage",
[PROJECT_DETAIL_TAB]: "Project.Detail",
};
@@ -42,15 +45,16 @@ const getTabWidget = (tab) => {
return "Project.ListPage";
};
-const tabContent = (
-
-);
+const props = {
+ ...props,
+ urlProps: props,
+};
+
+if (props.tab === EDIT_PROJECT_TAB) {
+ props.edit = true;
+}
+
+const tabContent =
;
const Content = styled.div`
width: 100%;
diff --git a/build/potlock/src/Project/Create.jsx b/build/potlock/src/Project/Create.jsx
index 2a52726e..67df3ff4 100644
--- a/build/potlock/src/Project/Create.jsx
+++ b/build/potlock/src/Project/Create.jsx
@@ -5,15 +5,16 @@ return (
-
+
>
);
diff --git a/build/potlock/src/Project/CreateForm.jsx b/build/potlock/src/Project/CreateForm.jsx
index 26677c30..b9dc3e06 100644
--- a/build/potlock/src/Project/CreateForm.jsx
+++ b/build/potlock/src/Project/CreateForm.jsx
@@ -27,6 +27,8 @@ if (!context.accountId) {
);
}
+const projects = Near.view(registryId, "get_projects", {});
+
const imageHeightPx = 120;
const profileImageTranslateYPx = 220;
@@ -431,20 +433,24 @@ const handleCreateProject = (e) => {
deposit: Big(JSON.stringify(socialArgs).length * 16).mul(Big(10).pow(20)),
args: socialArgs,
},
- // register on NEAR Horizon
- {
- contractName: "nearhorizon.near",
- methodName: "add_project",
- args: horizonArgs,
- },
- // register project on potlock
- {
- contractName: registryId,
- methodName: "register",
- deposit: Big(JSON.stringify(potlockRegistryArgs).length * 16).mul(Big(10).pow(20)), // TODO: update this, it isn't correct
- args: potlockRegistryArgs,
- },
];
+ if (!props.edit) {
+ transactions.push(
+ // register on NEAR Horizon
+ {
+ contractName: "nearhorizon.near",
+ methodName: "add_project",
+ args: horizonArgs,
+ },
+ // register project on potlock
+ {
+ contractName: registryId,
+ methodName: "register",
+ deposit: Big(JSON.stringify(potlockRegistryArgs).length * 16).mul(Big(10).pow(20)), // TODO: update this, it isn't correct
+ args: potlockRegistryArgs,
+ }
+ );
+ }
const res = Near.call(transactions);
};
@@ -533,9 +539,13 @@ const FormSectionLeft = (title, description, isRequired) => {
);
};
+if (props.edit && !registeredProject) {
+ return
Unauthorized
;
+}
+
return (
- {!state.socialDataFetched ? (
+ {!state.socialDataFetched || !projects ? (
) : registeredProject ? (
@@ -792,7 +802,7 @@ return (
props={{
type: "primary",
prefix: "https://",
- text: "Create new project",
+ text: props.edit ? "Update your project" : "Create new project",
disabled: isCreateProjectDisabled,
onClick: handleCreateProject,
}}
diff --git a/build/potlock/src/Project/Detail.jsx b/build/potlock/src/Project/Detail.jsx
index fb4227e1..749996c9 100644
--- a/build/potlock/src/Project/Detail.jsx
+++ b/build/potlock/src/Project/Detail.jsx
@@ -1,11 +1,18 @@
const ownerId = "potlock.near";
+const registryId = "registry.potlock.near";
const profile = props.profile ?? Social.getr(`${props.projectId}/profile`);
-if (profile === null) {
+const projects = props.projects ?? Near.view(registryId, "get_projects", {});
+
+if (!profile || !projects) {
return "Loading";
}
+const registeredProject = projects.find(
+ (project) => project.id == props.projectId && project.status == "Approved"
+);
+
const name = profile.name || "No-name profile";
const image = profile.image;
const backgroundImage = profile.backgroundImage;
@@ -20,54 +27,60 @@ const profileImageTranslateYPx = 220;
return (
-
-
-
-
-
-
-
-
-
+ {!registeredProject ? (
+
Project not found
+ ) : (
+ <>
+
+
-
-
+ >
+ )}
);