Client: PortalSettings: DeleteData: fix button size

This commit is contained in:
Viktor Fomin 2023-03-23 12:59:07 +03:00
parent 5b4b68d0f5
commit e53bfda10c
2 changed files with 23 additions and 3 deletions

View File

@ -1,4 +1,4 @@
import React, { useEffect } from "react";
import React, { useEffect, useState } from "react";
import { withRouter } from "react-router";
import { withTranslation } from "react-i18next";
import { inject } from "mobx-react";
@ -8,9 +8,11 @@ import toastr from "@docspace/components/toast/toastr";
import { MainContainer } from "./StyledDeleteData";
import { setDocumentTitle } from "../../../../helpers/utils";
import { sendSuspendPortalEmail } from "@docspace/common/api/portal";
import { isDesktop } from "@docspace/components/utils/device";
const PortalDeactivation = (props) => {
const { t, getPortalOwner, owner } = props;
const [isDesktopView, setIsDesktopView] = useState(false);
const fetchData = async () => {
await getPortalOwner();
@ -19,8 +21,16 @@ const PortalDeactivation = (props) => {
useEffect(() => {
setDocumentTitle(t("PortalDeactivation"));
fetchData();
onCheckView();
window.addEventListener("resize", onCheckView);
return () => window.removeEventListener("resize", onCheckView);
}, []);
const onCheckView = () => {
if (isDesktop()) setIsDesktopView(true);
else setIsDesktopView(false);
};
const onDeactivateClick = async () => {
try {
await sendSuspendPortalEmail();
@ -45,7 +55,7 @@ const PortalDeactivation = (props) => {
className="button"
label={t("Deactivate")}
primary
size="normal"
size={isDesktopView ? "small" : "normal"}
onClick={onDeactivateClick}
/>
</MainContainer>

View File

@ -12,11 +12,13 @@ import {
getPaymentAccount,
sendDeletePortalEmail,
} from "@docspace/common/api/portal";
import { isDesktop } from "@docspace/components/utils/device";
const PortalDeletion = (props) => {
const { t, getPortalOwner, owner } = props;
const [isDialogVisible, setIsDialogVisible] = useState(false);
const [stripeUrl, setStripeUrl] = useState(null);
const [isDesktopView, setIsDesktopView] = useState(false);
const fetchData = async () => {
await getPortalOwner();
@ -27,8 +29,16 @@ const PortalDeletion = (props) => {
useEffect(() => {
setDocumentTitle(t("DeleteDocSpace"));
fetchData();
onCheckView();
window.addEventListener("resize", onCheckView);
return () => window.removeEventListener("resize", onCheckView);
}, []);
const onCheckView = () => {
if (isDesktop()) setIsDesktopView(true);
else setIsDesktopView(false);
};
const onDeleteClick = async () => {
if (stripeUrl) {
setIsDialogVisible(true);
@ -57,7 +67,7 @@ const PortalDeletion = (props) => {
className="button"
label={t("Common:Delete")}
primary
size="normal"
size={isDesktopView ? "small" : "normal"}
onClick={onDeleteClick}
/>