mirror of
https://github.com/hexastack/hexabot
synced 2025-02-22 04:17:48 +00:00
Merge pull request #718 from Hexastack/fix/use-pages-rotuer
fix: use pages router instead of app router
This commit is contained in:
commit
8798dfa64b
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2024 Hexastack. All rights reserved.
|
||||
* Copyright © 2025 Hexastack. All rights reserved.
|
||||
*
|
||||
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
||||
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
import { Avatar, Box } from "@mui/material";
|
||||
import UiChatWidget from "hexabot-chat-widget/src/UiChatWidget";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { useRouter } from "next/router";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import { getAvatarSrc } from "@/components/inbox/helpers/mapMessages";
|
||||
@ -24,7 +24,7 @@ import { ChatWidgetHeader } from "./ChatWidgetHeader";
|
||||
const SETTING_TYPE = "console_channel" as const;
|
||||
|
||||
export const ChatWidget = () => {
|
||||
const pathname = usePathname();
|
||||
const { pathname } = useRouter();
|
||||
const { apiUrl } = useConfig();
|
||||
const { isAuthenticated } = useAuth();
|
||||
const isVisualEditor = pathname.startsWith(`/${RouterType.VISUAL_EDITOR}`);
|
||||
|
@ -1,12 +1,11 @@
|
||||
/*
|
||||
* Copyright © 2024 Hexastack. All rights reserved.
|
||||
* Copyright © 2025 Hexastack. All rights reserved.
|
||||
*
|
||||
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
||||
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||
*/
|
||||
|
||||
import { usePathname } from "next/navigation";
|
||||
import { useRouter } from "next/router";
|
||||
import { useContext } from "react";
|
||||
|
||||
@ -33,12 +32,11 @@ export const useAuth = () => {
|
||||
|
||||
export const useLogoutRedirection = () => {
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const hasPublicPath = PUBLIC_PATHS.includes(router.pathname);
|
||||
const logoutRedirection = async (fullReload: boolean = false) => {
|
||||
if (!hasPublicPath) {
|
||||
const redirectUrl = `/${RouterType.LOGIN}?redirect=${encodeURIComponent(
|
||||
pathname,
|
||||
router.asPath,
|
||||
)}`;
|
||||
|
||||
if (fullReload) {
|
||||
|
Loading…
Reference in New Issue
Block a user