Skip to content
Merged
10 changes: 2 additions & 8 deletions webdevadv/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion webdevadv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"electron-updater": "^6.8.9",
"react-router": "^8.5.2",
"react-router-dom": "^7.18.6",
"xlsx": "^0.18.5"
"xlsx": "^0.18.5",
"vitest": "^5.1.0"
},
"devDependencies": {
"@electron-toolkit/eslint-config": "^3.0.0",
Expand Down
28 changes: 0 additions & 28 deletions webdevadv/src/renderer/src/App.jsx

This file was deleted.

89 changes: 89 additions & 0 deletions webdevadv/src/renderer/src/Employees.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import './assets/globals.css';
import './assets/employees.css';
import { useEffect, useState } from 'react';

// Temporary sample data while the database is unavailable.
const employees = [
{ id: 1, employee_name: 'Alex Morgan', occupation: 'Server' },
{ id: 2, employee_name: 'Casey Rivera', occupation: 'Usher' },
{ id: 3, employee_name: 'Jordan Lee', occupation: 'Manager' },
{ id: 4, employee_name: 'Sam Patel', occupation: 'Cashier' },
{ id: 5, employee_name: 'Taylor Brooks', occupation: 'Projectionist' }
];

function Employees() {
// const [employees, setEmployees] = useState([]);
// const [loading, setLoading] = useState(true);
// const [error, setError] = useState('');

// useEffect(() => {
// let canceled = false;
// async function loadEmployees() {
// try {
// const result = await window.api.getEmployees();
// if (!result.ok) throw new Error(result.error);
// if (!canceled) setEmployees(result.employees);
// } catch (err) {
// if (!canceled) setError(err.message);
// } finally {
// if (!canceled) setLoading(false);
// }
// }
// loadEmployees();
// return () => { canceled = true; };
// }, []);

return (
<main className="employees-page">
<section className="employees-panel" aria-labelledby="employees-title">
<h1 id="employees-title">Employees</h1>
<div className="employees-toolbar">
<button className="employee-button employee-create-button" type="button">
Create Employee
</button>
</div>
<div className="employees-table-wrapper">
<table className="employees-table" aria-labelledby="employees-title">
<thead>
<tr>
<th scope="col">Employee Name</th>
<th scope="col">ID</th>
<th scope="col">Occupation</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
{employees.map((employee) => (
<tr key={employee.id}>
<th scope="row">{employee.employee_name}</th>
<td>{employee.id}</td>
<td>{employee.occupation}</td>
<td>
<div className="employee-row-actions">
<button
className="employee-button employee-edit-button"
type="button"
aria-label={`Edit ${employee.employee_name}`}
>
Edit
</button>
<button
className="employee-button employee-delete-button"
type="button"
aria-label={`Delete ${employee.employee_name}`}
>
Delete
</button>
</div>
</td>
</tr>
))}
</tbody>
</table>
</div>
</section>
</main>
)
}

export default Employees;
10 changes: 4 additions & 6 deletions webdevadv/src/renderer/src/Error404.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import './assets/app.css';
import React from 'react';
import './assets/error.css';

function Error404() {
const ipcHandle = () => window.electron.ipcRenderer.send('ping')

//This is the sign-in page for the scheduler application
return (
<>

<div >
Error404
</div>
<main className="error-container">
<h1>Error 404 - Page Not Found</h1>
</main>
</>
)
}
Expand Down
27 changes: 17 additions & 10 deletions webdevadv/src/renderer/src/Management.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import './assets/app.css';
import React from 'react';
import './assets/globals.css';
import './assets/management.css';
import { useNavigate } from 'react-router-dom';

function Management() {
const ipcHandle = () => window.electron.ipcRenderer.send('ping')
const navigate = useNavigate();

//This is the sign-in page for the scheduler application
return (
<>

<div >
Management
</div>
</>
<main className="management">
<button className="sign-out-button" type="button" onClick={() => navigate('/')}>
Sign Out
</button>

<div className="management-title">
<h1 id="management-title">Scheduler Portal</h1>
</div>
<div className="management-actions">
<button id="schedule-btn" type="button">Manage Schedule</button>
<button id="employee-btn" type="button" onClick={() => navigate('/employees')}>Manage Employees</button>
</div>
</main>
)
}

Expand Down
50 changes: 50 additions & 0 deletions webdevadv/src/renderer/src/SignIn.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { useRef } from 'react';
import './assets/globals.css';
import './assets/sign-in.css';
import { useNavigate } from 'react-router-dom';

const users = new Set([
JSON.stringify(['admin', '123']),
JSON.stringify(['1', '2']),
JSON.stringify(['david', '456'])
]);

// Sign in page
function SignIn() {
const ipcHandle = () => window.electron.ipcRenderer.send('ping');
const navigate = useNavigate();
const userRef = useRef(null);
const passwordRef = useRef(null);

const onSignIn = () => {
const username = userRef.current.value;
const password = passwordRef.current.value;

if (users.has(JSON.stringify([username, password]))) {
navigate('/management')
} else {
alert('Username or Password is incorrect!')
}
}

return (
<div className="sign-in-page">
<div className="container">
<div className="title">
<h1>Manager Portal</h1>
</div>

<div className="controls">
<input ref={userRef} type="text" name="username" placeholder="Username" />
<input ref={passwordRef} type="text" name="password" placeholder="Password" />

<button id="sign-in-button" onClick={onSignIn}>
Sign In
</button>
</div>
</div>
</div>
)
}

export default SignIn;
36 changes: 0 additions & 36 deletions webdevadv/src/renderer/src/assets/app.css

This file was deleted.

Loading
Loading