Skip to content

Commit

Permalink
Merge pull request #99 from PotLock/staging
Browse files Browse the repository at this point in the history
Staging => main
  • Loading branch information
M-Rb3 committed May 13, 2024
2 parents f1a98cb + cd0aff4 commit a6eae2c
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/components/PotCard/PotCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -61,7 +61,7 @@ const PotCard = ({ potId }: Props) => {
<CardSection>
<Title>{title}</Title>
<Description>
<Markdown text={description} />
<Markdown text={pot_description} />
</Description>
</CardSection>
<CardSection
Expand Down
58 changes: 42 additions & 16 deletions src/pages/CreateProject/components/CreateForm/CreateForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -180,6 +179,7 @@ const CreateForm = (props: { edit: boolean }) => {
</LowerBannerContainerRight>
</LowerBannerContainer>
<FormBody>
{/* PROJECT DETAILS */}
<Section>
<SubHeader title="Project details" requierd />
<DAOselect>
Expand Down Expand Up @@ -209,7 +209,7 @@ const CreateForm = (props: { edit: boolean }) => {
<Text
{...{
label: state.isDao ? "DAO address *" : "Project ID *",
value: state.isDao ? state.daoAddressTemp : context.accountId,
value: state.isDao ? state.daoAddressTemp : projectId,
disabled: !state.isDao,
onChange: (daoAddress) =>
State.update({ daoAddressTemp: daoAddress.toLowerCase(), daoAddressError: "" }),
Expand Down Expand Up @@ -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"
: "",
}}
/>
</Row>
Expand Down Expand Up @@ -357,6 +361,7 @@ const CreateForm = (props: { edit: boolean }) => {
/>
</Row>
</Section>
{/* SMART CONTRACT */}
<Section>
<SubHeader title="Smart contracts" />
{state.smartContracts.map(([chain, contractAddress]: [string, string], index: number) => {
Expand Down Expand Up @@ -480,6 +485,7 @@ const CreateForm = (props: { edit: boolean }) => {
Add more contract
</Button>
</Section>
{/* FUNDING SOURCE */}
<Section>
<SubHeader title="Funding sources" />
{state.fundingSources.length > 0 && (
Expand Down Expand Up @@ -593,12 +599,12 @@ const CreateForm = (props: { edit: boolean }) => {
<PlusIcon /> Add funding source
</Button>
</Section>
<Section>
<SubHeader title="Repositories" />
<Row>
{Array(4)
.fill("")
.map((_, index: number) => (
{/* REPOSITIORIES */}
{state.categories.includes("Open Source") && (
<Section>
<SubHeader title="Repositories" requierd />
<Row>
{Object.values(state.githubRepos).map((repo: any, index: number) => (
<Text
{...{
preInputChildren: <InputPrefix>github.com/</InputPrefix>,
Expand All @@ -607,7 +613,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: {
Expand All @@ -619,8 +625,6 @@ const CreateForm = (props: { edit: boolean }) => {
}),
validate: () => {
// validate link
const repo = state.githubRepos[index];

const repoObj = extractRepoPath(repo.value);
State.update({
githubRepos: {
Expand All @@ -629,12 +633,34 @@ const CreateForm = (props: { edit: boolean }) => {
},
});
},
error: state.githubRepos[index].err || "",
error: repo.err || "",
}}
/>
))}
</Row>
</Section>
</Row>
<Button
{...{
varient: "plain",
onClick: () => {
State.update({
githubRepos: {
...state.githubRepos,
[Object.keys(state.githubRepos).length]: {
value: "",
err: "",
},
},
});
},
}}
>
<PlusIcon />
Add more repo
</Button>
</Section>
)}
{/* SOCIAL LINKS */}

<Section>
<SubHeader title="Social links" />
<Row>
Expand Down
2 changes: 2 additions & 0 deletions src/pages/CreateProject/utils/fields.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const addressNamed = [".tg", ".sweat", ".near"];

export const socialFields = [
{
label: "twitter",
Expand Down
2 changes: 1 addition & 1 deletion src/pages/CreateProject/utils/getSocialData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
9 changes: 7 additions & 2 deletions src/pages/CreateProject/utils/helpers.ts
Original file line number Diff line number Diff line change
@@ -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 = {};
Expand Down Expand Up @@ -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 ||
Expand Down

0 comments on commit a6eae2c

Please sign in to comment.