質問編集履歴
1
該当のコンポーネントの全ソースコード記載しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,7 +40,7 @@
|
|
40
40
|
|
41
41
|
const incomeAmounts = incomeItems.map(incomeItem => incomeItem.amount);
|
42
42
|
|
43
|
-
|
43
|
+
|
44
44
|
|
45
45
|
const incomeTotal = incomeAmounts.reduce((acc, cur) => {
|
46
46
|
|
@@ -50,7 +50,31 @@
|
|
50
50
|
|
51
51
|
|
52
52
|
|
53
|
+
return (
|
54
|
+
|
55
|
+
<div>
|
56
|
+
|
57
|
+
<div>
|
58
|
+
|
59
|
+
<h4>Income</h4>
|
60
|
+
|
53
|
-
|
61
|
+
<p>{incomeTotal}</p>
|
62
|
+
|
63
|
+
</div>
|
64
|
+
|
65
|
+
<div>
|
66
|
+
|
67
|
+
<h4>Expense</h4>
|
68
|
+
|
69
|
+
<p>-5,000円</p>
|
70
|
+
|
71
|
+
</div>
|
72
|
+
|
73
|
+
</div>
|
74
|
+
|
75
|
+
)
|
76
|
+
|
77
|
+
}
|
54
78
|
|
55
79
|
```
|
56
80
|
|
@@ -168,6 +192,114 @@
|
|
168
192
|
|
169
193
|
|
170
194
|
|
195
|
+
Home.js
|
196
|
+
|
197
|
+
```JavaScript
|
198
|
+
|
199
|
+
import React, {useState} from 'react';
|
200
|
+
|
201
|
+
import { app } from "../firebase/Firebase";
|
202
|
+
|
203
|
+
import { Header } from './Header';
|
204
|
+
|
205
|
+
import { Balance } from './Balance';
|
206
|
+
|
207
|
+
import { IncomeExpense } from './IncomeExpense';
|
208
|
+
|
209
|
+
import { AddItem } from './AddItem';
|
210
|
+
|
211
|
+
import { ItemsList } from './ItemsList';
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
function Home (props) {
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
const [inputText, setInputText] = useState("");
|
220
|
+
|
221
|
+
const [inputAmount, setInputAmount] = useState(0);
|
222
|
+
|
223
|
+
const [incomeItems, setIncomeItems] = useState([]);
|
224
|
+
|
225
|
+
const [expenseItems, setExpenseItems] = useState([]);
|
226
|
+
|
227
|
+
const [type, setType] = useState("inc");
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
return (
|
232
|
+
|
233
|
+
<div>
|
234
|
+
|
235
|
+
<Header />
|
236
|
+
|
237
|
+
<Balance />
|
238
|
+
|
239
|
+
<IncomeExpense
|
240
|
+
|
241
|
+
incomeItems={incomeItems}
|
242
|
+
|
243
|
+
expenseItems={expenseItems}
|
244
|
+
|
245
|
+
/>
|
246
|
+
|
247
|
+
<AddItem
|
248
|
+
|
249
|
+
inputText={inputText}
|
250
|
+
|
251
|
+
setInputText={setInputText}
|
252
|
+
|
253
|
+
inputAmount={inputAmount}
|
254
|
+
|
255
|
+
setInputAmount={setInputAmount}
|
256
|
+
|
257
|
+
incomeItems={incomeItems}
|
258
|
+
|
259
|
+
setIncomeItems={setIncomeItems}
|
260
|
+
|
261
|
+
expenseItems={expenseItems}
|
262
|
+
|
263
|
+
setExpenseItems={setExpenseItems}
|
264
|
+
|
265
|
+
type={type}
|
266
|
+
|
267
|
+
setType={setType}
|
268
|
+
|
269
|
+
/>
|
270
|
+
|
271
|
+
<ItemsList
|
272
|
+
|
273
|
+
incomeItems={incomeItems}
|
274
|
+
|
275
|
+
setIncomeItems={setIncomeItems}
|
276
|
+
|
277
|
+
expenseItems={expenseItems}
|
278
|
+
|
279
|
+
setExpenseItems={setExpenseItems}
|
280
|
+
|
281
|
+
/>
|
282
|
+
|
283
|
+
<button onClick={() => app.auth().signOut()}>log out</button>
|
284
|
+
|
285
|
+
</div>
|
286
|
+
|
287
|
+
)
|
288
|
+
|
289
|
+
}
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
export default Home;
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
```
|
300
|
+
|
301
|
+
|
302
|
+
|
171
303
|
### 試したこと
|
172
304
|
|
173
305
|
|