diff options
author | crupest <crupest@outlook.com> | 2021-01-03 19:31:11 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-01-03 19:31:11 +0800 |
commit | 76e818a722a9c8cdb82c66dafaf0bd2768e29bc1 (patch) | |
tree | 454b773114f65160abd289a98afb49c9bf5f4936 /FrontEnd/src/app/views/home/BoardWithUser.tsx | |
parent | b7be2446ab3136b35ff8b752b13873ac690066f2 (diff) | |
download | timeline-76e818a722a9c8cdb82c66dafaf0bd2768e29bc1.tar.gz timeline-76e818a722a9c8cdb82c66dafaf0bd2768e29bc1.tar.bz2 timeline-76e818a722a9c8cdb82c66dafaf0bd2768e29bc1.zip |
...
Diffstat (limited to 'FrontEnd/src/app/views/home/BoardWithUser.tsx')
-rw-r--r-- | FrontEnd/src/app/views/home/BoardWithUser.tsx | 72 |
1 files changed, 60 insertions, 12 deletions
diff --git a/FrontEnd/src/app/views/home/BoardWithUser.tsx b/FrontEnd/src/app/views/home/BoardWithUser.tsx index 1c6f713a..8afe440b 100644 --- a/FrontEnd/src/app/views/home/BoardWithUser.tsx +++ b/FrontEnd/src/app/views/home/BoardWithUser.tsx @@ -3,6 +3,8 @@ import { Row, Col } from "react-bootstrap"; import { useTranslation } from "react-i18next"; import { AuthUser } from "@/services/user"; +import { pushAlert } from "@/services/alert"; + import { getHttpHighlightClient } from "@/http/highlight"; import { getHttpTimelineClient } from "@/http/timeline"; import { getHttpBookmarkClient } from "@/http/bookmark"; @@ -20,13 +22,36 @@ const BoardWithUser: React.FC<{ user: AuthUser }> = ({ user }) => { title={t("home.bookmarkTimeline")} load={() => getHttpBookmarkClient().list(user.token)} editHandler={{ - onDelete: () => { - // TODO: Implement this. - return Promise.resolve(); + onDelete: (timeline) => { + return getHttpBookmarkClient() + .delete(timeline, user.token) + .catch((e) => { + pushAlert({ + message: { + type: "i18n", + key: "home.message.deleteBookmarkFail", + }, + type: "danger", + }); + throw e; + }); }, - onMove: () => { - // TODO: Implement this. - return Promise.resolve(); + onMove: (timeline, index, offset) => { + return getHttpBookmarkClient() + .move( + { timeline, newPosition: index + offset + 1 }, // +1 because backend contract: index starts at 1 + user.token + ) + .catch((e) => { + pushAlert({ + message: { + type: "i18n", + key: "home.message.moveBookmarkFail", + }, + type: "danger", + }); + throw e; + }); }, }} /> @@ -48,13 +73,36 @@ const BoardWithUser: React.FC<{ user: AuthUser }> = ({ user }) => { editHandler={ user.hasHighlightTimelineAdministrationPermission ? { - onDelete: () => { - // TODO: Implement this. - return Promise.resolve(); + onDelete: (timeline) => { + return getHttpHighlightClient() + .delete(timeline, user.token) + .catch((e) => { + pushAlert({ + message: { + type: "i18n", + key: "home.message.deleteHighlightFail", + }, + type: "danger", + }); + throw e; + }); }, - onMove: () => { - // TODO: Implement this. - return Promise.resolve(); + onMove: (timeline, index, offset) => { + return getHttpHighlightClient() + .move( + { timeline, newPosition: index + offset + 1 }, // +1 because backend contract: index starts at 1 + user.token + ) + .catch((e) => { + pushAlert({ + message: { + type: "i18n", + key: "home.message.moveHighlightFail", + }, + type: "danger", + }); + throw e; + }); }, } : undefined |