|
|
@ -3,9 +3,6 @@ import { ArrowLeftIcon, InformationCircleIcon } from '@heroicons/react/solid';
|
|
|
|
import { useRouter } from 'next/router';
|
|
|
|
import { useRouter } from 'next/router';
|
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
import { defineMessages, useIntl } from 'react-intl';
|
|
|
|
import { defineMessages, useIntl } from 'react-intl';
|
|
|
|
import { AvailableLocale } from '../../context/LanguageContext';
|
|
|
|
|
|
|
|
import useLocale from '../../hooks/useLocale';
|
|
|
|
|
|
|
|
import useSettings from '../../hooks/useSettings';
|
|
|
|
|
|
|
|
import { Permission, useUser } from '../../hooks/useUser';
|
|
|
|
import { Permission, useUser } from '../../hooks/useUser';
|
|
|
|
import SearchInput from './SearchInput';
|
|
|
|
import SearchInput from './SearchInput';
|
|
|
|
import Sidebar from './Sidebar';
|
|
|
|
import Sidebar from './Sidebar';
|
|
|
@ -19,21 +16,9 @@ const messages = defineMessages({
|
|
|
|
const Layout: React.FC = ({ children }) => {
|
|
|
|
const Layout: React.FC = ({ children }) => {
|
|
|
|
const [isSidebarOpen, setSidebarOpen] = useState(false);
|
|
|
|
const [isSidebarOpen, setSidebarOpen] = useState(false);
|
|
|
|
const [isScrolled, setIsScrolled] = useState(false);
|
|
|
|
const [isScrolled, setIsScrolled] = useState(false);
|
|
|
|
const { user, hasPermission } = useUser();
|
|
|
|
const { hasPermission } = useUser();
|
|
|
|
const router = useRouter();
|
|
|
|
const router = useRouter();
|
|
|
|
const intl = useIntl();
|
|
|
|
const intl = useIntl();
|
|
|
|
const { currentSettings } = useSettings();
|
|
|
|
|
|
|
|
const { setLocale } = useLocale();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
if (setLocale) {
|
|
|
|
|
|
|
|
setLocale(
|
|
|
|
|
|
|
|
(user?.settings?.locale
|
|
|
|
|
|
|
|
? user.settings.locale
|
|
|
|
|
|
|
|
: currentSettings.locale) as AvailableLocale
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, [setLocale, currentSettings.locale, user]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
const updateScrolled = () => {
|
|
|
|
const updateScrolled = () => {
|
|
|
|