From 6b44cc6811bf26e169b7eba56996144a145b277f Mon Sep 17 00:00:00 2001 From: Martina Date: Sun, 25 Oct 2020 14:11:27 -0700 Subject: [PATCH] added backend for onboarding --- common/actions.js | 7 ++++ common/messages.js | 5 +++ node_common/managers/viewer.js | 1 + scenes/SceneDirectory.js | 73 ++++++++-------------------------- 4 files changed, 29 insertions(+), 57 deletions(-) diff --git a/common/actions.js b/common/actions.js index 9121e5f6..e01fac0a 100644 --- a/common/actions.js +++ b/common/actions.js @@ -180,6 +180,13 @@ export const createUser = async (data) => { }); }; +export const updateOnboardingStatus = async (data) => { + return await returnJSON(`/api/users/onboarding-update`, { + ...DEFAULT_OPTIONS, + body: JSON.stringify({ data }), + }); +}; + export const checkCIDStatus = async (data) => { return await returnJSON(`/api/data/cid-status`, { ...DEFAULT_OPTIONS, diff --git a/common/messages.js b/common/messages.js index 0a93673b..fd4925f6 100644 --- a/common/messages.js +++ b/common/messages.js @@ -165,6 +165,11 @@ export const error = { SERVER_USER_UPDATE: "Please make sure you are signed in first", SERVER_USER_UPDATE_USER_NOT_FOUND: "We're having trouble locating your information. Please try again", + SERVER_ONBOARDING_UPDATE: "Please log in first to access this page", + SERVER_ONBOARDING_UPDATE_USER_NOT_FOUND: + "We're having trouble locating your information right now", + SERVER_ONBOARDING_UPDATE_MUST_PROVIDE_UPDATE: + "We're having trouble updating your information right now", //Users Get GET_USER_BY_ID: "We weren't able to fetch information on that user. Please try again later", diff --git a/node_common/managers/viewer.js b/node_common/managers/viewer.js index 27ce13dd..8bffb777 100644 --- a/node_common/managers/viewer.js +++ b/node_common/managers/viewer.js @@ -104,6 +104,7 @@ export const getById = async ({ id }) => { ...Serializers.user(user), type: "VIEWER", library: user.data.library, + onboarding: user.data.onboarding || {}, // TODO(jim): Move this elsewhere. allow_filecoin_directory_listing: user.data.allow_filecoin_directory_listing diff --git a/scenes/SceneDirectory.js b/scenes/SceneDirectory.js index a7248e89..39a3ea43 100644 --- a/scenes/SceneDirectory.js +++ b/scenes/SceneDirectory.js @@ -8,10 +8,7 @@ import { css } from "@emotion/react"; import { TabGroup } from "~/components/core/TabGroup"; import { Boundary } from "~/components/system/components/fragments/Boundary"; import { PopoverNavigation } from "~/components/system/components/PopoverNavigation"; -import { - ButtonPrimary, - ButtonSecondary, -} from "~/components/system/components/Buttons"; +import { ButtonPrimary, ButtonSecondary } from "~/components/system/components/Buttons"; import ScenePage from "~/components/core/ScenePage"; import ScenePageHeader from "~/components/core/ScenePageHeader"; @@ -107,10 +104,7 @@ function UserEntry({ user, button, onClick, message }) { return (
-
+
{user.data.name || `@${user.username}`} {message ? {message} : null} @@ -212,10 +206,7 @@ export default class SceneDirectory extends React.Component { css={STYLES_ITEM_BOX} onClick={(e) => this._handleAccept(e, relation.owner.id)} > - +
- +
@@ -277,10 +265,7 @@ export default class SceneDirectory extends React.Component { }) .map((relation) => { let button = ( -
this._handleClick(e, relation.id)} - > +
this._handleClick(e, relation.id)}> {this.state.contextMenu === relation.id ? ( - this._handleCopy( - e, - `https://slate.host/${relation.owner.username}` - ), + this._handleCopy(e, `https://slate.host/${relation.owner.username}`), }, { text: "Remove peer", @@ -339,10 +321,7 @@ export default class SceneDirectory extends React.Component { }) .map((relation) => { let button = ( -
this._handleClick(e, relation.id)} - > +
this._handleClick(e, relation.id)}> {this.state.contextMenu === relation.id ? ( - this._handleCopy( - e, - `https://slate.host/${relation.user.username}` - ), + this._handleCopy(e, `https://slate.host/${relation.user.username}`), }, { text: "Remove peer", @@ -399,10 +375,7 @@ export default class SceneDirectory extends React.Component { }) .map((relation) => { let button = ( -
this._handleClick(e, relation.id)} - > +
this._handleClick(e, relation.id)}> {this.state.contextMenu === relation.id ? ( - this._handleCopy( - e, - `https://slate.host/${relation.user.username}` - ), + this._handleCopy(e, `https://slate.host/${relation.user.username}`), }, { text: "Unfollow", @@ -454,10 +424,7 @@ export default class SceneDirectory extends React.Component { let followers = this.props.viewer.subscribers.map((relation) => { let button = ( -
this._handleClick(e, relation.id)} - > +
this._handleClick(e, relation.id)}> {this.state.contextMenu === relation.id ? ( - this._handleCopy( - e, - `https://slate.host/${relation.owner.username}` - ), + this._handleCopy(e, `https://slate.host/${relation.owner.username}`), }, { - text: this.props.viewer.subscriptions.filter( - (subscription) => { - return ( - subscription.target_user_id === relation.owner.id - ); - } - ).length + text: this.props.viewer.subscriptions.filter((subscription) => { + return subscription.target_user_id === relation.owner.id; + }).length ? "Unfollow" : "Follow", onClick: (e) => this._handleFollow(e, relation.owner.id), @@ -549,8 +509,7 @@ export default class SceneDirectory extends React.Component { ) : ( - You can follow any user on the network to be updated on their new - uploads and slates. + You can follow any user on the network to be updated on their new uploads and slates. ) ) : null}