Skip to content

Commit a958753

Browse files
committed
Update counter display for comment and reservation
1 parent 4b99574 commit a958753

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/modules/render/comments.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,16 @@ const commentModal = (meal) => {
105105
API.postComment(
106106
meal.idMeal,
107107
commenterName.value,
108-
commenterMessage.value,
108+
commenterMessage.value
109109
).then(() => {
110110
if (commentUl.hasChildNodes()) {
111111
commentUl.innerHTML = '';
112112
API.getComments(meal.idMeal).then((data) => {
113113
if (data === 'No comments available for this meal') {
114114
commentUl.innerHTML = `<li class="no-comments">${`${data}. Add a new comment`}</li>`;
115115
} else {
116+
const commentCounter = counter.comments(data);
117+
allCommentsTitle.innerText = `All Comments(${commentCounter})`;
116118
data.forEach((userComment) => {
117119
displayComments(commentUl, userComment);
118120
});
@@ -127,4 +129,4 @@ const commentModal = (meal) => {
127129
modal.appendChild(modalInner);
128130
};
129131

130-
export default commentModal;
132+
export default commentModal;

src/modules/render/reservation.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,16 @@ const reserveModal = (meal) => {
162162
meal.idMeal,
163163
inputReserveName.value,
164164
inputReserveStartDate.value,
165-
inputReserveEndDate.value,
165+
inputReserveEndDate.value
166166
).then(() => {
167167
if (reservationList.hasChildNodes()) {
168168
reservationList.innerHTML = '';
169169
API.getReservations(meal.idMeal).then((data) => {
170170
if (data === 'No reservations available for this meal') {
171171
reservationList.innerHTML = `<li class='no-comments'>${`${data}. Add a new reservation`}</li>`;
172172
} else {
173+
const reservationCounter = counter.reservation(data);
174+
sectionTitleHeader.innerHTML = `Reservations(${reservationCounter})`;
173175
data.forEach((userReservation) => {
174176
displayReservations(reservationList, userReservation);
175177
});

0 commit comments

Comments
 (0)