teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

該当箇所のコードを追記

2020/05/31 04:35

投稿

_3443_
_3443_

スコア5

title CHANGED
File without changes
body CHANGED
@@ -73,6 +73,40 @@
73
73
  };
74
74
  ```
75
75
 
76
+ ```js
77
+ import { SCHEDULES_ADD_ITEM } from "./actions";
78
+ import dayjs from "dayjs";
79
+
80
+ const init = {
81
+ items: [
82
+ {
83
+ id: 1,
84
+ title: "テストtitle",
85
+ date: dayjs(),
86
+ location: "テストlocation",
87
+ description: "テストdescription"
88
+ }
89
+ ],
90
+ isLoading: false
91
+ };
92
+
93
+ const schedulesReducer = (state = init, action) => {
94
+ const { type, payload } = action;
95
+
96
+ switch (type) {
97
+ case SCHEDULES_ADD_ITEM:
98
+ return {
99
+ ...state,
100
+ item: [...state.items, { ...payload, id: state.items.length + 1 }]
101
+ };
102
+ default:
103
+ return state;
104
+ }
105
+ };
106
+
107
+ export default schedulesReducer;
108
+ ```
109
+
76
110
  ### 試したこと
77
111
 
78
112
  schedulesが空ということだと思ったのですが、解決方法が分からず、、

2

該当箇所のコードを追記

2020/05/31 04:35

投稿

_3443_
_3443_

スコア5

title CHANGED
File without changes
body CHANGED
@@ -66,6 +66,13 @@
66
66
  )(CalendarBoard);
67
67
  ```
68
68
 
69
+ ```js
70
+ export const isSameDay = (d1, d2) => {
71
+ const format = "YYYYMMDD";
72
+ return d1.format(format) === d2.format(format);
73
+ };
74
+ ```
75
+
69
76
  ### 試したこと
70
77
 
71
78
  schedulesが空ということだと思ったのですが、解決方法が分からず、、

1

該当箇所のコードを追記

2020/05/31 03:09

投稿

_3443_
_3443_

スコア5

title CHANGED
File without changes
body CHANGED
@@ -21,6 +21,51 @@
21
21
  }));
22
22
  ```
23
23
 
24
+ ```js
25
+ import { createCalendar } from "../../services/calendar";
26
+ import { connect } from "react-redux";
27
+ import CalendarBoard from "./presentation";
28
+ import {
29
+ addScheduleOpenDialog,
30
+ addScheduleSetValue
31
+ } from "../../redux/addSchedule/actions";
32
+ import { setSchedules } from "../../services/schedule";
33
+
34
+ const mapDispatchToProps = dispatch => ({
35
+ openAddScheduleDialog: d => {
36
+ dispatch(addScheduleOpenDialog());
37
+ dispatch(addScheduleSetValue({ date: d }));
38
+ }
39
+ });
40
+
41
+ const mapStateToProps = state => ({
42
+ calendar: state.calendar,
43
+ schedules: state.schedules
44
+ });
45
+
46
+ const mergeProps = (stateProps, dispatchProps) => {
47
+ const {
48
+ calendar: month,
49
+ schedules: { items: schedules }
50
+ } = stateProps;
51
+
52
+ const calendar = setSchedules(createCalendar(month), schedules);
53
+
54
+ return {
55
+ ...stateProps,
56
+ ...dispatchProps,
57
+ calendar,
58
+ month
59
+ };
60
+ };
61
+
62
+ export default connect(
63
+ mapStateToProps,
64
+ mapDispatchToProps,
65
+ mergeProps
66
+ )(CalendarBoard);
67
+ ```
68
+
24
69
  ### 試したこと
25
70
 
26
71
  schedulesが空ということだと思ったのですが、解決方法が分からず、、