From 2ce4288639cdfab4135e823ac5506bbf5a4e07f5 Mon Sep 17 00:00:00 2001 From: Timofey Boyko Date: Thu, 4 Apr 2024 08:05:50 +0300 Subject: [PATCH] Shared: fix nextjs probles, add 'use client' and delete useless wrappers and providers --- .../shared/components/app-loader/index.tsx | 2 + .../error-boundary/ErrorBoundary.tsx | 23 ---------- .../shared/components/errors/Error404.tsx | 13 +----- .../shared/components/global-style/index.tsx | 3 +- .../shared/components/share/Share.wrapper.tsx | 46 ------------------- packages/shared/components/toast/Toast.tsx | 2 + .../selectors/Files/FilesSelector.wrapper.tsx | 46 ------------------- packages/shared/utils/useClickOutside.ts | 3 ++ 8 files changed, 10 insertions(+), 128 deletions(-) delete mode 100644 packages/shared/components/share/Share.wrapper.tsx delete mode 100644 packages/shared/selectors/Files/FilesSelector.wrapper.tsx diff --git a/packages/shared/components/app-loader/index.tsx b/packages/shared/components/app-loader/index.tsx index d6b76761c0..dbf7c90101 100644 --- a/packages/shared/components/app-loader/index.tsx +++ b/packages/shared/components/app-loader/index.tsx @@ -24,6 +24,8 @@ // content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode +"use client"; + import React from "react"; import { Loader, LoaderTypes } from "../loader"; diff --git a/packages/shared/components/error-boundary/ErrorBoundary.tsx b/packages/shared/components/error-boundary/ErrorBoundary.tsx index 07c739a899..e8ba1976f7 100644 --- a/packages/shared/components/error-boundary/ErrorBoundary.tsx +++ b/packages/shared/components/error-boundary/ErrorBoundary.tsx @@ -26,8 +26,6 @@ import React, { ErrorInfo } from "react"; -import { I18nextProvider } from "react-i18next"; - import Error520 from "../errors/Error520"; import type { @@ -68,32 +66,11 @@ class ErrorBoundary extends React.Component< currentDeviceType, whiteLabelLogoUrls, currentColorScheme, - isNextJS, - theme, - i18n, } = this.props; if (error) { // You can render any custom fallback UI - if (isNextJS && !i18n?.language) return null; - - if (isNextJS && theme && i18n) { - return ( - - - - ); - } - return ( { }; export default Error404; - -export const Error404Wrapper = ({ i18nProp }: { i18nProp: i18n }) => { - if (!i18nProp.language) return null; - return ( - - - - ); -}; diff --git a/packages/shared/components/global-style/index.tsx b/packages/shared/components/global-style/index.tsx index 730b903c78..8cfee73494 100644 --- a/packages/shared/components/global-style/index.tsx +++ b/packages/shared/components/global-style/index.tsx @@ -32,7 +32,7 @@ const GlobalStyle = createGlobalStyle<{ theme: TTheme }>` margin: 0; background-color: ${(props) => props.theme.backgroundColor}; - + color: ${(props) => props.theme.color}; font-family: ${(props) => props.theme.fontFamily}; @@ -42,7 +42,6 @@ const GlobalStyle = createGlobalStyle<{ theme: TTheme }>` } body { - direction: ${(props) => props.theme.interfaceDirection}; } `; diff --git a/packages/shared/components/share/Share.wrapper.tsx b/packages/shared/components/share/Share.wrapper.tsx deleted file mode 100644 index 110cfa1dfa..0000000000 --- a/packages/shared/components/share/Share.wrapper.tsx +++ /dev/null @@ -1,46 +0,0 @@ -// (c) Copyright Ascensio System SIA 2009-2024 -// -// This program is a free software product. -// You can redistribute it and/or modify it under the terms -// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software -// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended -// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of -// any third-party rights. -// -// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see -// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html -// -// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021. -// -// The interactive user interfaces in modified source and object code versions of the Program must -// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3. -// -// Pursuant to Section 7(b) of the License you must retain the original Product logo when -// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under -// trademark law for use of our trademarks. -// -// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing -// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 -// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - -import React from "react"; -import { i18n } from "i18next"; -import { I18nextProvider } from "react-i18next"; - -import { ShareProps } from "./Share.types"; -import Share from "."; - -const FilesSelectorWrapper = ({ - i18nProp, - - ...rest -}: ShareProps & { i18nProp: i18n }) => { - return ( - - - - ); -}; - -export default FilesSelectorWrapper; diff --git a/packages/shared/components/toast/Toast.tsx b/packages/shared/components/toast/Toast.tsx index 0b847a173a..a48de26944 100644 --- a/packages/shared/components/toast/Toast.tsx +++ b/packages/shared/components/toast/Toast.tsx @@ -24,6 +24,8 @@ // content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode +"use client"; + import React, { useCallback, useEffect, useState } from "react"; import { ToastClassName, cssTransition } from "react-toastify"; import { isMobileOnly } from "react-device-detect"; diff --git a/packages/shared/selectors/Files/FilesSelector.wrapper.tsx b/packages/shared/selectors/Files/FilesSelector.wrapper.tsx deleted file mode 100644 index 15f6d86efa..0000000000 --- a/packages/shared/selectors/Files/FilesSelector.wrapper.tsx +++ /dev/null @@ -1,46 +0,0 @@ -// (c) Copyright Ascensio System SIA 2009-2024 -// -// This program is a free software product. -// You can redistribute it and/or modify it under the terms -// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software -// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended -// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of -// any third-party rights. -// -// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see -// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html -// -// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021. -// -// The interactive user interfaces in modified source and object code versions of the Program must -// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3. -// -// Pursuant to Section 7(b) of the License you must retain the original Product logo when -// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under -// trademark law for use of our trademarks. -// -// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing -// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 -// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - -import React from "react"; -import { i18n } from "i18next"; -import { I18nextProvider } from "react-i18next"; - -import { FilesSelectorProps } from "./FilesSelector.types"; -import FilesSelector from "."; - -const FilesSelectorWrapper = ({ - i18nProp, - - ...rest -}: FilesSelectorProps & { i18nProp: i18n }) => { - return ( - - - - ); -}; - -export default FilesSelectorWrapper; diff --git a/packages/shared/utils/useClickOutside.ts b/packages/shared/utils/useClickOutside.ts index bc6ad00b90..11aa3d1cf9 100644 --- a/packages/shared/utils/useClickOutside.ts +++ b/packages/shared/utils/useClickOutside.ts @@ -25,6 +25,9 @@ // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode /* eslint-disable react-hooks/exhaustive-deps */ + +"use client"; + import { useEffect } from "react"; export const useClickOutside = (