Skip to content

Commit df944b0

Browse files
committed
enable ignore and deny merge request in react
1 parent 7548632 commit df944b0

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

frontend/src/components/navBar/MergeMessages.jsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
import React, { useState } from "react";
22
import BrutalismButton from "../BrutalismButton";
33
import { FormattedMessage } from "react-intl";
4+
import changeIndividualMergeState from "../../models/notifications/changeIndividualMergeState";
45

56
export default function MergeMessages({
67
mergeData,
78
getAllNotifications,
89
setModalOpen,
910
}) {
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+
}
1520
};
1621

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-
2222
const content = mergeData?.map((data) => {
2323
const mergePending = data.notificationType === "mergePending";
2424
const mergeComplete = data.notificationType === "mergeComplete";
@@ -103,7 +103,6 @@ export default function MergeMessages({
103103
display: "flex",
104104
marginTop: "10px",
105105
marginBottom: "10px",
106-
// width: 105
107106
}}
108107
>
109108
<BrutalismButton onClick={() => handleClick("ignore", data.taskId)}>
@@ -167,7 +166,11 @@ export default function MergeMessages({
167166
</h4>
168167
)}
169168
{content}
170-
{showError && <h6>{error}</h6>}
169+
{error && (
170+
<h4>
171+
<FormattedMessage id="BEERROR_UNKNOWN" />
172+
</h4>
173+
)}
171174
</div>
172175
);
173176
}
Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1-
import axios from 'axios';
1+
import axios from "axios";
22

33
export default async function changeIndividualMergeState(action, mergeId) {
4+
let json = {};
5+
json["mergeId"] = mergeId;
6+
json["action"] = action;
47

5-
let json = {};
6-
json['mergeId'] = mergeId;
7-
json['action'] = action;
8-
9-
console.log("Trying to change individual merge state on mergeId "+mergeId+" to "+action+".");
10-
11-
const response = await axios.post('/ScheduledIndividualMergeUpdate', json, {
12-
headers: {
13-
'Content-Type': 'application/json'
14-
}
8+
try {
9+
const response = await axios.post("/ScheduledIndividualMergeUpdate", json, {
10+
headers: {
11+
"Content-Type": "application/json",
12+
},
1513
});
16-
17-
console.log('changeIndividualMergeState result:', response.json());
18-
19-
return response.json();
20-
21-
}
14+
return response;
15+
} catch (error) {
16+
return error;
17+
}
18+
}

0 commit comments

Comments
 (0)