@@ -169,6 +176,7 @@ const PopupSettingsSpaceShare = observer(class PopupSettingsSpaceShare extends R
componentDidMount() {
this.load();
+ this.onGenerate(true);
};
componentDidUpdate() {
@@ -212,18 +220,41 @@ const PopupSettingsSpaceShare = observer(class PopupSettingsSpaceShare extends R
});
};
- onInviteCopy () {
- UtilCommon.copyToast(translate('commonLink'), this.inviteLink);
+ getLink () {
+ return `${Constant.protocol}://main/invite/?cid=${this.cid}&key=${encodeURIComponent(this.key)}`
};
- onInviteRefresh () {
- $('#refreshInviteLink').addClass('loading');
+ onCopy () {
+ UtilCommon.copyToast(translate('commonLink'), this.getLink());
+ };
- // refresh logic goes here
+ onGenerate (auto: boolean) {
+ const { space } = commonStore;
+ const node = $(this.node);
+ const button = node.find('#generate');
- window.setTimeout(() => {
- $('#refreshInviteLink').removeClass('loading');
- }, 2000);
+ if (!auto) {
+ button.addClass('loading');
+ };
+
+ C.SpaceInviteGenerate(space, (message: any) => {
+ if (!auto) {
+ button.removeClass('loading');
+ };
+
+ if (message.error.code) {
+ this.setState({ error: message.error.description });
+ return;
+ };
+
+ this.cid = message.inviteCid;
+ this.key = message.inviteKey;
+ this.refInput.setValue(this.getLink());
+
+ if (!auto) {
+ this.onCopy();
+ };
+ });
};
onStopSharing () {
diff --git a/src/ts/component/popup/space/joinRequest.tsx b/src/ts/component/popup/space/joinRequest.tsx
index 5fb4f9250c..54040b6541 100644
--- a/src/ts/component/popup/space/joinRequest.tsx
+++ b/src/ts/component/popup/space/joinRequest.tsx
@@ -1,12 +1,21 @@
import * as React from 'react';
-import { Title, Icon, Label, Button, Textarea, ObjectName, IconObject } from 'Component';
-import { I, translate, UtilCommon, UtilObject } from 'Lib';
+import { Title, Icon, Label, Button, Textarea, ObjectName, IconObject, Error } from 'Component';
+import { I, C, translate, UtilCommon, UtilObject } from 'Lib';
import { observer } from 'mobx-react';
import { authStore, dbStore, detailStore } from 'Store';
-const PopupSpaceJoinRequest = observer(class PopupSpaceJoinRequest extends React.Component
{
+interface State {
+ error: string;
+};
- message: string = '';
+const PopupSpaceJoinRequest = observer(class PopupSpaceJoinRequest extends React.Component {
+
+ refMessage = null;
+ state = {
+ error: '',
+ };
+ spaceName = '';
+ creatorName = '';
constructor (props: I.Popup) {
super(props);
@@ -15,43 +24,50 @@ const PopupSpaceJoinRequest = observer(class PopupSpaceJoinRequest extends React
};
render() {
- const space = UtilObject.getSpaceview();
- const owner = { name: 'Owner Name', layout: I.ObjectLayout.Human }; // mock, to be replaced with space owner
-
- const Profile = (item: any) => {
- return (
-
-
-
-
- );
- };
+ const { error } = this.state;
return (
-
-
- {translate('popupSpaceJoinRequestTextPart1')}
-
- {translate('popupSpaceJoinRequestTextPart2')}
-
- {translate('popupSpaceJoinRequestTextPart3')}
+
+
+
-