Skip to content

Commit

Permalink
fixing syntax
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 29205c1 commit fcdfdbe
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 57 deletions.
110 changes: 55 additions & 55 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 = {};

Check failure on line 4 in public/src/admin/dashboard/bug-logs.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 1 tab but found 4 spaces

BugLogs.init = () => {

Check failure on line 6 in public/src/admin/dashboard/bug-logs.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 1 tab but found 4 spaces
// Fetch and display bug logs

Check failure on line 7 in public/src/admin/dashboard/bug-logs.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 2 tabs but found 8 spaces
fetchBugLogs();

Check failure on line 8 in public/src/admin/dashboard/bug-logs.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 2 tabs but found 8 spaces

// Handle bug report submission

Check failure on line 10 in public/src/admin/dashboard/bug-logs.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 2 tabs but found 8 spaces
$('#submit-bug-report').on('click', submitBugReport);

Check failure on line 11 in public/src/admin/dashboard/bug-logs.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 2 tabs but found 8 spaces
};

Check failure on line 12 in public/src/admin/dashboard/bug-logs.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 1 tab but found 4 spaces

function fetchBugLogs() {

Check failure on line 14 in public/src/admin/dashboard/bug-logs.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 1 tab but found 4 spaces
api.get('/api/admin/get-bug-log')

Check failure on line 15 in public/src/admin/dashboard/bug-logs.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 2 tabs but found 8 spaces
.then((data) => {

Check failure on line 16 in public/src/admin/dashboard/bug-logs.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 3 tabs but found 12 spaces
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;
});
2 changes: 1 addition & 1 deletion src/controllers/admin/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,4 +430,4 @@ dashboardController.submitBugReport = async function (req, res) {
console.error('Error submitting bug report:', error); // Log the error for debugging
res.status(500).json({ message: 'Internal server error' });
}
};
};
2 changes: 1 addition & 1 deletion src/routes/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ function apiRoutes(router, name, middleware, controllers) {
router.post(`/api/${name}/uploadOgImage`, middlewares, helpers.tryRoute(controllers.admin.uploads.uploadOgImage));
router.post(`/api/${name}/upload/file`, middlewares, helpers.tryRoute(controllers.admin.uploads.uploadFile));
router.post(`/api/${name}/uploadDefaultAvatar`, middlewares, helpers.tryRoute(controllers.admin.uploads.uploadDefaultAvatar));
}
}

0 comments on commit fcdfdbe

Please sign in to comment.