Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve layout and colour scheme of admin page #81

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified readme/adminpage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 4 additions & 10 deletions src/components/Row.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,16 @@ export const Row = ({ item }) => {
<td>{timeLeft}</td>
<td>
<button
className="btn btn-primary me-3"
className="btn btn-warning me-3"
onClick={() => editItems(item.id, true, false)}
>
Update
Update item
</button>
<button
className="btn btn-primary me-3"
className="btn btn-danger me-3"
onClick={() => editItems(item.id, false, true)}
>
Reset
</button>
<button
className="btn btn-primary"
onClick={() => editItems(item.id, true, true)}
>
Update & Reset
Delete bids
</button>
</td>
</tr>
Expand Down
6 changes: 3 additions & 3 deletions src/firebase/utils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const unflattenItems = (doc, demo) => {
return Object.values(items);
};

export const editItems = (id = undefined, update = false, reset = false) => {
export const editItems = (id = undefined, updateItems = false, deleteBids = false) => {
fetch(import.meta.env.BASE_URL + "items.yml")
.then((response) => response.text())
.then((text) => yaml.load(text))
Expand All @@ -69,9 +69,9 @@ export const editItems = (id = undefined, update = false, reset = false) => {
fields
.filter((field) => parseField(field).item === newItem.id)
.forEach((field) => {
if (update && parseField(field).bid === 0)
if (updateItems && parseField(field).bid === 0)
updates[field] = newItem;
if (reset && parseField(field).bid)
if (deleteBids && parseField(field).bid)
updates[field] = deleteField();
});
});
Expand Down
20 changes: 7 additions & 13 deletions src/pages/Admin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,18 @@ import Table from "../components/Table";
function AdminPage() {
return (
<div className="container mt-3">
<div className="d-flex justify-content-between mb-3">
<div className="d-flex justify-content-left mb-3">
<button
className="btn btn-primary me-3"
className="btn btn-danger me-3"
onClick={() => editItems(undefined, true, false)}
>
Update All
>
Update all items
</button>
<button
className="btn btn-primary me-3"
className="btn btn-danger me-3"
onClick={() => editItems(undefined, false, true)}
>
Reset All
</button>
<button
className="btn btn-primary"
onClick={() => editItems(undefined, true, true)}
>
Update & Reset All
>
Delete all bids
</button>
</div>
<Table />
Expand Down
Loading