Skip to content

Commit 848d556

Browse files
Consolidate application feedback into the update payload, refine API base URL environment configuration, and upgrade to Yarn 4.
1 parent 7640cb1 commit 848d556

File tree

2 files changed

+6
-45
lines changed

2 files changed

+6
-45
lines changed

applications/script.js

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
showToast,
66
updateApplication,
77
getApplicationById,
8-
addApplicationFeedback,
98
} from './utils.js';
109
let nextLink;
1110
let isDataLoading = false;
@@ -127,31 +126,20 @@ function updateUserApplication({ isAccepted, isRequestChanges = false }) {
127126
}
128127

129128
const applicationStatus = isAccepted ? 'accepted' : 'rejected';
130-
const payload = { status: applicationStatus };
131-
132-
const promises = [];
133129
const feedback =
134130
applicationTextarea && applicationTextarea.value
135131
? applicationTextarea.value.trim()
136132
: '';
137133

134+
const payload = { status: applicationStatus };
138135
if (feedback) {
139-
promises.push(
140-
addApplicationFeedback(currentApplicationId, {
141-
feedback,
142-
status: applicationStatus,
143-
}),
144-
);
136+
payload.feedback = feedback;
145137
}
146138

147-
promises.push(
148-
updateApplication({
149-
applicationId: currentApplicationId,
150-
applicationPayload: payload,
151-
}),
152-
);
153-
154-
Promise.all(promises)
139+
updateApplication({
140+
applicationId: currentApplicationId,
141+
applicationPayload: payload,
142+
})
155143
.then(() => {
156144
showToastMessage({
157145
isDev,

applications/utils.js

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -117,32 +117,6 @@ async function updateApplication({ applicationPayload, applicationId }) {
117117
}
118118
}
119119

120-
async function addApplicationFeedback(applicationId, feedbackData) {
121-
try {
122-
const res = await fetch(
123-
`${BASE_URL}/applications/${applicationId}/feedback`,
124-
{
125-
method: 'PATCH',
126-
credentials: 'include',
127-
body: JSON.stringify(feedbackData),
128-
headers: {
129-
'Content-type': 'application/json',
130-
},
131-
},
132-
);
133-
134-
if (!res.ok) {
135-
const error = await res.json();
136-
throw error;
137-
}
138-
139-
const data = await res.json();
140-
return data;
141-
} catch (error) {
142-
throw error;
143-
}
144-
}
145-
146120
function showToast({ message, type }) {
147121
toast.innerText = message;
148122

@@ -168,7 +142,6 @@ export {
168142
getApplications,
169143
getApplicationById,
170144
updateApplication,
171-
addApplicationFeedback,
172145
getIsSuperUser,
173146
showToast,
174147
};

0 commit comments

Comments
 (0)