Skip to content

Commit

Permalink
fixed errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron383 committed Sep 30, 2023
1 parent 1f7e5c2 commit 0015d5b
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions app/src/routes/admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ function findDish(ID, dishesUsed) {
function findOverdue(dishesUsed, transactionsUsed) {
const transactions = transactionsUsed.filter(transaction => transaction.returned.timestamp == "");
const timeToday = new Date();
var num = 0;
let num = 0;
transactions.map(transaction =>
{
var time = transaction.timestamp.slice(0,10);
let time = transaction.timestamp.slice(0,10);
time = new Date(time);
var difference = (timeToday.getTime() - time.getTime()) / 86400000;
let difference = (timeToday.getTime() - time.getTime()) / 86400000;
difference = parseInt(difference.toString());
if (difference > 2) {
num += 1;
Expand All @@ -125,12 +125,12 @@ function findOverdue(dishesUsed, transactionsUsed) {
function findLost(dishesUsed, transactionsUsed) {
const transactions = transactionsUsed.filter(transaction => transaction.returned.timestamp == "");
const timeToday = new Date();
var num = 0;
let num = 0;
transactions.map(transaction =>
{
var time = transaction.timestamp.slice(0,10);
let time = transaction.timestamp.slice(0,10);
time = new Date(time);
var difference = (timeToday.getTime() - time.getTime()) / 86400000;
let difference = (timeToday.getTime() - time.getTime()) / 86400000;
difference = parseInt(difference.toString());
if (difference >=30) {
num += 1;
Expand All @@ -150,29 +150,28 @@ function createRows(dishesUsed, transactionsUsed) {
else {
dish = dish[0];
}
let id = dish.qid;
let type = dish.type;
const id = dish.qid;
const type = dish.type;
let email = '';
if(transaction.user == undefined) {
email = 'NULL';
}
else {
email = transaction.user.email;
}
let lost = '';
var status = '';
let status = '';
let overdue = '';
var timestamp;
let timestamp;
if (transaction.returned.timestamp != '') {
timestamp = transaction.returned.timestamp;
}
else {
timestamp = transaction.timestamp;
}
if (transaction.returned.timestamp == "") {
var time = transaction.timestamp.slice(0,10);
let time = transaction.timestamp.slice(0,10);
time = new Date(time);
var difference = (timeToday.getTime() - time.getTime()) / 86400000;
let difference = (timeToday.getTime() - time.getTime()) / 86400000;
difference = parseInt(difference.toString());
if (difference >= 30) {
status = 'lost'
Expand Down Expand Up @@ -340,13 +339,13 @@ function Admin() {
const lost = findLost(dishesUsed, transactionsUsed);
const overdue = findOverdue(dishesUsed, transactionsUsed) - lost;

let dishNumbers = [numBorrowedDishes, returnedDishes, overdue, lost];
const dishNumbers = [numBorrowedDishes, returnedDishes, overdue, lost];
let tableRows = createRows(dishesUsed, transactionsUsed);
tableRows = sortRows(tableRows);
let row = Rows(tableRows, searchValue);
let bar = dishStatus(dishNumbers);
let table = dishTable();
let add = addDish();
const row = Rows(tableRows, searchValue);
const bar = dishStatus(dishNumbers);
const table = dishTable();
const add = addDish();


return (
Expand Down

0 comments on commit 0015d5b

Please sign in to comment.