Skip to content

Commit

Permalink
Merge pull request #124 from NEARBuilders/profile-page
Browse files Browse the repository at this point in the history
Profile page
  • Loading branch information
elliotBraem authored Feb 2, 2024
2 parents e21b0ba + 16a34e3 commit 06a5c33
Show file tree
Hide file tree
Showing 72 changed files with 1,563 additions and 487 deletions.
22 changes: 12 additions & 10 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
title: ""
labels: bug
assignees: ''

assignees: ""
---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand All @@ -24,15 +24,17 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
title: ""
labels: enhancement
assignees: ''

assignees: ""
---

**Is your feature request related to a problem? Please describe.**
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
with:
deploy-env: "mainnet"
app-name: "builddao"
deploy-account-address: ${{ vars.BOS_SIGNER_ACCOUNT_ID }}
deploy-account-address: ${{ vars.BOS_SIGNER_ACCOUNT_ID }}
signer-account-address: ${{ vars.BOS_SIGNER_ACCOUNT_ID }}
signer-public-key: ${{ vars.BOS_SIGNER_PUBLIC_KEY }}
secrets:
SIGNER_PRIVATE_KEY: ${{ secrets.BOS_SIGNER_PRIVATE_KEY }}
secrets:
SIGNER_PRIVATE_KEY: ${{ secrets.BOS_SIGNER_PRIVATE_KEY }}
6 changes: 3 additions & 3 deletions .github/workflows/testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
with:
deploy-env: "testnet"
app-name: "builddao"
deploy-account-address: ${{ vars.BOS_TESTNET_SIGNER_ACCOUNT_ID }}
deploy-account-address: ${{ vars.BOS_TESTNET_SIGNER_ACCOUNT_ID }}
signer-account-address: ${{ vars.BOS_TESTNET_SIGNER_ACCOUNT_ID }}
signer-public-key: ${{ vars.BOS_TESTNET_SIGNER_PUBLIC_KEY }}
secrets:
SIGNER_PRIVATE_KEY: ${{ secrets.BOS_TESTNET_SIGNER_PRIVATE_KEY }}
secrets:
SIGNER_PRIVATE_KEY: ${{ secrets.BOS_TESTNET_SIGNER_PRIVATE_KEY }}
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ Let's connect, collaborate, and create solutions together!
## Setup & Development

Install packages:

```
yarn
```

Start development version:

