2022-07-25 15:07:19 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Layouts 1.4
|
2021-07-21 09:49:03 +00:00
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
2021-09-28 15:04:06 +00:00
|
|
|
import utils 1.0
|
2022-07-25 15:07:19 +00:00
|
|
|
import shared.panels 1.0
|
2021-10-01 15:58:36 +00:00
|
|
|
|
|
|
|
import "../../views"
|
|
|
|
import "../../panels/communities"
|
2020-12-11 20:38:10 +00:00
|
|
|
|
2022-07-25 15:07:19 +00:00
|
|
|
StatusStackModal {
|
|
|
|
id: root
|
2020-12-11 20:38:10 +00:00
|
|
|
|
2022-01-10 16:44:54 +00:00
|
|
|
property var rootStore
|
|
|
|
property var contactsStore
|
2021-07-21 09:49:03 +00:00
|
|
|
property var community
|
2022-01-19 20:07:02 +00:00
|
|
|
property var communitySectionModule
|
2020-12-11 20:38:10 +00:00
|
|
|
|
2022-07-25 15:07:19 +00:00
|
|
|
property var pubKeys: ([])
|
|
|
|
property string inviteMessage: ""
|
|
|
|
property string validationError: ""
|
|
|
|
property string successMessage: ""
|
2022-03-23 10:56:25 +00:00
|
|
|
|
2022-09-28 21:07:18 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
2022-11-07 13:16:29 +00:00
|
|
|
// values from Figma design
|
|
|
|
readonly property int footerButtonsHeight: 44
|
|
|
|
readonly property int popupContentHeight: 551
|
|
|
|
|
2022-09-28 21:07:18 +00:00
|
|
|
function sendInvites(pubKeys, inviteMessage) {
|
|
|
|
const error = root.communitySectionModule.inviteUsersToCommunity(JSON.stringify(pubKeys), inviteMessage);
|
|
|
|
d.processInviteResult(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
function processInviteResult(error) {
|
|
|
|
if (error) {
|
|
|
|
console.error('Error inviting', error);
|
|
|
|
root.validationError = error;
|
|
|
|
} else {
|
|
|
|
root.validationError = "";
|
|
|
|
root.successMessage = qsTr("Invite successfully sent");
|
|
|
|
}
|
2022-07-25 15:07:19 +00:00
|
|
|
}
|
2020-12-11 20:38:10 +00:00
|
|
|
}
|
|
|
|
|
2022-07-25 15:07:19 +00:00
|
|
|
onOpened: {
|
|
|
|
root.pubKeys = [];
|
|
|
|
root.successMessage = "";
|
|
|
|
root.validationError = "";
|
|
|
|
}
|
2022-06-20 13:27:00 +00:00
|
|
|
|
2022-07-25 15:07:19 +00:00
|
|
|
stackTitle: qsTr("Invite Contacts to %1").arg(community.name)
|
|
|
|
width: 640
|
2022-10-25 09:06:18 +00:00
|
|
|
|
|
|
|
padding: 0
|
2022-08-23 14:57:37 +00:00
|
|
|
leftPadding: 0
|
|
|
|
rightPadding: 0
|
2021-03-31 19:14:09 +00:00
|
|
|
|
2022-07-25 15:07:19 +00:00
|
|
|
nextButton: StatusButton {
|
2022-10-25 18:39:21 +00:00
|
|
|
objectName: "InviteFriendsToCommunityPopup_NextButton"
|
2022-11-07 13:16:29 +00:00
|
|
|
implicitHeight: d.footerButtonsHeight
|
2022-07-25 15:07:19 +00:00
|
|
|
text: qsTr("Next")
|
|
|
|
enabled: root.pubKeys.length
|
|
|
|
onClicked: {
|
|
|
|
root.currentIndex++;
|
2022-03-23 10:56:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-25 15:07:19 +00:00
|
|
|
finishButton: StatusButton {
|
2022-10-25 18:39:21 +00:00
|
|
|
objectName: "InviteFriendsToCommunityPopup_SendButton"
|
2022-11-07 13:16:29 +00:00
|
|
|
implicitHeight: d.footerButtonsHeight
|
2022-07-25 15:07:19 +00:00
|
|
|
enabled: root.pubKeys.length > 0
|
2023-05-11 10:57:00 +00:00
|
|
|
text: qsTr("Send %n invite(s)", "", root.pubKeys.length)
|
2022-07-25 15:07:19 +00:00
|
|
|
onClicked: {
|
2022-09-28 21:07:18 +00:00
|
|
|
d.sendInvites(root.pubKeys, root.inviteMessage);
|
2022-07-25 15:07:19 +00:00
|
|
|
root.close();
|
|
|
|
}
|
2020-12-11 20:38:10 +00:00
|
|
|
}
|
|
|
|
|
2022-07-25 15:07:19 +00:00
|
|
|
subHeaderItem: StyledText {
|
|
|
|
text: root.validationError || root.successMessage
|
|
|
|
visible: root.validationError !== "" || root.successMessage !== ""
|
|
|
|
font.pixelSize: 13
|
|
|
|
color: !!root.validationError ? Style.current.danger : Style.current.success
|
2022-08-23 14:57:37 +00:00
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
height: visible ? contentHeight : 0
|
2022-07-25 15:07:19 +00:00
|
|
|
}
|
2020-12-11 20:38:10 +00:00
|
|
|
|
2022-07-25 15:07:19 +00:00
|
|
|
stackItems: [
|
2022-10-25 09:06:18 +00:00
|
|
|
Item {
|
2022-11-07 13:16:29 +00:00
|
|
|
implicitHeight: d.popupContentHeight
|
|
|
|
|
2022-10-25 09:06:18 +00:00
|
|
|
CommunityProfilePopupInviteFriendsPanel {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.topMargin: 16
|
|
|
|
anchors.bottomMargin: 16
|
|
|
|
|
|
|
|
rootStore: root.rootStore
|
|
|
|
contactsStore: root.contactsStore
|
|
|
|
community: root.community
|
|
|
|
onPubKeysChanged: root.pubKeys = pubKeys
|
|
|
|
}
|
2022-07-25 15:07:19 +00:00
|
|
|
},
|
2022-10-25 09:06:18 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
CommunityProfilePopupInviteMessagePanel {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.topMargin: 16
|
|
|
|
|
|
|
|
contactsStore: root.contactsStore
|
|
|
|
pubKeys: root.pubKeys
|
|
|
|
onInviteMessageChanged: root.inviteMessage = inviteMessage
|
|
|
|
}
|
2020-12-11 20:38:10 +00:00
|
|
|
}
|
2021-07-21 09:49:03 +00:00
|
|
|
]
|
2020-12-11 20:38:10 +00:00
|
|
|
}
|
|
|
|
|