mirror of
https://github.com/aykhans/slash-e.git
synced 2025-07-23 21:34:24 +00:00
feat: use react-hot-toast
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import { Button, Input } from "@mui/joy";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { toast } from "react-hot-toast";
|
||||
import * as api from "../helpers/api";
|
||||
import { validate, ValidatorConfig } from "../helpers/validator";
|
||||
import { userService } from "../services";
|
||||
import useLoading from "../hooks/useLoading";
|
||||
import Icon from "../components/Icon";
|
||||
import toastHelper from "../components/Toast";
|
||||
|
||||
const validateConfig: ValidatorConfig = {
|
||||
minLength: 4,
|
||||
@@ -53,13 +53,13 @@ const Auth: React.FC = () => {
|
||||
|
||||
const emailValidResult = validate(email, validateConfig);
|
||||
if (!emailValidResult.result) {
|
||||
toastHelper.error("Email: " + emailValidResult.reason);
|
||||
toast.error("Email: " + emailValidResult.reason);
|
||||
return;
|
||||
}
|
||||
|
||||
const passwordValidResult = validate(password, validateConfig);
|
||||
if (!passwordValidResult.result) {
|
||||
toastHelper.error("Password: " + passwordValidResult.reason);
|
||||
toast.error("Password: " + passwordValidResult.reason);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -72,11 +72,11 @@ const Auth: React.FC = () => {
|
||||
replace: true,
|
||||
});
|
||||
} else {
|
||||
toastHelper.error("Signin failed");
|
||||
toast.error("Signin failed");
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error(error);
|
||||
toastHelper.error(JSON.stringify(error.response.data));
|
||||
toast.error(JSON.stringify(error.response.data));
|
||||
}
|
||||
actionBtnLoadingState.setFinish();
|
||||
};
|
||||
@@ -88,13 +88,13 @@ const Auth: React.FC = () => {
|
||||
|
||||
const emailValidResult = validate(email, validateConfig);
|
||||
if (!emailValidResult.result) {
|
||||
toastHelper.error("Email: " + emailValidResult.reason);
|
||||
toast.error("Email: " + emailValidResult.reason);
|
||||
return;
|
||||
}
|
||||
|
||||
const passwordValidResult = validate(password, validateConfig);
|
||||
if (!passwordValidResult.result) {
|
||||
toastHelper.error("Password: " + passwordValidResult.reason);
|
||||
toast.error("Password: " + passwordValidResult.reason);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -107,11 +107,11 @@ const Auth: React.FC = () => {
|
||||
replace: true,
|
||||
});
|
||||
} else {
|
||||
toastHelper.error("Signup failed");
|
||||
toast.error("Signup failed");
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error(error);
|
||||
toastHelper.error(JSON.stringify(error.response.data));
|
||||
toast.error(JSON.stringify(error.response.data));
|
||||
}
|
||||
actionBtnLoadingState.setFinish();
|
||||
};
|
||||
|
@@ -1,12 +1,12 @@
|
||||
import { Button, Input, Tooltip } from "@mui/joy";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import toast from "react-hot-toast";
|
||||
import { useAppSelector } from "../store";
|
||||
import { showCommonDialog } from "../components/Alert";
|
||||
import { userService } from "../services";
|
||||
import Icon from "../components/Icon";
|
||||
import copy from "copy-to-clipboard";
|
||||
import toastHelper from "../components/Toast";
|
||||
import ChangePasswordDialog from "../components/ChangePasswordDialog";
|
||||
|
||||
interface State {
|
||||
@@ -36,12 +36,12 @@ const UserDetail: React.FC = () => {
|
||||
|
||||
const handleCopyOpenIdBtnClick = async () => {
|
||||
if (!user?.openId) {
|
||||
toastHelper.error("OpenID not found");
|
||||
toast.error("OpenID not found");
|
||||
return;
|
||||
}
|
||||
|
||||
copy(user.openId);
|
||||
toastHelper.success("OpenID copied");
|
||||
toast.success("OpenID copied");
|
||||
};
|
||||
|
||||
const handleResetOpenIdBtnClick = async () => {
|
||||
|
@@ -1,11 +1,11 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { NavLink, useLocation, useNavigate, useParams } from "react-router-dom";
|
||||
import toast from "react-hot-toast";
|
||||
import { shortcutService, userService } from "../services";
|
||||
import { useAppSelector } from "../store";
|
||||
import { unknownWorkspace } from "../store/modules/workspace";
|
||||
import useLoading from "../hooks/useLoading";
|
||||
import Icon from "../components/Icon";
|
||||
import toastHelper from "../components/Toast";
|
||||
import Dropdown from "../components/common/Dropdown";
|
||||
import ShortcutListView from "../components/ShortcutListView";
|
||||
import WorkspaceSetting from "../components/WorkspaceSetting";
|
||||
@@ -34,7 +34,7 @@ const WorkspaceDetail: React.FC = () => {
|
||||
}
|
||||
|
||||
if (!workspace) {
|
||||
toastHelper.error("workspace not found");
|
||||
toast.error("workspace not found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user