chore: i18n in toast
This commit is contained in:
@@ -3,12 +3,14 @@ import { KEY_LOCAL_MAGIC_TOKEN } from "../../app/config";
|
||||
import { useLoginMutation } from "../../app/services/auth";
|
||||
import toast from "react-hot-toast";
|
||||
import { FetchBaseQueryError } from "@reduxjs/toolkit/dist/query";
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
export type GithubLoginSource = "widget" | "webapp"
|
||||
type Props = {
|
||||
code: string, from?: GithubLoginSource
|
||||
}
|
||||
const GithubCallback: FC<Props> = ({ code, from = "webapp" }) => {
|
||||
const { t: ct } = useTranslation();
|
||||
//拿本地存的magic token
|
||||
const magic_token = localStorage.getItem(KEY_LOCAL_MAGIC_TOKEN);
|
||||
const [login, { isLoading, isSuccess, error }] = useLoginMutation();
|
||||
@@ -23,7 +25,7 @@ const GithubCallback: FC<Props> = ({ code, from = "webapp" }) => {
|
||||
}, [code]);
|
||||
useEffect(() => {
|
||||
if (isSuccess) {
|
||||
toast.success("Login Successfully");
|
||||
toast.success(ct("tip.login"));
|
||||
// 通知widget
|
||||
if (from == 'widget') {
|
||||
localStorage.setItem("widget", `${new Date().getTime()}`);
|
||||
|
||||
@@ -10,12 +10,14 @@ import OidcLoginButton from "./OidcLoginButton";
|
||||
import { useLoginMutation } from '../../app/services/auth';
|
||||
import { LoginConfig } from '../../types/server';
|
||||
import { AuthType } from '../../types/common';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
type Props = {
|
||||
type?: AuthType
|
||||
}
|
||||
|
||||
const SocialLoginButtons = ({ type = "login" }: Props) => {
|
||||
const { t: ct } = useTranslation();
|
||||
const [login, { isSuccess }] = useLoginMutation();
|
||||
const { config: githubAuthConfig } = useGithubAuthConfig();
|
||||
const { data: loginConfig, isSuccess: loginConfigSuccess } = useGetLoginConfigQuery();
|
||||
@@ -23,7 +25,7 @@ const SocialLoginButtons = ({ type = "login" }: Props) => {
|
||||
|
||||
useEffect(() => {
|
||||
if (isSuccess) {
|
||||
toast.success("Login Successfully");
|
||||
toast.success(ct("tip.login"));
|
||||
// navigateTo("/");
|
||||
}
|
||||
}, [isSuccess]);
|
||||
|
||||
@@ -18,6 +18,7 @@ import SocialLoginButtons from "./SocialLoginButtons";
|
||||
|
||||
export default function LoginPage() {
|
||||
const { t } = useTranslation("auth");
|
||||
const { t: ct } = useTranslation();
|
||||
const { data: enableSMTP } = useGetSMTPStatusQuery();
|
||||
const [login, { isSuccess, isLoading, error }] = useLoginMutation();
|
||||
const { clientId } = useGoogleAuthConfig();
|
||||
@@ -82,7 +83,7 @@ export default function LoginPage() {
|
||||
}, [error]);
|
||||
useEffect(() => {
|
||||
if (isSuccess) {
|
||||
toast.success("Login Successfully");
|
||||
toast.success(ct("tip.login"));
|
||||
// navigateTo("/");
|
||||
}
|
||||
}, [isSuccess]);
|
||||
|
||||
@@ -6,8 +6,10 @@ import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useLoginMutation } from "../../app/services/auth";
|
||||
import toast from "react-hot-toast";
|
||||
import { setAuthData } from "../../app/slices/auth.data";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
export default function OAuthPage() {
|
||||
const { t: ct } = useTranslation();
|
||||
const [login, { data, isSuccess, isError }] = useLoginMutation();
|
||||
const { token } = useParams();
|
||||
const [loading, setLoading] = useState(true);
|
||||
@@ -36,7 +38,7 @@ export default function OAuthPage() {
|
||||
if (isSuccess && data) {
|
||||
setLoading(false);
|
||||
// 更新本地认证信息
|
||||
toast.success("Login Successfully");
|
||||
toast.success(ct("tip.login"));
|
||||
dispatch(setAuthData(data));
|
||||
navigateTo("/");
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ const UpdateFrontendURL = ({ refreshInviteLink }: Props) => {
|
||||
useEffect(() => {
|
||||
if (isSuccess) {
|
||||
refreshInviteLink();
|
||||
toast.success("Update Successfully!");
|
||||
toast.success(ct("tip.update"));
|
||||
}
|
||||
}, [isSuccess]);
|
||||
return (
|
||||
|
||||
@@ -8,8 +8,10 @@ import Button from "../../common/component/styled/Button";
|
||||
import { useLoginMutation, useCheckMagicTokenValidMutation } from "../../app/services/auth";
|
||||
import ExpiredTip from "./ExpiredTip";
|
||||
import { useRegisterMutation } from "../../app/services/auth";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
const RegWithUsername: FC = () => {
|
||||
const { t: ct } = useTranslation();
|
||||
const [checkTokenInvalid, { data: isTokenValid, isLoading: checkingToken }] =
|
||||
useCheckMagicTokenValidMutation();
|
||||
const [
|
||||
@@ -62,7 +64,7 @@ const RegWithUsername: FC = () => {
|
||||
const data = loginData || regData;
|
||||
if (isSuccess && data) {
|
||||
// 更新本地认证信息
|
||||
toast.success("Login Successfully");
|
||||
toast.success(ct("tip.login"));
|
||||
dispatch(setAuthData(data));
|
||||
// tricky
|
||||
location.href = `/#/`;
|
||||
|
||||
@@ -72,7 +72,7 @@ export default function APIConfig() {
|
||||
useEffect(() => {
|
||||
if (isSuccess) {
|
||||
hideAll();
|
||||
toast.success("Update API Secret Successfully!");
|
||||
toast.success(ct("tip.update"));
|
||||
}
|
||||
}, [isSuccess]);
|
||||
const handleToggle = (val: { third_party: boolean }) => {
|
||||
|
||||
@@ -21,7 +21,7 @@ const DeleteAPIKeyModal = ({ closeModal, uid, kid }: Props) => {
|
||||
};
|
||||
useEffect(() => {
|
||||
if (isSuccess) {
|
||||
toast.success("Delete API Key Successfully!");
|
||||
toast.success(ct("tip.delete"));
|
||||
closeModal();
|
||||
}
|
||||
}, [isSuccess]);
|
||||
|
||||
@@ -21,7 +21,7 @@ const DeleteModal = ({ closeModal, uid, name }: Props) => {
|
||||
};
|
||||
useEffect(() => {
|
||||
if (isSuccess) {
|
||||
toast.success("Delete Bot Successfully!");
|
||||
toast.success(ct("tip.delete"));
|
||||
closeModal();
|
||||
}
|
||||
}, [isSuccess]);
|
||||
|
||||
@@ -38,7 +38,7 @@ const WebhookModal = ({ uid, webhook, closeModal }: Props) => {
|
||||
};
|
||||
useEffect(() => {
|
||||
if (isSuccess) {
|
||||
toast.success("Update Webhook URL Successfully!");
|
||||
toast.success(ct("tip.update"));
|
||||
closeModal();
|
||||
}
|
||||
}, [isSuccess]);
|
||||
|
||||
@@ -53,7 +53,7 @@ export default function BotConfig() {
|
||||
};
|
||||
useEffect(() => {
|
||||
if (updateAvatarSuccess) {
|
||||
toast.success("Update Bot Avatar Successfully!");
|
||||
toast.success(ct("tip.update"));
|
||||
}
|
||||
}, [updateAvatarSuccess]);
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ const UpdateLicenseModal: FC<Props> = ({ closeModal, updateLicense, updating, up
|
||||
};
|
||||
useEffect(() => {
|
||||
if (updated) {
|
||||
toast.success("Update Successfully!");
|
||||
toast.success(ct("tip.update"));
|
||||
closeModal();
|
||||
}
|
||||
}, [updated]);
|
||||
|
||||
@@ -50,7 +50,7 @@ const LogoutConfirmModal: FC<Props> = ({ closeModal }) => {
|
||||
if (clearLocal) {
|
||||
clearLocalData();
|
||||
}
|
||||
toast.success("Logout Successfully");
|
||||
toast.success(ct("tip.logout"));
|
||||
}
|
||||
}, [exited, clearLocal]);
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ export default function MyAccount() {
|
||||
|
||||
useEffect(() => {
|
||||
if (uploadSuccess) {
|
||||
toast.success("update avatar successfully!");
|
||||
toast.success(ct("tip.update"));
|
||||
}
|
||||
}, [uploadSuccess]);
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ const Index = () => {
|
||||
const [updateUrl, { isLoading, isSuccess }] = useUpdateFrontendUrlMutation();
|
||||
useEffect(() => {
|
||||
if (isSuccess) {
|
||||
toast.success("Update Successfully!");
|
||||
toast.success(ct("tip.update"));
|
||||
}
|
||||
}, [isSuccess]);
|
||||
useEffect(() => {
|
||||
|
||||
@@ -12,6 +12,7 @@ import { useAppSelector } from '../../../app/store';
|
||||
|
||||
const Index = () => {
|
||||
const { t } = useTranslation("setting");
|
||||
const { t: ct } = useTranslation();
|
||||
const { loginUser, server } = useAppSelector((store) => {
|
||||
return { loginUser: store.authData.user, server: store.server };
|
||||
});
|
||||
@@ -42,7 +43,7 @@ const Index = () => {
|
||||
}, [server]);
|
||||
useEffect(() => {
|
||||
if (uploadSuccess) {
|
||||
toast.success("Update logo successfully!");
|
||||
toast.success(ct("tip.update"));
|
||||
}
|
||||
}, [uploadSuccess]);
|
||||
useEffect(() => {
|
||||
|
||||
@@ -47,7 +47,7 @@ const ProfileBasicEditModal: FC<Props> = ({
|
||||
useEffect(() => {
|
||||
if (isSuccess) {
|
||||
// todo
|
||||
toast.success("update user info successfully");
|
||||
toast.success(t("tip.update"));
|
||||
closeModal();
|
||||
}
|
||||
}, [isSuccess]);
|
||||
|
||||
@@ -16,7 +16,6 @@ const RemoveConfirmModal: FC<Props> = ({ closeModal }) => {
|
||||
const handleRemove = async () => {
|
||||
try {
|
||||
await removeCurrentAccount();
|
||||
// toast.success("Remove Account Successfully!");
|
||||
} catch (error) {
|
||||
toast.error("Remove Account Failed!");
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ interface BaseForm {
|
||||
|
||||
const ProfileBasicEditModal: FC<Props> = ({ closeModal }) => {
|
||||
const { t } = useTranslation("member");
|
||||
const { t: ct } = useTranslation();
|
||||
const { data } = useGetCredentialsQuery();
|
||||
const [input, setInput] = useState<BaseForm>({
|
||||
current: "",
|
||||
@@ -63,7 +64,7 @@ const ProfileBasicEditModal: FC<Props> = ({ closeModal }) => {
|
||||
useEffect(() => {
|
||||
if (isSuccess) {
|
||||
// todo
|
||||
toast.success("update password successfully");
|
||||
toast.success(ct("tip.update"));
|
||||
closeModal();
|
||||
}
|
||||
}, [isSuccess]);
|
||||
|
||||
@@ -15,6 +15,7 @@ import { useTranslation } from "react-i18next";
|
||||
|
||||
export default function Logins() {
|
||||
const { t } = useTranslation("setting", { keyPrefix: "login" });
|
||||
const { t: ct } = useTranslation();
|
||||
const {
|
||||
changed: clientIdChanged,
|
||||
clientId,
|
||||
@@ -37,14 +38,14 @@ export default function Logins() {
|
||||
// 更新google client id
|
||||
await updateClientIdToServer();
|
||||
if (!changed) {
|
||||
toast.success("Configuration Updated!");
|
||||
toast.success(ct("tip.update"));
|
||||
}
|
||||
}
|
||||
if (github && githubChanged) {
|
||||
// github config
|
||||
await updateGithubAuthConfigToServer();
|
||||
if (!changed) {
|
||||
toast.success("Configuration Updated!");
|
||||
toast.success(ct("tip.update"));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -39,7 +39,7 @@ const navs = [
|
||||
items: [
|
||||
{
|
||||
name: "bot",
|
||||
component: <ServerVersionChecker version="0.3.2"><BotConfig /></ServerVersionChecker>,
|
||||
component: <ServerVersionChecker version="0.3.4"><BotConfig /></ServerVersionChecker>,
|
||||
admin: true
|
||||
},
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ const DeleteConfirmModal: FC<Props> = ({ id, closeModal }) => {
|
||||
|
||||
useEffect(() => {
|
||||
if (isSuccess) {
|
||||
toast.success("delete channel successfully!");
|
||||
toast.success(ct("tip.delete"));
|
||||
closeModal();
|
||||
navigateTo("/chat");
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ const StyledWrapper = styled.div`
|
||||
`;
|
||||
export default function Overview({ id = 0 }) {
|
||||
const { t } = useTranslation("setting", { keyPrefix: "channel" });
|
||||
const { t: ct } = useTranslation();
|
||||
const { loginUser, channel } = useAppSelector((store) => {
|
||||
return {
|
||||
loginUser: store.authData.user,
|
||||
@@ -105,13 +106,13 @@ export default function Overview({ id = 0 }) {
|
||||
|
||||
useEffect(() => {
|
||||
if (updated) {
|
||||
toast.success("Channel updated!");
|
||||
toast.success(ct("tip.update"));
|
||||
refetch();
|
||||
}
|
||||
}, [updated]);
|
||||
useEffect(() => {
|
||||
if (changeTypeSuccess) {
|
||||
toast.success("Change channel visibility successfully!");
|
||||
toast.success(ct("tip.update"));
|
||||
}
|
||||
}, [changeTypeSuccess]);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ const DeleteConfirmModal: FC<Props> = ({ id, closeModal }) => {
|
||||
|
||||
useEffect(() => {
|
||||
if (isSuccess) {
|
||||
toast.success("delete user successfully!");
|
||||
toast.success(ct("tip.delete"));
|
||||
closeModal();
|
||||
navigateTo("/chat");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user