Skip to content

Commit

Permalink
fixing syntax and indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Latifa Al-Hitmi authored and Latifa Al-Hitmi committed Oct 19, 2024
1 parent fcdfdbe commit 795a0b5
Showing 1 changed file with 56 additions and 56 deletions.
112 changes: 56 additions & 56 deletions public/src/admin/dashboard/bug-logs.js
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
'use strict';

define('admin/dashboard/bug-logs', ['jquery', 'api'], ($, api) => {
const BugLogs = {};

BugLogs.init = () => {
// Fetch and display bug logs
fetchBugLogs();

// Handle bug report submission
$('#submit-bug-report').on('click', submitBugReport);
};

function fetchBugLogs() {
api.get('/api/admin/get-bug-log')
.then((data) => {
const bugLogsContainer = $('#bug-logs-container');
bugLogsContainer.empty();

if (data.bugLogs && data.bugLogs.length > 0) {
data.bugLogs.forEach((log) => {
const logElement = $('<div>').addClass('bug-log');
logElement.append($('<p>').text(`User: ${log.user}`));
logElement.append($('<p>').text(`Description: ${log.description}`));
logElement.append($('<p>').text(`Timestamp: ${log.timestamp}`));
bugLogsContainer.append(logElement);
});
} else {
bugLogsContainer.append($('<p>').text('No bug logs found.'));
}
})
.catch((err) => {
console.error('Error fetching bug logs:', err);
$('#bug-logs-container').append($('<p>').text('Error fetching bug logs.'));
});
}

function submitBugReport() {
const description = $('#bug-report-description').val().trim();

if (!description) {
alert('Description is required');
return;
}

api.post('/api/admin/submit-bug-report', { description })
.then(() => {
alert('Bug report submitted successfully');
$('#bug-report-description').val('');
fetchBugLogs();
})
.catch((err) => {
console.error('Error submitting bug report:', err);
alert('Error submitting bug report');
});
}

return BugLogs;
});
const BugLogs = {};

BugLogs.init = () => {
// Fetch and display bug logs
fetchBugLogs();

// Handle bug report submission
$('#submit-bug-report').on('click', submitBugReport);
};

function fetchBugLogs() {
api.get('/api/admin/get-bug-log')
.then((data) => {
const bugLogsContainer = $('#bug-logs-container');
bugLogsContainer.empty();

if (data.bugLogs && data.bugLogs.length > 0) {
data.bugLogs.forEach((log) => {
const logElement = $('<div>').addClass('bug-log');
logElement.append($('<p>').text(`User: ${log.user}`));
logElement.append($('<p>').text(`Description: ${log.description}`));
logElement.append($('<p>').text(`Timestamp: ${log.timestamp}`));
bugLogsContainer.append(logElement);
});
} else {
bugLogsContainer.append($('<p>').text('No bug logs found.'));
}
})
.catch((err) => {
console.error('Error fetching bug logs:', err);
$('#bug-logs-container').append($('<p>').text('Error fetching bug logs.'));
});
}

function submitBugReport() {
const description = $('#bug-report-description').val().trim();

if (!description) {
alert('Description is required');

Check warning on line 42 in public/src/admin/dashboard/bug-logs.js

View workflow job for this annotation

GitHub Actions / test

Unexpected alert
return;
}

api.post('/api/admin/submit-bug-report', { description })
.then(() => {
alert('Bug report submitted successfully');

Check warning on line 48 in public/src/admin/dashboard/bug-logs.js

View workflow job for this annotation

GitHub Actions / test

Unexpected alert
$('#bug-report-description').val('');
fetchBugLogs();
})
.catch((err) => {
console.error('Error submitting bug report:', err);
alert('Error submitting bug report');

Check warning on line 54 in public/src/admin/dashboard/bug-logs.js

View workflow job for this annotation

GitHub Actions / test

Unexpected alert
});
}

return BugLogs;
});

0 comments on commit 795a0b5

Please sign in to comment.