Skip to content

Commit

Permalink
Merge pull request #274 from UofA-Blueprint/fix/adminHome
Browse files Browse the repository at this point in the history
Admin homepage tests
  • Loading branch information
royayush1 authored Dec 16, 2023
2 parents dbcf28b + 7745c36 commit 7299187
Show file tree
Hide file tree
Showing 2 changed files with 389 additions and 20 deletions.
33 changes: 13 additions & 20 deletions app/src/routes/admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,31 @@ import leaf_white from "../assets/leaf-white.svg";
import axios from "axios";
import { useAuth } from "../contexts/AuthContext";



function dishStatus(dishNumbers: number[]) {

return(
<div className="d-flex">

<div className="admin-container" style={{position: 'relative'}}>
<img src={leaf_white} style={{position:'absolute', top:'16px', right:'16px'}}/>
<p className="header" style={{marginTop: 10}}>{dishNumbers[0]}</p>
<p className="header" style={{marginTop: 10}} data-testid="in-use">{dishNumbers[0]}</p>
<p className="sub-header-4">Currently in use</p>
</div>
<div className="admin-container" style={{position: 'relative'}}>
<img src={leaf_white} style={{position:'absolute', top:'16px', right:'16px'}}/>
<p className="header" style={{marginTop: 10}}>{dishNumbers[1]}</p>
<p className="header" style={{marginTop: 10}} data-testid="returned">{dishNumbers[1]}</p>
<p className="sub-header-4">Available</p>
</div>
<div className="admin-container" style={{position: 'relative'}}>
<img src={leaf_white} style={{position:'absolute', top:'16px', right:'16px'}}/>
<p className="header" style={{marginTop: 10}}>{dishNumbers[2]}</p>
<p className="sub-header-4">Overdue</p>
<p className="header" style={{marginTop: 10}} data-testid="overdue-count">{dishNumbers[2]}</p>
<p className="sub-header-4" data-testid="overdue-text">Overdue</p>
</div>
<div className="admin-container" style={{position: 'relative'}}>
<img src={leaf_white} style={{position:'absolute', top:'16px', right:'16px'}}/>
<p className="header" style={{marginTop: 10}}>{dishNumbers[3]}</p>
<p className="header" style={{marginTop: 10}} data-testid="lost-count">{dishNumbers[3]}</p>
<p className="sub-header-4">Dishes Lost</p>
</div>

</div>

);
}

Expand Down Expand Up @@ -87,14 +82,12 @@ function dishTable() {
<p style={{position: "absolute", marginLeft: '4%'}}>Dish ID</p>
<p style={{position: "absolute", marginLeft: '22%'}}>Dish type</p>
<p style={{position: "absolute", marginLeft: '41%'}}>Dish Status</p>
<p style={{position: "absolute", marginLeft: '65%'}}>Overdue</p>
<p style={{position: "absolute", marginLeft: '84%'}}>Email</p>
<p style={{position: "absolute", marginLeft: '65%'}} data-testid="overdue-table">Overdue</p>
<p style={{position: "absolute", marginLeft: '84%'}} data-testid="email-table">Email</p>
</div>
);
}



function findDish(ID, dishesUsed) {
if (ID == null) {
return('')
Expand Down Expand Up @@ -151,7 +144,7 @@ function createRows(dishesUsed, transactionsUsed) {
else {
dish = dish[0];
}
const id = dish.qid;
const id = dish.qid; // this is a number
const type = dish.type;
let email = '';
if(transaction.user == undefined) {
Expand Down Expand Up @@ -235,11 +228,11 @@ function Rows(tableRows, search) {
<div>
{records.map(row =>
<div className="row-container d-flex" style={{position: 'relative'}}>
<p style={{position: "absolute", marginLeft: '4%'}}>{row.id}</p>
<div style={{position: "absolute", marginLeft: '22%'}}>{dishTag(row.type)}</div>
<p style={{position: "absolute", marginLeft: '41%'}}>{dishTag(row.status)}</p>
<p style={{position: "absolute", marginLeft: '65%'}}>{row.overdue}</p>
<p style={{position: "absolute", marginLeft: '84%'}}>{row.email}</p>
<p style={{position: "absolute", marginLeft: '4%'}} data-testid={`row-${row.id}`}>{row.id}</p>
<div style={{position: "absolute", marginLeft: '22%'}} data-testid={`row-${row.type}`}>{dishTag(row.type)}</div>
<p style={{position: "absolute", marginLeft: '41%'}} data-testid={`row-${row.status}`}>{dishTag(row.status)}</p>
<p style={{position: "absolute", marginLeft: '65%'}} data-testid={`row-${row.overdue}`}>{row.overdue}</p>
<p style={{position: "absolute", marginLeft: '84%'}} data-testid={`row-${row.email}`}>{row.email}</p>
</div>
)}
</div>
Expand Down
Loading

0 comments on commit 7299187

Please sign in to comment.