mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
Merge branch 'main' into 587-issue---refactor-delete-dialog-logic
This commit is contained in:
@@ -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.
|
||||
@@ -9,34 +9,26 @@
|
||||
import VisibilityOffOutlinedIcon from "@mui/icons-material/VisibilityOffOutlined";
|
||||
import VisibilityOutlinedIcon from "@mui/icons-material/VisibilityOutlined";
|
||||
import { IconButton, InputAdornment, TextFieldProps } from "@mui/material";
|
||||
import React, { forwardRef, useState } from "react";
|
||||
import { forwardRef, useState } from "react";
|
||||
|
||||
import { Input } from "./Input";
|
||||
|
||||
export const PasswordInput = forwardRef<any, TextFieldProps>(
|
||||
({ onChange, InputProps, value, ...rest }, ref) => {
|
||||
const [password, setPassword] = useState<string>(value as string);
|
||||
({ onChange, InputProps, ...rest }, ref) => {
|
||||
const [showPassword, setShowPassword] = useState(false);
|
||||
const handleTogglePasswordVisibility = () => {
|
||||
setShowPassword(!showPassword);
|
||||
};
|
||||
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setPassword(event.target.value);
|
||||
if (onChange) {
|
||||
onChange(event);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Input
|
||||
ref={ref}
|
||||
type={showPassword ? "text" : "password"}
|
||||
{...rest}
|
||||
defaultValue={value}
|
||||
onChange={handleChange}
|
||||
onChange={onChange}
|
||||
InputProps={{
|
||||
...InputProps,
|
||||
endAdornment: password && (
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
<IconButton onClick={handleTogglePasswordVisibility} edge="end">
|
||||
{showPassword ? (
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
* 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 getConfig from "next/config";
|
||||
import { useRouter } from "next/router";
|
||||
import { createContext, ReactNode, useEffect, useState } from "react";
|
||||
@@ -22,7 +21,6 @@ import { Progress } from "@/app-components/displays/Progress";
|
||||
import { useLogout } from "@/hooks/entities/auth-hooks";
|
||||
import { useApiClient } from "@/hooks/useApiClient";
|
||||
import { CURRENT_USER_KEY, PUBLIC_PATHS } from "@/hooks/useAuth";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { RouterType } from "@/services/types";
|
||||
import { IUser } from "@/types/user.types";
|
||||
@@ -54,18 +52,16 @@ export const AuthProvider = ({ children }: AuthProviderProps): JSX.Element => {
|
||||
const router = useRouter();
|
||||
const [search, setSearch] = useState("");
|
||||
const hasPublicPath = PUBLIC_PATHS.includes(router.pathname);
|
||||
const { i18n, t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const { i18n } = useTranslate();
|
||||
const [isReady, setIsReady] = useState(false);
|
||||
const queryClient = useQueryClient();
|
||||
const updateLanguage = (lang: string) => {
|
||||
i18n.changeLanguage(lang);
|
||||
};
|
||||
const { mutateAsync: logoutSession } = useLogout();
|
||||
const { mutate: logoutSession } = useLogout();
|
||||
const logout = async () => {
|
||||
updateLanguage(publicRuntimeConfig.lang.default);
|
||||
await logoutSession();
|
||||
toast.success(t("message.logout_success"));
|
||||
logoutSession();
|
||||
};
|
||||
const authRedirection = async (isAuthenticated: boolean) => {
|
||||
if (isAuthenticated) {
|
||||
|
||||
@@ -22,6 +22,8 @@ import { useSocket } from "@/websocket/socket-hooks";
|
||||
import { useFind } from "../crud/useFind";
|
||||
import { useApiClient } from "../useApiClient";
|
||||
import { CURRENT_USER_KEY, useAuth, useLogoutRedirection } from "../useAuth";
|
||||
import { useToast } from "../useToast";
|
||||
import { useTranslate } from "../useTranslate";
|
||||
|
||||
export const useLogin = (
|
||||
options?: Omit<
|
||||
@@ -54,6 +56,8 @@ export const useLogout = (
|
||||
const { apiClient } = useApiClient();
|
||||
const { socket } = useSocket();
|
||||
const { logoutRedirection } = useLogoutRedirection();
|
||||
const { toast } = useToast();
|
||||
const { t } = useTranslate();
|
||||
|
||||
return useMutation({
|
||||
...options,
|
||||
@@ -65,6 +69,10 @@ export const useLogout = (
|
||||
onSuccess: async () => {
|
||||
queryClient.removeQueries([CURRENT_USER_KEY]);
|
||||
await logoutRedirection();
|
||||
toast.success(t("message.logout_success"));
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t("message.logout_failed"));
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user