質問編集履歴

3

該当箇所のコードを追記

2020/05/31 04:35

投稿

_3443_
_3443_

スコア5

test CHANGED
File without changes
test CHANGED
@@ -148,6 +148,74 @@
148
148
 
149
149
 
150
150
 
151
+ ```js
152
+
153
+ import { SCHEDULES_ADD_ITEM } from "./actions";
154
+
155
+ import dayjs from "dayjs";
156
+
157
+
158
+
159
+ const init = {
160
+
161
+ items: [
162
+
163
+ {
164
+
165
+ id: 1,
166
+
167
+ title: "テストtitle",
168
+
169
+ date: dayjs(),
170
+
171
+ location: "テストlocation",
172
+
173
+ description: "テストdescription"
174
+
175
+ }
176
+
177
+ ],
178
+
179
+ isLoading: false
180
+
181
+ };
182
+
183
+
184
+
185
+ const schedulesReducer = (state = init, action) => {
186
+
187
+ const { type, payload } = action;
188
+
189
+
190
+
191
+ switch (type) {
192
+
193
+ case SCHEDULES_ADD_ITEM:
194
+
195
+ return {
196
+
197
+ ...state,
198
+
199
+ item: [...state.items, { ...payload, id: state.items.length + 1 }]
200
+
201
+ };
202
+
203
+ default:
204
+
205
+ return state;
206
+
207
+ }
208
+
209
+ };
210
+
211
+
212
+
213
+ export default schedulesReducer;
214
+
215
+ ```
216
+
217
+
218
+
151
219
  ### 試したこと
152
220
 
153
221
 

2

該当箇所のコードを追記

2020/05/31 04:35

投稿

_3443_
_3443_

スコア5

test CHANGED
File without changes
test CHANGED
@@ -134,6 +134,20 @@
134
134
 
135
135
 
136
136
 
137
+ ```js
138
+
139
+ export const isSameDay = (d1, d2) => {
140
+
141
+ const format = "YYYYMMDD";
142
+
143
+ return d1.format(format) === d2.format(format);
144
+
145
+ };
146
+
147
+ ```
148
+
149
+
150
+
137
151
  ### 試したこと
138
152
 
139
153
 

1

該当箇所のコードを追記

2020/05/31 03:09

投稿

_3443_
_3443_

スコア5

test CHANGED
File without changes
test CHANGED
@@ -44,6 +44,96 @@
44
44
 
45
45
 
46
46
 
47
+ ```js
48
+
49
+ import { createCalendar } from "../../services/calendar";
50
+
51
+ import { connect } from "react-redux";
52
+
53
+ import CalendarBoard from "./presentation";
54
+
55
+ import {
56
+
57
+ addScheduleOpenDialog,
58
+
59
+ addScheduleSetValue
60
+
61
+ } from "../../redux/addSchedule/actions";
62
+
63
+ import { setSchedules } from "../../services/schedule";
64
+
65
+
66
+
67
+ const mapDispatchToProps = dispatch => ({
68
+
69
+ openAddScheduleDialog: d => {
70
+
71
+ dispatch(addScheduleOpenDialog());
72
+
73
+ dispatch(addScheduleSetValue({ date: d }));
74
+
75
+ }
76
+
77
+ });
78
+
79
+
80
+
81
+ const mapStateToProps = state => ({
82
+
83
+ calendar: state.calendar,
84
+
85
+ schedules: state.schedules
86
+
87
+ });
88
+
89
+
90
+
91
+ const mergeProps = (stateProps, dispatchProps) => {
92
+
93
+ const {
94
+
95
+ calendar: month,
96
+
97
+ schedules: { items: schedules }
98
+
99
+ } = stateProps;
100
+
101
+
102
+
103
+ const calendar = setSchedules(createCalendar(month), schedules);
104
+
105
+
106
+
107
+ return {
108
+
109
+ ...stateProps,
110
+
111
+ ...dispatchProps,
112
+
113
+ calendar,
114
+
115
+ month
116
+
117
+ };
118
+
119
+ };
120
+
121
+
122
+
123
+ export default connect(
124
+
125
+ mapStateToProps,
126
+
127
+ mapDispatchToProps,
128
+
129
+ mergeProps
130
+
131
+ )(CalendarBoard);
132
+
133
+ ```
134
+
135
+
136
+
47
137
  ### 試したこと
48
138
 
49
139