refactor: introducing use{Module}Store instead of service (#768)

* refactor: introducing `useEditorStore`

* refactor: update

* chore: update
This commit is contained in:
boojack
2022-12-18 15:25:18 +08:00
committed by GitHub
parent bd00fa798d
commit ef621a444f
63 changed files with 911 additions and 886 deletions

View File

@ -1,7 +1,6 @@
import React, { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { userService } from "../../services";
import { useAppSelector } from "../../store";
import { useUserStore } from "../../store/module";
import * as api from "../../helpers/api";
import toastHelper from "../Toast";
import Dropdown from "../common/Dropdown";
@ -16,7 +15,8 @@ interface State {
const PreferencesSection = () => {
const { t } = useTranslation();
const currentUser = useAppSelector((state) => state.user.user);
const userStore = useUserStore();
const currentUser = userStore.state.user;
const [state, setState] = useState<State>({
createUserUsername: "",
createUserPassword: "",
@ -80,7 +80,7 @@ const PreferencesSection = () => {
content: `Are you sure to archive ${user.username}?`,
style: "warning",
onConfirm: async () => {
await userService.patchUser({
await userStore.patchUser({
id: user.id,
rowStatus: "ARCHIVED",
});
@ -90,7 +90,7 @@ const PreferencesSection = () => {
};
const handleRestoreUserClick = async (user: User) => {
await userService.patchUser({
await userStore.patchUser({
id: user.id,
rowStatus: "NORMAL",
});
@ -103,7 +103,7 @@ const PreferencesSection = () => {
content: `Are you sure to delete ${user.username}? THIS ACTION IS IRREVERSIABLE.❗️`,
style: "warning",
onConfirm: async () => {
await userService.deleteUser({
await userStore.deleteUser({
id: user.id,
});
fetchUserList();