```
yarn dev
```
Expand All @@ -20,17 +22,16 @@ To view your local developments, either visit them through a gateway ${gateway_u

For example, to use this local gateway, use:

* Set the flag (something like http://127.0.0.1:4040/api/loader) at localhost:3000/flags

- Set the flag (something like http://127.0.0.1:4040/api/loader) at localhost:3000/flags

### Community Page

[View Default](https://nearbuilders.org/build.sputnik-dao.near/widget/community)

#### Features

* Customizable Settings
* Onboarding Flow
* Leaderboard
* Groups
* Projects
- Customizable Settings
- Onboarding Flow
- Leaderboard
- Groups
- Projects
2 changes: 1 addition & 1 deletion apps/builddao/bos.config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"appAccount": "buildhub.near"
}
}
20 changes: 9 additions & 11 deletions apps/builddao/widget/Compose.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ const [postContent, setPostContent] = useState("");
const [hideAdvanced, setHideAdvanced] = useState(true);
const [labels, setLabels] = useState([]);

setPostContent(draft || props.template);
const [composeKey, setComposeKey] = useState(0);
const memoizedComposeKey = useMemo(() => composeKey, [composeKey]);

function generateUID() {
const maxHex = 0xffffffff;
const randomNumber = Math.floor(Math.random() * maxHex);
return randomNumber.toString(16).padStart(8, "0");
}

setPostContent(draft || props.template);

function tagsFromLabels(labels) {
return labels.reduce(
(newLabels, label) => ({
Expand Down Expand Up @@ -85,15 +88,9 @@ function checkAndAppendHashtag(input, target) {
}
}

const postToCustomFeed = ({ feed, text, labels }) => {
// if (!labels) labels = [];

// labels = labels.map((label) => label.toLowerCase());
// labels.push(feed.name.toLowerCase());

const postToCustomFeed = ({ feed, text }) => {
const requiredHashtags = props.requiredHashtags || ["build"];
if (feed.hashtag) requiredHashtags.push(feed.hashtag.toLowerCase());
requiredHashtags.push(feed.name.toLowerCase());
text = text + `\n\n`;
requiredHashtags.forEach((hashtag) => {
text = checkAndAppendHashtag(text, hashtag);
Expand Down Expand Up @@ -156,7 +153,8 @@ const postToCustomFeed = ({ feed, text, labels }) => {
onCommit: () => {
setPostContent("");
Storage.privateSet(draftKey, props.template || "");
setHandler("autocompleteSelected"); // this is a hack to force the iframe to update
// setHandler("autocompleteSelected"); // this is a hack to force the iframe to update
setComposeKey(generateUID());
},
onCancel: () => {
// console.log(`Cancelled ${feed}: #${postId}`);
Expand Down Expand Up @@ -260,7 +258,7 @@ const MarkdownEditor = `
}
.drop-wrap {
top: -110px !important;
border-radius: 0.5rem !important;
}
Expand Down Expand Up @@ -385,7 +383,7 @@ return (
<TextareaWrapper
className="markdown-editor"
data-value={postContent || ""}
key={props.feed.name || "Editor"}
key={memoizedComposeKey}
>
<Widget
src="mob.near/widget/MarkdownEditorIframe"
Expand Down
25 changes: 13 additions & 12 deletions apps/builddao/widget/Profile.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
if (!context.accountId || !props.accountId) {
if (!(props.accountId ?? context.accountId)) {
return "No Account ID";
}

const accountId = props.accountId || context.accountId;
const accountId = props.accountId ?? context.accountId;

const profile = Social.getr(`${accountId}/profile`);
if (!profile) {
Expand All @@ -13,6 +13,11 @@ const ProfileContainer = styled.div`
display: grid;
grid-template-columns: repeat(6, minmax(0, 1fr));
gap: 1rem;
@media screen and (max-width: 768px) {
display: flex;
flex-direction: column;
}
`;

const SideContainer = styled.div`
Expand All @@ -32,17 +37,13 @@ return (
/>
</SideContainer>
<MainContainer>
<button
onClick={() => {
Social.set({
profile: {
location: "Multan, Pakistan",
},
});
<Widget
src="buildhub.near/widget/components.profile.ProfileTabs"
props={{
accountId,
profile,
}}
>
test
</button>
/>
</MainContainer>
</ProfileContainer>
);
55 changes: 28 additions & 27 deletions apps/builddao/widget/Proposals.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const { Button } = VM.require("buildhub.near/widget/components.Button") || {
Button: <></>
Button: <></>,
};
const DaoSDK = VM.require("sdks.near/widget/SDKs.Sputnik.DaoSDK");
const DaoSDK = VM.require("sdks.near/widget/SDKs.Sputnik.DaoSDK") || (() => {});

if (!DaoSDK) {
return <></>;
}

const resPerPage = 10;
const daoId = props.daoId ?? "build.sputnik-dao.near";
const proposalId = props.proposalId ?? null;
Expand All @@ -18,8 +19,8 @@ const lastProposalId = sdk.getLastProposalId();
const reversedProposals = proposalId
? [
sdk.getProposalById({
proposalId
})
proposalId,
}),
] || []
: sdk.getProposals({
offset:
Expand All @@ -28,7 +29,7 @@ const reversedProposals = proposalId
? lastProposalId - resPerPage
: lastProposalId ?? 10
: lastProposalId - currentPage * resPerPage,
limit: resPerPage
limit: resPerPage,
}) || [];

const proposals = reversedProposals.reverse();
Expand Down Expand Up @@ -81,15 +82,15 @@ const handleVote = ({ action, proposalId, proposer }) => {
message: `${accountId} voted to ${customAction} your proposal for ${daoId} (Proposal ID: ${proposalId})`,
params: {
daoId: daoId,
proposalId: proposalId
proposalId: proposalId,
},
type: "custom",
widget: "buildhub.near/widget/Proposals"
}
}
])
}
}
widget: "buildhub.near/widget/Proposals",
},
},
]),
},
},
};

sdk.actProposal({
Expand All @@ -103,9 +104,9 @@ const handleVote = ({ action, proposalId, proposer }) => {
args: { data: notification },
deposit: Big(JSON.stringify(notification).length * 16)
.mul(Big(10).pow(20))
.toString()
}
]
.toString(),
},
],
});
};

Expand Down Expand Up @@ -144,30 +145,30 @@ const proposalsComponent = useMemo(() => {
sdk.hasPermission({
accountId,
kindName,
actionType: actions.VoteApprove
actionType: actions.VoteApprove,
}),
sdk.hasPermission({
accountId,
kindName,
actionType: actions.VoteReject
actionType: actions.VoteReject,
}),

sdk.hasPermission({
accountId,
kindName,
actionType: actions.VoteRemove
})
actionType: actions.VoteRemove,
}),
];

const { thresholdVoteCount } =
sdk.getVotersAndThresholdForProposalKind({
kindName
kindName,
});
const totalVotes = sdk.calculateVoteCountByType({
votes: item.votes
votes: item.votes,
});
let expirationTime = sdk.getProposalExpirationTime({
submissionTime: item.submission_time
submissionTime: item.submission_time,
});

return (
Expand All @@ -181,14 +182,14 @@ const proposalsComponent = useMemo(() => {
totalVotes: {
...totalVotes,
yes: totalVotes.approve,
no: totalVotes.reject
no: totalVotes.reject,
},
expirationTime
expirationTime,
},
daoId: daoId,
comments: comments,
isAllowedToVote,
handleVote
handleVote,
}}
/>
);
Expand All @@ -207,7 +208,7 @@ return (
src="buildhub.near/widget/components.modals.CreateProposal"
props={{
showModal: showProposalModal,
toggleModal: () => setShowModal(!showProposalModal)
toggleModal: () => setShowModal(!showProposalModal),
}}
/>
<div className="d-flex justify-content-between">
Expand All @@ -226,7 +227,7 @@ return (
totalPages: Math.round(lastProposalId / resPerPage),
onPageClick: (v) => setCurrentPage(v),
selectedPage: currentPage,
ThemeContainer: PaginationThemeContainer
ThemeContainer: PaginationThemeContainer,
}}
/>
</div>
Expand Down
Loading

0 comments on commit 06a5c33

Please sign in to comment.