diff --git a/apps/builddao/widget/Compose.jsx b/apps/builddao/widget/Compose.jsx index b39b1353..1676757b 100644 --- a/apps/builddao/widget/Compose.jsx +++ b/apps/builddao/widget/Compose.jsx @@ -5,7 +5,7 @@ const { User, Button } = VM.require("buildhub.near/widget/components") || { const draftKey = props.draftKey || "draft"; const draft = Storage.privateGet(draftKey); - +const postBtnText = props.postBtnText; if (draft === null) { return ""; } @@ -30,7 +30,7 @@ function tagsFromLabels(labels) { return labels.reduce( (newLabels, label) => ({ ...newLabels, - [label]: "", + [label]: "" }), {} ); @@ -76,8 +76,8 @@ const extractMentionNotifications = (text, item) => key: accountId, value: { type: "mention", - item, - }, + item + } })); function checkAndAppendHashtag(input, target) { @@ -113,20 +113,20 @@ const postToCustomFeed = ({ feed, text }) => { post: { main: JSON.stringify({ type: "md", - text, + text // tags: tagsFromLabels(labels), // postType: feed.name, - }), + }) }, index: { - post: JSON.stringify({ key: "main", value: { type: "md" } }), + post: JSON.stringify({ key: "main", value: { type: "md" } }) // every: JSON.stringify({ key: feed.name, value: { type: "md" } }), - }, + } }; const item = { type: "social", - path: `${context.accountId}/post/main`, + path: `${context.accountId}/post/main` }; const notifications = extractMentionNotifications(text, item); @@ -143,7 +143,7 @@ const postToCustomFeed = ({ feed, text }) => { data.index.hashtag = JSON.stringify( hashtags.map((hashtag) => ({ key: hashtag, - value: item, + value: item })) ); } @@ -158,7 +158,7 @@ const postToCustomFeed = ({ feed, text }) => { }, onCancel: () => { // console.log(`Cancelled ${feed}: #${postId}`); - }, + } }); }; @@ -393,7 +393,7 @@ return ( onChange: (v) => { setPostContent(v); Storage.privateSet(draftKey, v || ""); - }, + } }} /> @@ -430,11 +430,11 @@ return ( postToCustomFeed({ feed: props.feed, text: postContent, - labels, + labels }) } > - Post {props.feed.name} + {postBtnText ?? "Post" + props.feed.name} diff --git a/apps/builddao/widget/Feed.jsx b/apps/builddao/widget/Feed.jsx index 7b0308b6..18246bd1 100644 --- a/apps/builddao/widget/Feed.jsx +++ b/apps/builddao/widget/Feed.jsx @@ -1,10 +1,31 @@ const { Feed } = VM.require("devs.near/widget/Feed") || { - Feed: () => <>, + Feed: () => <> }; const { Post } = VM.require("buildhub.near/widget/components") || { - Post: () => <>, + Post: () => <> }; +const { Button } = VM.require("buildhub.near/widget/components") || { + Button: () => <> +}; + +const LoginContainer = styled.div` + background-color: #23242b; + color: #fff; + + width: 100%; + height: 16rem; + border-radius: 1rem; + + display: flex; + flex-direction: column; + gap: 0.5rem; + align-items: center; + justify-content: center; + + margin-bottom: 1rem; +`; + const { name: feedName, template, requiredHashtags, customActions } = props; // for modals @@ -14,7 +35,7 @@ const toggleProposeModal = () => { setShowProposeModal(!showProposeModal); }; const modalToggles = { - propose: toggleProposeModal, + propose: toggleProposeModal }; return ( @@ -27,17 +48,18 @@ return ( props={{ showModal: showProposeModal, toggleModal: toggleProposeModal, - item: item, + item: item }} /> )} {!context.accountId ? ( // if not logged in - + +

Please login in order to post.

+ + + +
) : ( )} @@ -61,12 +83,12 @@ return ( key: it, options: { limit: 10, - order: "desc", + order: "desc" }, cacheOptions: { - ignoreCache: true, + ignoreCache: true }, - required: true, + required: true }))} Item={(p) => ( <>, + Button: () => <>, + ProgressState: () => <> +}; + +const DaoSDK = VM.require("sdks.near/widget/SDKs.Sputnik.DaoSDK"); + +const stepsArray = [1, 2, 3]; + +if (!DaoSDK) { + return <>; +} +const daoID = "build.sputnik-dao.near"; +const sdk = DaoSDK(daoID); + +const groupMembers = sdk.getMembersByGroupId({ groupId: "community" }) ?? []; + +const StorageKey = { + userCompletedOnboarding: "userCompletedOnboarding" +}; + +function onFollow(accountId) { + const data = { + graph: { follow: { [accountId]: "" } }, + index: { + graph: JSON.stringify({ + key: "follow", + value: { + type, + accountId: accountId + } + }), + notify: JSON.stringify({ + key: accountId, + value: { + type + } + }) + } + }; + + Social.set(data, { + force: true + }); +} + +const PostTemplate = `👋 Hey BuildDAO community! Thrilled to join this innovative space. Looking forward to connecting with like-minded individuals. What's your favorite aspect of BuildDAO?`; + +function OnboardingFlow() { + const userCompletedOnboarding = Storage.privateGet( + StorageKey.userCompletedOnboarding + ); + const [showModal, setShowModal] = useState(false); + const [step, setStep] = useState(1); + + const daofollowEdge = Social.keys( + `${context.accountId}/graph/follow/${daoID}`, + undefined, + { + values_only: true + } + ); + const userAlreadyFollowDao = + daofollowEdge && Object.keys(daofollowEdge).length > 0; + + useEffect(() => { + if (context.accountId && !userCompletedOnboarding) { + setShowModal(true); + } else { + setShowModal(false); + } + }, [userCompletedOnboarding]); + + useEffect(() => { + if (showModal && !userCompletedOnboarding) { + Storage.privateSet(StorageKey.userCompletedOnboarding, true); + } + }, [showModal]); + + const Wrapper = styled.div` + color: white; + font-size: 14px; + .text-muted { + color: #cdd0d5 !important; + } + .horizontal-line { + background-color: rgba(255, 255, 255, 0.2); + height: 1px; + width: 40px; + } + `; + + const Container = styled.div` + border-radius: 16px; + border: 1px solid rgba(255, 255, 255, 0.2); + + .fw-bold { + color: #fff !important; + } + `; + + const FollowBtn = ({ isFollowing, accountId }) => { + return ( + + ); + }; + + const accountsNotFollowed = + Array.isArray(groupMembers) && + groupMembers.filter((account) => { + const accountfollowEdge = Social.keys( + `${context.accountId}/graph/follow/${account}`, + undefined, + { + values_only: true + } + ); + if (accountfollowEdge && Object.keys(accountfollowEdge).length > 0) { + return false; + } + return true; + }); + + function getRandomAccounts() { + const shuffled = [...accountsNotFollowed].sort(() => 0.5 - Math.random()); + return shuffled; + } + + const StepsComponent = () => { + switch (step) { + case 1: + return ( +
+

Welcome!

+
+

First off, follow our DAO

+ + + + +
+
+ ); + case 2: + return ( +
+

Connect with others!

+
+

+ Follow interesting profiles and stay updated with the latest + discussions.
+ So far, we have {groupMembers?.length} members in the Build DAO + community. +

+

People you might want to follow

+ + {getRandomAccounts() + .slice(0, 4) + ?.map((account) => ( + +
+ +
+ +
+ ))} +
+
+ ); + case 3: + return ( +
+

Make Your Mark in BuildDAO

+
+

+ Exciting times!
+ Your application is under review. +
Show your presence in the community with your first post. +
+ Need inspiration? +

+
Suggested First Post
+
+ } + src="buildhub.near/widget/Compose" + props={{ + template: PostTemplate, + requiredHashtags: requiredHashtags, + postBtnText: "Create Your First Post" + }} + /> +
+ + ); + } + }; + + return ( + + {}} + hideCloseBtn={true} + > +
+
+ {stepsArray.map((item, index) => ( +
+ + {item} + + {index !== stepsArray.length - 1 && ( +
+ )} +
+ ))} +
+ +
+ +
+
+ +
+ + {step > 1 && ( + + )} +
+
+
+ ); +} + +return OnboardingFlow(props); diff --git a/apps/builddao/widget/Proposals.jsx b/apps/builddao/widget/Proposals.jsx index f4a57cf8..3cddbd7b 100644 --- a/apps/builddao/widget/Proposals.jsx +++ b/apps/builddao/widget/Proposals.jsx @@ -213,7 +213,11 @@ return ( />

Proposals

-
diff --git a/apps/builddao/widget/components/Modal.jsx b/apps/builddao/widget/components/Modal.jsx index 93235fd0..39c349a7 100644 --- a/apps/builddao/widget/components/Modal.jsx +++ b/apps/builddao/widget/components/Modal.jsx @@ -61,6 +61,7 @@ function Modal({ toggle, toggleContainerProps, key, + hideCloseBtn }) { return ( @@ -73,13 +74,15 @@ function Modal({
{title}
- - - - - + {!hideCloseBtn && ( + + + + + + )}
{children}
diff --git a/apps/builddao/widget/components/buttons/UserDropdown.jsx b/apps/builddao/widget/components/buttons/UserDropdown.jsx index 4864ae1b..dff0319c 100644 --- a/apps/builddao/widget/components/buttons/UserDropdown.jsx +++ b/apps/builddao/widget/components/buttons/UserDropdown.jsx @@ -164,7 +164,7 @@ return ( props={{ accountId: context.accountId, className: "d-inline-block", - style: { width: "40px", height: "40px" }, + style: { width: "40px", height: "40px" } }} /> diff --git a/apps/builddao/widget/components/login-now.jsx b/apps/builddao/widget/components/login-now.jsx deleted file mode 100644 index e5f68c46..00000000 --- a/apps/builddao/widget/components/login-now.jsx +++ /dev/null @@ -1,29 +0,0 @@ -const { Button } = VM.require("buildhub.near/widget/components") || { - Button: () => <>, -}; - -const Container = styled.div` - background-color: #23242b; - color: #fff; - - width: 100%; - height: 16rem; - border-radius: 1rem; - - display: flex; - flex-direction: column; - gap: 0.5rem; - align-items: center; - justify-content: center; - - margin-bottom: 1rem; -`; - -return ( - -

User not signed in. Please login in order to post.

- - - -
-); diff --git a/apps/builddao/widget/components/navigation/header.jsx b/apps/builddao/widget/components/navigation/header.jsx index 62ce83df..c3da1549 100644 --- a/apps/builddao/widget/components/navigation/header.jsx +++ b/apps/builddao/widget/components/navigation/header.jsx @@ -1,5 +1,5 @@ const { Button } = VM.require("buildhub.near/widget/components") || { - Button: () => <>, + Button: () => <> }; const Navbar = styled.div` @@ -67,8 +67,8 @@ const NavLink = ({ to, children }) => ( to={href({ widgetSrc: "buildhub.near/widget/app", params: { - page: to, - }, + page: to + } })} > {children} @@ -82,20 +82,8 @@ const SignInOrConnect = () => ( <> {context.accountId ? ( - ), - showActivity: false, - className: "custom-button", - joinBtnChildren: "Join Now", - href: "/join", - }} + src="buildhub.near/widget/components.buttons.UserDropdown" + props={{ logOut: props.logOut }} /> ) : ( @@ -114,8 +102,8 @@ const AppHeader = ({ page, routes, ...props }) => ( to={href({ widgetSrc: "buildhub.near/widget/app", params: { - page: "home", - }, + page: "home" + } })} > ( to={href({ widgetSrc: "buildhub.near/widget/app", params: { - page: "home", - }, + page: "home" + } })} > {

Together, we can build a better future.

-
diff --git a/apps/builddao/widget/home/join.jsx b/apps/builddao/widget/home/join.jsx index eb3216fc..05144cc2 100644 --- a/apps/builddao/widget/home/join.jsx +++ b/apps/builddao/widget/home/join.jsx @@ -362,8 +362,7 @@ const Join = () => { props={{ joinBtnChildren: "Join Now", showActivity: true, - className: "custom-button", - href: "/join", + className: "custom-button" }} /> diff --git a/apps/embeds/widget/EmbedPlugin.jsx b/apps/embeds/widget/EmbedPlugin.jsx index 279380a5..0f1204b2 100644 --- a/apps/embeds/widget/EmbedPlugin.jsx +++ b/apps/embeds/widget/EmbedPlugin.jsx @@ -4,8 +4,6 @@ const installedEmbeds = JSON.parse( Social.get(`${context.accountId}/settings/every/embed`, "final") || "null" ); -console.log("installedEmbeds", installedEmbeds); - if (plugin) { return (
@@ -37,11 +35,11 @@ if (plugin) { ...(installedEmbeds || []), { widgetSrc: plugin.widgetSrc, - embedSrc: plugin.embedSrc, - }, - ], - }, - }, + embedSrc: plugin.embedSrc + } + ] + } + } }) } > @@ -53,8 +51,8 @@ if (plugin) { notifyAccountId: accountId, item: { type: "social", - path: `${accountId}/${type}/${name}`, - }, + path: `${accountId}/${type}/${name}` + } }} />
@@ -94,7 +92,7 @@ return ( display: "flex", flexDirection: "column", justifyContent: "space-between", - overflow: "hidden", + overflow: "hidden" }} >
@@ -145,11 +143,11 @@ return ( ...(installedEmbeds || []), { widgetSrc: data.widgetSrc, - embedSrc: data.embedSrc, - }, - ], - }, - }, + embedSrc: data.embedSrc + } + ] + } + } }) } > @@ -161,8 +159,8 @@ return ( notifyAccountId: accountId, item: { type: "social", - path: `${accountId}/${type}/${name}`, - }, + path: `${accountId}/${type}/${name}` + } }} />
diff --git a/apps/embeds/widget/Post/Index.jsx b/apps/embeds/widget/Post/Index.jsx index 8168a0e1..fbf75ac4 100644 --- a/apps/embeds/widget/Post/Index.jsx +++ b/apps/embeds/widget/Post/Index.jsx @@ -21,7 +21,7 @@ const notifyAccountId = accountId; const item = { type: "social", path: `${accountId}/post/main`, - blockHeight, + blockHeight }; const link = @@ -172,7 +172,7 @@ const contentWidget = ( content, raw, truncateContent: props.truncateContent, - noEmbed: props.noEmbed, + noEmbed: props.noEmbed }} /> ); @@ -183,7 +183,7 @@ return ( props.hideComments || props.noBorder ? undefined : { - borderBottom: "1px solid #eee", + borderBottom: "1px solid #eee" } } > @@ -206,7 +206,7 @@ return ( hideMenu, link, postType: "post", - flagItem: item, + flagItem: item }} /> {fullPostLink ? ( @@ -230,7 +230,7 @@ return ( src="mob.near/widget/N.CommentButton" props={{ disabled: permissions.disableComment, - onClick: () => State.update({ showReply: !state.showReply }), + onClick: () => State.update({ showReply: !state.showReply }) }} /> State.update({ showReply: false }), + onComment: () => State.update({ showReply: false }) }} />
@@ -291,7 +291,7 @@ return ( raw, accounts: props.commentAccounts, groupId, - permissions, + permissions }} /> )} diff --git a/functions/sitemap/posts/[index].js b/functions/sitemap/posts/[index].js index cb926e01..34b24415 100644 --- a/functions/sitemap/posts/[index].js +++ b/functions/sitemap/posts/[index].js @@ -11,7 +11,7 @@ export const generateSitemapPosts = async (env, offset) => { monthly ` ); - console.log("urls count", urls.length); + return urls.slice(offset, offset + Limit).join("\n"); }; @@ -30,8 +30,8 @@ ${await generateSitemapPosts(env, offset)} `, { headers: { - "content-type": "application/xml;charset=UTF-8", - }, + "content-type": "application/xml;charset=UTF-8" + } } ); } diff --git a/functions/sitemap/sources/[index].js b/functions/sitemap/sources/[index].js index 01f6d436..36211ba6 100644 --- a/functions/sitemap/sources/[index].js +++ b/functions/sitemap/sources/[index].js @@ -5,7 +5,7 @@ const LIMIT = 50000; export const generateSitemapSources = async (env, offset) => { const data = await socialKeys("*/widget/*", null, { - return_type: "History", + return_type: "History" }); const urls = Object.entries(data) .map(([accountId, widget]) => @@ -24,7 +24,6 @@ export const generateSitemapSources = async (env, offset) => { .flat() ) .flat(); - console.log("urls count", urls.length); return urls.slice(offset, offset + LIMIT).join("\n"); }; @@ -43,8 +42,8 @@ ${await generateSitemapSources(env, offset)} `, { headers: { - "content-type": "application/xml;charset=UTF-8", - }, + "content-type": "application/xml;charset=UTF-8" + } } ); } diff --git a/src/App.js b/src/App.js index 2daff8c9..d8f2f6ec 100644 --- a/src/App.js +++ b/src/App.js @@ -20,7 +20,7 @@ import { useAccount, useInitNear, useNear, - utils, + utils } from "near-social-vm"; import React, { useCallback, useEffect, useState } from "react"; import "react-bootstrap-typeahead/css/Typeahead.bs5.css"; @@ -77,7 +77,7 @@ function App() { setupMeteorWallet(), setupNeth({ gas: "300000000000000", - bundle: false, + bundle: false }), setupNightly(), setupKeypom({ @@ -95,10 +95,10 @@ function App() { url: NetworkId == "testnet" ? "https://test.nearbuilders.org/#instant-url/ACCOUNT_ID/SECRET_KEY/MODULE_ID" - : "https://nearbuilders.org/#instant-url/ACCOUNT_ID/SECRET_KEY/MODULE_ID", - }, - }), - ], + : "https://nearbuilders.org/#instant-url/ACCOUNT_ID/SECRET_KEY/MODULE_ID" + } + }) + ] }), customElements: { Link: (props) => { @@ -114,11 +114,11 @@ function App() { : "about:blank"; } return ; - }, + } }, config: { - defaultFinality: undefined, - }, + defaultFinality: undefined + } }); }, [initNear]); @@ -190,7 +190,7 @@ function App() { logOut, requestSignIn, widgets: Widgets, - documentationHref, + documentationHref }; return ( diff --git a/src/components/OnboardingFlow.js b/src/components/OnboardingFlow.js new file mode 100644 index 00000000..98bd601d --- /dev/null +++ b/src/components/OnboardingFlow.js @@ -0,0 +1,18 @@ +import React from "react"; +import { Widget } from "near-social-vm"; +import { useBosLoaderStore } from "../stores/bos-loader"; + +export default function OnboardingFlow() { + const redirectMapStore = useBosLoaderStore(); + + return ( +
+ +
+ ); +} diff --git a/src/components/navigation/UserDropdown.js b/src/components/navigation/UserDropdown.js index 700c8a92..a5de78d1 100644 --- a/src/components/navigation/UserDropdown.js +++ b/src/components/navigation/UserDropdown.js @@ -120,7 +120,7 @@ export function UserDropdown(props) { props={{ accountId: account.accountId, className: "d-inline-block", - style: { width: "40px", height: "40px" }, + style: { width: "40px", height: "40px" } }} />
diff --git a/src/pages/Viewer.js b/src/pages/Viewer.js index 600b2c2e..de1c3754 100644 --- a/src/pages/Viewer.js +++ b/src/pages/Viewer.js @@ -1,6 +1,7 @@ import { Widget } from "near-social-vm"; import React, { useEffect, useMemo, useState } from "react"; import { useLocation, useParams } from "react-router-dom"; +import OnboardingFlow from "../components/OnboardingFlow"; const SESSION_STORAGE_REDIRECT_MAP_KEY = "nearSocialVMredirectMap"; @@ -59,16 +60,19 @@ function Viewer({ code, ...props }) { ); return ( - + <> + + + ); }