Shared: fix nextjs probles, add 'use client' and delete useless wrappers and providers

This commit is contained in:
Timofey Boyko 2024-04-04 08:05:50 +03:00
parent decd30c482
commit 2ce4288639
8 changed files with 10 additions and 128 deletions

View File

@ -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";

View File

@ -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 (
<I18nextProvider i18n={i18n}>
<Error520
user={user}
errorLog={error}
version={version}
firebaseHelper={firebaseHelper}
currentDeviceType={currentDeviceType}
whiteLabelLogoUrls={whiteLabelLogoUrls}
currentColorScheme={theme.currentColorScheme}
/>
</I18nextProvider>
);
}
return (
<Error520
user={user}

View File

@ -25,8 +25,8 @@
// 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, useTranslation } from "react-i18next";
import { useTranslation } from "react-i18next";
import ErrorContainer from "../error-container/ErrorContainer";
@ -37,12 +37,3 @@ const Error404 = () => {
};
export default Error404;
export const Error404Wrapper = ({ i18nProp }: { i18nProp: i18n }) => {
if (!i18nProp.language) return null;
return (
<I18nextProvider i18n={i18nProp}>
<Error404 />
</I18nextProvider>
);
};

View File

@ -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};
}
`;

View File

@ -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 (
<I18nextProvider i18n={i18nProp}>
<Share {...rest} />
</I18nextProvider>
);
};
export default FilesSelectorWrapper;

View File

@ -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";

View File

@ -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 (
<I18nextProvider i18n={i18nProp}>
<FilesSelector {...rest} />
</I18nextProvider>
);
};
export default FilesSelectorWrapper;

View File

@ -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 = (