Skip to content

Commit c64a114

Browse files
committed
Fixed incorrect kudos action after edit.
1 parent 7d905d1 commit c64a114

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

web-ui/src/pages/ManageKudosPage.jsx

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,29 @@ const ManageKudosPage = () => {
112112
setPendingKudos(sortPendingKudos([...pendingKudos]));
113113
}, [pendingSort]);
114114

115+
const loadAndSetPendingKudos = () => {
116+
loadPendingKudos().then(data => {
117+
if (data) {
118+
setPendingKudos(sortPendingKudos(data));
119+
}
120+
});
121+
};
122+
123+
const loadAndSetApprovedKudos = () => {
124+
loadApprovedKudos().then(data => {
125+
if (data) {
126+
setApprovedKudos(data);
127+
}
128+
});
129+
};
130+
115131
const handleTabChange = useCallback((event, newTab) => {
116132
switch (newTab) {
117133
case "PENDING":
118-
loadPendingKudos().then(data => {
119-
if (data) {
120-
setPendingKudos(sortPendingKudos(data));
121-
}
122-
});
134+
loadAndSetPendingKudos();
123135
break;
124136
case "APPROVED":
125-
loadApprovedKudos().then(data => {
126-
if (data) {
127-
setApprovedKudos(data);
128-
}
129-
});
137+
loadAndSetApprovedKudos();
130138
break;
131139
default:
132140
console.warn(`Invalid tab: ${newTab}`);
@@ -210,10 +218,7 @@ const ManageKudosPage = () => {
210218
kudos={k}
211219
includeActions
212220
includeEdit
213-
onKudosAction={() => {
214-
const updatedKudos = pendingKudos.filter(pk => pk.id !== k.id);
215-
setPendingKudos(updatedKudos);
216-
}}
221+
onKudosAction={loadAndSetPendingKudos}
217222
/>
218223
)}
219224
</div>

0 commit comments

Comments
 (0)