Skip to content

Commit

Permalink
refactor store
Browse files Browse the repository at this point in the history
  • Loading branch information
chenbolin committed May 19, 2021
1 parent a08eefe commit ac95e77
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 21 deletions.
8 changes: 4 additions & 4 deletions packages/autonews-client/src/layout/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RouteConfig } from "src/shared/models/routeModels";
import { ReactElement, useEffect } from "react";
import { useEffect } from "react";
import { Layout, Menu } from "antd";
import cls from "./Layout.module.scss";
import { Link, useLocation } from "react-router-dom";
Expand All @@ -9,13 +9,13 @@ import { useDispatch } from "react-redux";

const { Header, Content, Footer } = Layout;

const LayoutComponent = ({ children }: RouteConfig): ReactElement => {
const LayoutComponent = ({ children }: RouteConfig) => {
const { pathname } = useLocation();
const dispatch = useDispatch();

useEffect(() => {
dispatch(fetchGlobalOrigin);
});
dispatch(fetchGlobalOrigin());
}, [dispatch]);

return (
<Layout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const PastInquiry = () => {
pastInquiryResult,
form: formData,
detail,
} = pastInquiry.pastInquiryResult;
} = pastInquiry;
const columns = [
{
title: "日期",
Expand Down
3 changes: 1 addition & 2 deletions packages/autonews-client/src/store/reducer/rootReducer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { AnyAction, Reducer } from "redux";
import actionTypes from "../types/actionTypes";
// import { updateObject } from '../../utils/utility';

const initialState = {
fakeDataList: [],
Expand Down Expand Up @@ -99,7 +98,7 @@ const rootReducer: Reducer<any> = (
case actionTypes.GLOBAL_FETCH_origin_SUCCESSED:
return {
...state,
origin: action.payload.origin,
origin: action.payload,
};
case actionTypes.GLOBAL_FETCH_newsList_SUCCESSED:
return {
Expand Down
18 changes: 9 additions & 9 deletions packages/autonews-client/src/store/sagas/globalSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function* watchFetchUserInfo(): any {
});
if (response) {
yield put(fetchPostApiDataExample(response));
yield put({ type: actionTypes.GLOBAL_SET_USERINFO, data: response });
yield put({ type: actionTypes.GLOBAL_SET_USERINFO, payload: response });
}
}
function* watchFetchGlobalOrigin(): any {
Expand All @@ -28,11 +28,11 @@ function* watchFetchGlobalOrigin(): any {
if (originList) {
yield put({
type: actionTypes.GLOBAL_FETCH_origin_SUCCESSED,
data: originList.data.data,
payload: originList.data,
});
yield put({
type: actionTypes.GLOBAL_FETCH_userSetting_REQUESTED,
origin: originList.data.data,
payload: originList.data,
});
}
}
Expand Down Expand Up @@ -88,7 +88,7 @@ function* watchFetchGlobalNewsList(): any {
return put({
type: actionTypes.GLOBAL_FETCH_newsList_SUCCESSED,
origin: originKeys[index],
data: item.data.data,
data: item.data,
});
});
}
Expand All @@ -105,11 +105,11 @@ function* watchSetLayouts(): any {
}

const globalSaga = [
watchFetchUserInfo,
watchFetchGlobalOrigin,
watchFetchGlobalUserSetting,
watchFetchGlobalNewsList,
watchSetLayouts,
watchFetchUserInfo(),
watchFetchGlobalOrigin(),
watchFetchGlobalUserSetting(),
watchFetchGlobalNewsList(),
watchSetLayouts(),
];

export default globalSaga;
2 changes: 1 addition & 1 deletion packages/autonews-client/src/store/sagas/monitorSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ function* watchFetchMonitor() {
}
}

const monitorSaga = [watchFetchMonitor];
const monitorSaga = [watchFetchMonitor()];

export default monitorSaga;
6 changes: 3 additions & 3 deletions packages/autonews-client/src/store/sagas/pastInquirySaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function* watchFetchPastInquiry(): any {
if (pastInquiry) {
yield put({
type: actionTypes.PastInquiry_FETCH_SUCCESSED,
payload: pastInquiry.data.data,
payload: pastInquiry.data,
});
} else {
let errBody = yield pastInquiry;
Expand All @@ -46,7 +46,7 @@ function* watchFetchDetailById(): any {
if (newsDetail) {
yield put({
type: actionTypes.PastInquiry_FETCH_detail_SUCCESSED,
data: newsDetail.data.data,
data: newsDetail.data,
});
} else {
let errBody = yield newsDetail;
Expand All @@ -58,6 +58,6 @@ function* watchFetchDetailById(): any {
}
}

const pastInquirySaga = [watchFetchPastInquiry, watchFetchDetailById];
const pastInquirySaga = [watchFetchPastInquiry(), watchFetchDetailById()];

export default pastInquirySaga;
2 changes: 1 addition & 1 deletion renovate.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": ["config:base", "schedule:earlyMondays"],
"extends": ["config:base", "schedule:monthly"],
"masterIssue": true
}

0 comments on commit ac95e77

Please sign in to comment.