aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/pages
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2023-08-26 23:49:28 +0800
committercrupest <crupest@outlook.com>2023-08-26 23:49:28 +0800
commit256cc9592a3f31fc392e1ccdb699aa206b7b47ce (patch)
treefdca6f8b1cdbd5ed264a1af9e48496685f4e9a95 /FrontEnd/src/pages
parentf5dfd52f6efece2f4cad227044ecf4dd66301bbc (diff)
downloadtimeline-256cc9592a3f31fc392e1ccdb699aa206b7b47ce.tar.gz
timeline-256cc9592a3f31fc392e1ccdb699aa206b7b47ce.tar.bz2
timeline-256cc9592a3f31fc392e1ccdb699aa206b7b47ce.zip
...
Diffstat (limited to 'FrontEnd/src/pages')
-rw-r--r--FrontEnd/src/pages/login/index.tsx14
-rw-r--r--FrontEnd/src/pages/register/index.tsx26
-rw-r--r--FrontEnd/src/pages/setting/ChangeAvatarDialog.tsx5
-rw-r--r--FrontEnd/src/pages/setting/ChangePasswordDialog.tsx17
-rw-r--r--FrontEnd/src/pages/setting/index.tsx11
-rw-r--r--FrontEnd/src/pages/timeline/Timeline.tsx3
-rw-r--r--FrontEnd/src/pages/timeline/TimelineDeleteDialog.tsx4
-rw-r--r--FrontEnd/src/pages/timeline/TimelinePostView.tsx8
8 files changed, 38 insertions, 50 deletions
diff --git a/FrontEnd/src/pages/login/index.tsx b/FrontEnd/src/pages/login/index.tsx
index 582ebd0f..39ea3831 100644
--- a/FrontEnd/src/pages/login/index.tsx
+++ b/FrontEnd/src/pages/login/index.tsx
@@ -6,11 +6,7 @@ import { useUser, userService } from "~src/services/user";
import { useC } from "~src/components/common";
import LoadingButton from "~src/components/button/LoadingButton";
-import {
- InputErrorDict,
- InputGroup,
- useInputs,
-} from "~src/components/input/InputGroup";
+import { InputGroup, useInputs } from "~src/components/input/InputGroup";
import Page from "~src/components/Page";
import "./index.css";
@@ -47,15 +43,13 @@ export default function LoginPage() {
label: "user.rememberMe",
},
],
- validator: ({ username, password }) => {
- const result: InputErrorDict = {};
+ validator: ({ username, password }, errors) => {
if (username === "") {
- result["username"] = "login.emptyUsername";
+ errors["username"] = "login.emptyUsername";
}
if (password === "") {
- result["password"] = "login.emptyPassword";
+ errors["password"] = "login.emptyPassword";
}
- return result;
},
},
dataInit: {},
diff --git a/FrontEnd/src/pages/register/index.tsx b/FrontEnd/src/pages/register/index.tsx
index 9e478612..fa25c2c2 100644
--- a/FrontEnd/src/pages/register/index.tsx
+++ b/FrontEnd/src/pages/register/index.tsx
@@ -7,11 +7,7 @@ import { getHttpTokenClient } from "~src/http/token";
import { userService, useUser } from "~src/services/user";
import { LoadingButton } from "~src/components/button";
-import {
- useInputs,
- InputErrorDict,
- InputGroup,
-} from "~src/components/input/InputGroup";
+import { useInputs, InputGroup } from "~src/components/input/InputGroup";
import "./index.css";
@@ -51,26 +47,22 @@ export default function RegisterPage() {
label: "register.registerCode",
},
],
- validator: ({
- username,
- password,
- confirmPassword,
- registerCode,
- }) => {
- const result: InputErrorDict = {};
+ validator: (
+ { username, password, confirmPassword, registerCode },
+ errors,
+ ) => {
if (username === "") {
- result["username"] = "register.error.usernameEmpty";
+ errors["username"] = "register.error.usernameEmpty";
}
if (password === "") {
- result["password"] = "register.error.passwordEmpty";
+ errors["password"] = "register.error.passwordEmpty";
}
if (confirmPassword !== password) {
- result["confirmPassword"] = "register.error.confirmPasswordWrong";
+ errors["confirmPassword"] = "register.error.confirmPasswordWrong";
}
if (registerCode === "") {
- result["registerCode"] = "register.error.registerCodeEmpty";
+ errors["registerCode"] = "register.error.registerCodeEmpty";
}
- return result;
},
},
dataInit: {},
diff --git a/FrontEnd/src/pages/setting/ChangeAvatarDialog.tsx b/FrontEnd/src/pages/setting/ChangeAvatarDialog.tsx
index c34bcf4f..011c5059 100644
--- a/FrontEnd/src/pages/setting/ChangeAvatarDialog.tsx
+++ b/FrontEnd/src/pages/setting/ChangeAvatarDialog.tsx
@@ -11,9 +11,8 @@ import ImageCropper, {
applyClipToImage,
} from "~src/components/ImageCropper";
import BlobImage from "~src/components/BlobImage";
-import ButtonRowV2 from "~src/components/button/ButtonRowV2";
-import Dialog from "~src/components/dialog/Dialog";
-import DialogContainer from "~src/components/dialog/DialogContainer";
+import { ButtonRowV2 } from "~src/components/button";
+import { Dialog, DialogContainer } from "~src/components/dialog";
import "./ChangeAvatarDialog.css";
diff --git a/FrontEnd/src/pages/setting/ChangePasswordDialog.tsx b/FrontEnd/src/pages/setting/ChangePasswordDialog.tsx
index bfcea92d..946b9fbe 100644
--- a/FrontEnd/src/pages/setting/ChangePasswordDialog.tsx
+++ b/FrontEnd/src/pages/setting/ChangePasswordDialog.tsx
@@ -3,9 +3,7 @@ import { useNavigate } from "react-router-dom";
import { userService } from "~src/services/user";
-import OperationDialog, {
- InputErrorDict,
-} from "~src/components/dialog/OperationDialog";
+import { OperationDialog } from "~src/components/dialog";
interface ChangePasswordDialogProps {
open: boolean;
@@ -47,21 +45,22 @@ export function ChangePasswordDialog(props: ChangePasswordDialogProps) {
password: true,
},
],
- validator: ({ oldPassword, newPassword, retypedNewPassword }) => {
- const result: InputErrorDict = {};
+ validator: (
+ { oldPassword, newPassword, retypedNewPassword },
+ errors,
+ ) => {
if (oldPassword === "") {
- result["oldPassword"] =
+ errors["oldPassword"] =
"settings.dialogChangePassword.errorEmptyOldPassword";
}
if (newPassword === "") {
- result["newPassword"] =
+ errors["newPassword"] =
"settings.dialogChangePassword.errorEmptyNewPassword";
}
if (retypedNewPassword !== newPassword) {
- result["retypedNewPassword"] =
+ errors["retypedNewPassword"] =
"settings.dialogChangePassword.errorRetypeNotMatch";
}
- return result;
},
}}
onProcess={async ({ oldPassword, newPassword }) => {
diff --git a/FrontEnd/src/pages/setting/index.tsx b/FrontEnd/src/pages/setting/index.tsx
index 67416a08..918a77b5 100644
--- a/FrontEnd/src/pages/setting/index.tsx
+++ b/FrontEnd/src/pages/setting/index.tsx
@@ -4,25 +4,26 @@ import {
ReactNode,
ComponentPropsWithoutRef,
} from "react";
-import { useTranslation } from "react-i18next";
+import { useTranslation } from "react-i18next"; // For change language.
import { useNavigate } from "react-router-dom";
import classNames from "classnames";
-import { useC, Text } from "~src/common";
import { useUser, userService } from "~src/services/user";
import { getHttpUserClient } from "~src/http/user";
+import { pushAlert } from "~src/services/alert";
+
+import { useC, Text } from "~src/common";
-import { useDialog } from "~src/components/dialog";
-import ConfirmDialog from "~src/components/dialog/ConfirmDialog";
+import { useDialog, ConfirmDialog } from "~src/components/dialog";
import Card from "~src/components/Card";
import Spinner from "~src/components/Spinner";
import Page from "~src/components/Page";
+
import ChangePasswordDialog from "./ChangePasswordDialog";
import ChangeAvatarDialog from "./ChangeAvatarDialog";
import ChangeNicknameDialog from "./ChangeNicknameDialog";
import "./index.css";
-import { pushAlert } from "~src/services/alert";
interface SettingSectionProps
extends Omit<ComponentPropsWithoutRef<typeof Card>, "title"> {
diff --git a/FrontEnd/src/pages/timeline/Timeline.tsx b/FrontEnd/src/pages/timeline/Timeline.tsx
index f266ec9d..caf4f502 100644
--- a/FrontEnd/src/pages/timeline/Timeline.tsx
+++ b/FrontEnd/src/pages/timeline/Timeline.tsx
@@ -1,6 +1,5 @@
import { useState, useEffect } from "react";
import classnames from "classnames";
-import { useScrollToBottom } from "~src/utilities/hooks";
import { HubConnectionState } from "@microsoft/signalr";
import {
@@ -16,6 +15,8 @@ import {
import { getTimelinePostUpdate$ } from "~src/services/timeline";
+import { useScrollToBottom } from "~src/components/hooks";
+
import TimelinePostList from "./TimelinePostList";
import TimelinePostEdit from "./TimelinePostCreateView";
import TimelineCard from "./TimelineCard";
diff --git a/FrontEnd/src/pages/timeline/TimelineDeleteDialog.tsx b/FrontEnd/src/pages/timeline/TimelineDeleteDialog.tsx
index 7b7b8e8c..a7209e75 100644
--- a/FrontEnd/src/pages/timeline/TimelineDeleteDialog.tsx
+++ b/FrontEnd/src/pages/timeline/TimelineDeleteDialog.tsx
@@ -39,9 +39,9 @@ const TimelineDeleteDialog: React.FC<TimelineDeleteDialog> = (props) => {
label: "",
},
],
- validator: ({ name }) => {
+ validator: ({ name }, errors) => {
if (name !== timeline.nameV2) {
- return { name: "timeline.deleteDialog.notMatch" };
+ errors.name = "timeline.deleteDialog.notMatch";
}
},
}}
diff --git a/FrontEnd/src/pages/timeline/TimelinePostView.tsx b/FrontEnd/src/pages/timeline/TimelinePostView.tsx
index 2a8c5947..6b87ef2a 100644
--- a/FrontEnd/src/pages/timeline/TimelinePostView.tsx
+++ b/FrontEnd/src/pages/timeline/TimelinePostView.tsx
@@ -1,11 +1,13 @@
import { useState } from "react";
-import { getHttpTimelineClient, HttpTimelinePostInfo } from "~src/http/timeline";
+import {
+ getHttpTimelineClient,
+ HttpTimelinePostInfo,
+} from "~src/http/timeline";
import { pushAlert } from "~src/services/alert";
-import { useClickOutside } from "~src/utilities/hooks";
-
+import { useClickOutside } from "~src/components/hooks";
import UserAvatar from "~src/components/user/UserAvatar";
import { useDialog } from "~src/components/dialog";
import FlatButton from "~src/components/button/FlatButton";