Skip to content

Commit

Permalink
auto-close report question modal
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffrey-wu committed Jan 5, 2023
1 parent 8b98710 commit 8941cb8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion client/database/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ <h5 class="modal-title">Report Question</h5>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" data-bs-dismiss="modal" type="button">Close</button>
<button class="btn btn-secondary" id="report-question-close" data-bs-dismiss="modal" type="button">Close</button>
<button class="btn btn-primary" id="report-question-submit" type="button">Submit</button>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion client/multiplayer/room.html
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ <h5 class="modal-title">Report Question</h5>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" data-bs-dismiss="modal" type="button">Close</button>
<button class="btn btn-secondary" id="report-question-close" data-bs-dismiss="modal" type="button">Close</button>
<button class="btn btn-primary" id="report-question-submit" type="button">Submit</button>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion client/singleplayer/bonuses.html
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ <h5 class="modal-title">Report Question</h5>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" data-bs-dismiss="modal" type="button">Close</button>
<button class="btn btn-secondary" id="report-question-close" data-bs-dismiss="modal" type="button">Close</button>
<button class="btn btn-primary" id="report-question-submit" type="button">Submit</button>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion client/singleplayer/tossups.html
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ <h5 class="modal-title">Report Question</h5>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" data-bs-dismiss="modal" type="button">Close</button>
<button class="btn btn-secondary" id="report-question-close" data-bs-dismiss="modal" type="button">Close</button>
<button class="btn btn-primary" id="report-question-submit" type="button">Submit</button>
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions client/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,16 +239,13 @@ function rangeToArray(string, max = 0) {


function reportQuestion(_id, reason = '', description = '') {
document.getElementById('report-question-submit').disabled = true;
fetch('/api/report-question', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
_id: _id,
reason: reason,
description: description
})
body: JSON.stringify({ _id, reason, description })
}).then(response => {
if (response.status === 200) {
alert('Question has been reported.');
Expand All @@ -257,6 +254,9 @@ function reportQuestion(_id, reason = '', description = '') {
}
}).catch(error => {
alert('There was an error reporting the question.');
}).finally(() => {
document.getElementById('report-question-close').click();
document.getElementById('report-question-submit').disabled = false;
});
}

Expand Down

0 comments on commit 8941cb8

Please sign in to comment.