PortalSettings: add toast

This commit is contained in:
Viktor Fomin 2022-08-12 03:39:57 +03:00
parent 048237dffc
commit bc9c501f35
2 changed files with 34 additions and 8 deletions

View File

@ -1,21 +1,29 @@
import React, { useEffect } from "react"; import React, { useEffect } from "react";
import { withRouter } from "react-router"; import { withRouter } from "react-router";
import { withTranslation } from "react-i18next"; import { withTranslation } from "react-i18next";
import { inject } from "mobx-react";
import Text from "@docspace/components/text"; import Text from "@docspace/components/text";
import Button from "@docspace/components/button"; import Button from "@docspace/components/button";
import toastr from "@docspace/components/toast/toastr";
import { MainContainer } from "./StyledDeleteData"; import { MainContainer } from "./StyledDeleteData";
import { setDocumentTitle } from "../../../../helpers/utils"; import { setDocumentTitle } from "../../../../helpers/utils";
import api from "@docspace/common/api"; import api from "@docspace/common/api";
const PortalDeactivation = (props) => { const PortalDeactivation = (props) => {
const { t } = props; const { t, getPortalOwner, owner } = props;
useEffect(() => { useEffect(() => {
setDocumentTitle(t("PortalDeactivation")); setDocumentTitle(t("PortalDeactivation"));
getPortalOwner();
}, []); }, []);
const onDeactivateClick = async () => { const onDeactivateClick = async () => {
await api.portal.sendSuspendPortalEmail(); try {
await api.portal.sendSuspendPortalEmail();
toastr.success(t("ConfirmEmailSended", { ownerName: owner.displayName }));
} catch (error) {
toastr.error(error);
}
}; };
return ( return (
@ -38,4 +46,10 @@ const PortalDeactivation = (props) => {
); );
}; };
export default withTranslation("Settings")(withRouter(PortalDeactivation)); export default inject(({ auth }) => {
const { getPortalOwner, owner } = auth.settingsStore;
return {
getPortalOwner,
owner,
};
})(withTranslation("Settings")(withRouter(PortalDeactivation)));

View File

@ -1,21 +1,29 @@
import React, { useEffect } from "react"; import React, { useEffect } from "react";
import { withRouter } from "react-router"; import { withRouter } from "react-router";
import { withTranslation } from "react-i18next"; import { withTranslation } from "react-i18next";
import { inject } from "mobx-react";
import Text from "@docspace/components/text"; import Text from "@docspace/components/text";
import Button from "@docspace/components/button"; import Button from "@docspace/components/button";
import toastr from "@docspace/components/toast/toastr";
import { MainContainer } from "./StyledDeleteData"; import { MainContainer } from "./StyledDeleteData";
import { setDocumentTitle } from "../../../../helpers/utils"; import { setDocumentTitle } from "../../../../helpers/utils";
import api from "@docspace/common/api"; import api from "@docspace/common/api";
const PortalDeletion = (props) => { const PortalDeletion = (props) => {
const { t } = props; const { t, getPortalOwner, owner } = props;
useEffect(() => { useEffect(() => {
setDocumentTitle(t("PortalDeletion")); setDocumentTitle(t("PortalDeletion"));
getPortalOwner();
}, []); }, []);
const onDeleteClick = async () => { const onDeleteClick = async () => {
await api.portal.sendDeletePortalEmail(); try {
await api.portal.sendDeletePortalEmail();
toastr.success(t("ConfirmEmailSended", { ownerName: owner.displayName }));
} catch (error) {
toastr.error(error);
}
}; };
return ( return (
@ -38,6 +46,10 @@ const PortalDeletion = (props) => {
); );
}; };
export default withTranslation(["Settings", "Common"])( export default inject(({ auth }) => {
withRouter(PortalDeletion) const { getPortalOwner, owner } = auth.settingsStore;
); return {
getPortalOwner,
owner,
};
})(withTranslation(["Settings", "Common"])(withRouter(PortalDeletion)));