From 97a222b44d8680a64920ca4f2beefa4141d4770a Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Mon, 13 May 2024 06:14:21 +0400 Subject: [PATCH 1/3] update repositories section in create form --- .../components/CreateForm/CreateForm.tsx | 41 +++++++++++++------ .../CreateProject/utils/getSocialData.ts | 2 +- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/pages/CreateProject/components/CreateForm/CreateForm.tsx b/src/pages/CreateProject/components/CreateForm/CreateForm.tsx index 3f839ce8..3f2765ae 100644 --- a/src/pages/CreateProject/components/CreateForm/CreateForm.tsx +++ b/src/pages/CreateProject/components/CreateForm/CreateForm.tsx @@ -593,12 +593,11 @@ const CreateForm = (props: { edit: boolean }) => { Add funding source -
- - - {Array(4) - .fill("") - .map((_, index: number) => ( + {state.categories.includes("Open Source") && ( +
+ + + {Object.values(state.githubRepos).map((repo: any, index: number) => ( github.com/, @@ -607,7 +606,7 @@ const CreateForm = (props: { edit: boolean }) => { borderRadius: "0px 4px 4px 0px", transform: "translateX(-1px)", }, - value: state.githubRepos[index].value, + value: repo.value, onChange: (value) => State.update({ githubRepos: { @@ -619,8 +618,6 @@ const CreateForm = (props: { edit: boolean }) => { }), validate: () => { // validate link - const repo = state.githubRepos[index]; - const repoObj = extractRepoPath(repo.value); State.update({ githubRepos: { @@ -629,12 +626,32 @@ const CreateForm = (props: { edit: boolean }) => { }, }); }, - error: state.githubRepos[index].err || "", + error: repo.err || "", }} /> ))} - -
+
+ +
+ )}
diff --git a/src/pages/CreateProject/utils/getSocialData.ts b/src/pages/CreateProject/utils/getSocialData.ts index ad1e4ceb..979490ea 100644 --- a/src/pages/CreateProject/utils/getSocialData.ts +++ b/src/pages/CreateProject/utils/getSocialData.ts @@ -26,7 +26,7 @@ const getSocialData = () => { plSmartContracts: formattedSmartContracts ? JSON.stringify(formattedSmartContracts) : null, plGithubRepos: JSON.stringify( Object.values(state.githubRepos) - .map(({ value, err }: any) => (err ? false : "github.com/" + value)) + .map(({ value, err }: any) => (err || !value ? false : "github.com/" + value)) .filter((val: any) => val), ), plFundingSources: JSON.stringify(state.fundingSources), From d71b85a16bb4f574eb480312aef59dd06940b902 Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Mon, 13 May 2024 06:53:49 +0400 Subject: [PATCH 2/3] allow only named accounts to register --- .../components/CreateForm/CreateForm.tsx | 17 +++++++++++++---- src/pages/CreateProject/utils/fields.ts | 2 ++ src/pages/CreateProject/utils/helpers.ts | 9 +++++++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/pages/CreateProject/components/CreateForm/CreateForm.tsx b/src/pages/CreateProject/components/CreateForm/CreateForm.tsx index 3f2765ae..9ed25af3 100644 --- a/src/pages/CreateProject/components/CreateForm/CreateForm.tsx +++ b/src/pages/CreateProject/components/CreateForm/CreateForm.tsx @@ -13,11 +13,10 @@ import ModalMultiAccount from "@app/components/ModalMultiAccount/ModalMultiAccou import routesPath from "@app/routes/routesPath"; import doesUserHaveDaoFunctionCallProposalPermissions from "@app/utils/doesUserHaveDaoFunctionCallProposalPermissions"; import validateEVMAddress from "@app/utils/validateEVMAddress"; -import validateGithubRepoUrl from "@app/utils/validateGithubRepoUrl"; import validateNearAddress from "@app/utils/validateNearAddress"; import { socialFields, CATEGORY_MAPPINGS, CHAIN_OPTIONS, DEFAULT_STATE } from "../../utils/fields"; import handleCreateOrUpdateProject from "../../utils/handleCreateOrUpdateProject"; -import { extractRepoPath, projectDisabled } from "../../utils/helpers"; +import { extractRepoPath, isNamedAccount, projectDisabled } from "../../utils/helpers"; import setSocialData from "../../utils/setSocialData"; import AccountsStack from "../AccountsStack/AccountsStack"; import DAOInProgress from "../DAOInProgress/DAOInProgress"; @@ -180,6 +179,7 @@ const CreateForm = (props: { edit: boolean }) => { + {/* PROJECT DETAILS */}
@@ -209,7 +209,7 @@ const CreateForm = (props: { edit: boolean }) => { State.update({ daoAddressTemp: daoAddress.toLowerCase(), daoAddressError: "" }), @@ -269,7 +269,11 @@ const CreateForm = (props: { edit: boolean }) => { } State.update({ daoAddressError: "" }); }, - error: state.isDao ? state.daoAddressError : "", + error: state.isDao + ? state.daoAddressError + : !isNamedAccount(projectId) + ? "Require a name account for proejct registration" + : "", }} /> @@ -357,6 +361,7 @@ const CreateForm = (props: { edit: boolean }) => { />
+ {/* SMART CONTRACT */}
{state.smartContracts.map(([chain, contractAddress]: [string, string], index: number) => { @@ -480,6 +485,7 @@ const CreateForm = (props: { edit: boolean }) => { Add more contract
+ {/* FUNDING SOURCE */}
{state.fundingSources.length > 0 && ( @@ -593,6 +599,7 @@ const CreateForm = (props: { edit: boolean }) => { Add funding source
+ {/* REPOSITIORIES */} {state.categories.includes("Open Source") && (
@@ -652,6 +659,8 @@ const CreateForm = (props: { edit: boolean }) => {
)} + {/* SOCIAL LINKS */} +
diff --git a/src/pages/CreateProject/utils/fields.ts b/src/pages/CreateProject/utils/fields.ts index 3536e3f6..6722ce78 100644 --- a/src/pages/CreateProject/utils/fields.ts +++ b/src/pages/CreateProject/utils/fields.ts @@ -1,3 +1,5 @@ +export const addressNamed = [".tg", ".sweat", ".near"]; + export const socialFields = [ { label: "twitter", diff --git a/src/pages/CreateProject/utils/helpers.ts b/src/pages/CreateProject/utils/helpers.ts index 4c350dc8..12971d11 100644 --- a/src/pages/CreateProject/utils/helpers.ts +++ b/src/pages/CreateProject/utils/helpers.ts @@ -1,5 +1,9 @@ -import { asyncFetch, state } from "alem"; -import { CATEGORY_MAPPINGS } from "./fields"; +import { asyncFetch, context, state } from "alem"; +import { CATEGORY_MAPPINGS, addressNamed } from "./fields"; + +export function isNamedAccount(accountId: string) { + return addressNamed.some((substring) => accountId.includes(substring)); +} export const deepObjectDiff = (objOriginal: any, objUpdated: any) => { if (!objUpdated) objUpdated = {}; @@ -41,6 +45,7 @@ export const uploadFileUpdateState = (body: any, callback: any) => { }; export const projectDisabled = () => + (!state.isDao && !isNamedAccount(context.accountId || "")) || !state.profileImage || !state.backgroundImage || state.daoAddressError || From a4261cbc9cc9a5bb9a5700c424aee3414fbc2730 Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Mon, 13 May 2024 07:19:41 +0400 Subject: [PATCH 3/3] show full pot_description in card --- src/components/PotCard/PotCard.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/PotCard/PotCard.tsx b/src/components/PotCard/PotCard.tsx index 76c7ad2f..789e19dc 100644 --- a/src/components/PotCard/PotCard.tsx +++ b/src/components/PotCard/PotCard.tsx @@ -38,7 +38,7 @@ const PotCard = ({ potId }: Props) => { const description = !pot_description ? "No description" : pot_description.length > MAX_DESCRIPTION_LENGTH - ? `${pot_description.slice(0, MAX_DESCRIPTION_LENGTH)}...` + ? `${pot_description.slice(0, MAX_DESCRIPTION_LENGTH).trim()}...` : pot_description; const title = !pot_name @@ -61,7 +61,7 @@ const PotCard = ({ potId }: Props) => { {title} - +