|
1 | 1 | import React, { useState } from "react"; |
2 | 2 | import BrutalismButton from "../BrutalismButton"; |
3 | 3 | import { FormattedMessage } from "react-intl"; |
| 4 | +import changeIndividualMergeState from "../../models/notifications/changeIndividualMergeState"; |
4 | 5 |
|
5 | 6 | export default function MergeMessages({ |
6 | 7 | mergeData, |
7 | 8 | getAllNotifications, |
8 | 9 | setModalOpen, |
9 | 10 | }) { |
10 | | - const handleClick = () => { |
11 | | - // const result = changeIndividualMergeState(action, taskId); |
12 | | - // setError('Error: ' + result); |
13 | | - getAllNotifications(); |
14 | | - setModalOpen(false); |
| 11 | + const [error, setError] = useState(false); |
| 12 | + const handleClick = async (action, taskId) => { |
| 13 | + const result = await changeIndividualMergeState(action, taskId); |
| 14 | + if (result.status === 200) { |
| 15 | + getAllNotifications(); |
| 16 | + setModalOpen(false); |
| 17 | + } else { |
| 18 | + setError(true); |
| 19 | + } |
15 | 20 | }; |
16 | 21 |
|
17 | | - // eslint-disable-next-line no-unused-vars |
18 | | - const [showError, setShowError] = useState(false); |
19 | | - // eslint-disable-next-line no-unused-vars |
20 | | - const [error, setError] = useState(""); |
21 | | - |
22 | 22 | const content = mergeData?.map((data) => { |
23 | 23 | const mergePending = data.notificationType === "mergePending"; |
24 | 24 | const mergeComplete = data.notificationType === "mergeComplete"; |
@@ -103,7 +103,6 @@ export default function MergeMessages({ |
103 | 103 | display: "flex", |
104 | 104 | marginTop: "10px", |
105 | 105 | marginBottom: "10px", |
106 | | - // width: 105 |
107 | 106 | }} |
108 | 107 | > |
109 | 108 | <BrutalismButton onClick={() => handleClick("ignore", data.taskId)}> |
@@ -167,7 +166,11 @@ export default function MergeMessages({ |
167 | 166 | </h4> |
168 | 167 | )} |
169 | 168 | {content} |
170 | | - {showError && <h6>{error}</h6>} |
| 169 | + {error && ( |
| 170 | + <h4> |
| 171 | + <FormattedMessage id="BEERROR_UNKNOWN" /> |
| 172 | + </h4> |
| 173 | + )} |
171 | 174 | </div> |
172 | 175 | ); |
173 | 176 | } |
0 commit comments