This commit is contained in:
Steven Tracey 2025-07-14 22:09:36 -04:00
parent 94c7412081
commit a08c4708e2
7 changed files with 126 additions and 39 deletions

View File

@ -1,19 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<?php include $_SERVER['DOCUMENT_ROOT']."/snippets/head.php" ?>
<body>
<?php include $_SERVER['DOCUMENT_ROOT'].'/snippets/header.php' ?>
<div class="container">
<div class="content flex-vertical">
<div class="section-one">
<h1>Error</h1>
<p>Please report the following to Steven</p>
<p>{{ .error }}</p>
</div>
</div>
</div>
<?php include $_SERVER['DOCUMENT_ROOT'].'/snippets/footer.php' ?>
</body>
</html>

View File

@ -1,14 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<?php include $_SERVER['DOCUMENT_ROOT']."/snippets/head.php" ?>
<?php include $_SERVER['DOCUMENT_ROOT']."/snippets/head.php"; ?>
<body>
<?php include $_SERVER['DOCUMENT_ROOT']."/snippets/header.php" ?>
<?php include $_SERVER['DOCUMENT_ROOT']."/snippets/header.php"; ?>
<div class="container">
<div class="content flex-vertical">
<div class="section-one">
<h1>Unauthorized</h1>
<p>Maybe you had the wrong code?</p>
<h1>{{ .header }}</h1>
<p>{{ .body }}</p>
</div>
</div>
</div>

View File

@ -9,15 +9,44 @@
<div class="section-one">
<h1>Registration</h1>
</div>
<div class="section-two flex-vertical align-left">
<form> <!-- TODO Make these stack vertically -->
<label>Registration Code</label>
<label>Name</label>
<div class="section-two">
<form id="reg-form" accept-charset="UTF-8" action="/api/register" method="post">
<div class="inputs">
<div class="flex flex-vertical">
<label class="label-left" for="name">Name</label>
<input id="name" name="name" type="text" placeholder="John Doe">
<label class="label-left" for="user-id">User ID</label>
<input id="user-id" name="user-id" type="text" placeholder="jdoe">
<label class="label-left" for="email">Email Address</label>
<input id="email" name="email" type="text" placeholder="johndoe@example.com">
<label class="label-left" for="phone-number">Phone Number</label>
<input id="phone-number" name="phone-number" type="text" placeholder="+1(212)555-1234">
<label class="label-left" for="registration_code">Registration Code</label>
<input id="registration_code" name="registration_code" type="text" placeholder="xxxxxxxx">
<p id="msg-box"></p>
</div>
<div class="flex flex-vertical">
<label class="label-left" for="street1">Street Line 1</label>
<input id="street1" name="street1" type="text" placeholder="123 Main Street">
<label class="label-left" for="street2">Street Line 2</label>
<input id="street2" name="street2" type="text" placeholder="(Optional)">
<label class="label-left" for="city">City</label>
<input id="city" name="city" type="text" placeholder="Anytown">
<label class="label-left" for="state">State</label>
<input id="state" name="state" type="text" placeholder="New York">
<label class="label-left" for="postal-code">Postal Code</label>
<input id="postal-code" name="postal-code" type="text" placeholder="12345">
<label class="label-left" for="country">Country</label>
<input id="country" name="country" type="text" placeholder="United States">
</div>
</div>
<input class="btn" type="submit" value="Register">
</form>
</div>
</div>
</div>
<?php include $_SERVER['DOCUMENT_ROOT']."/snippets/footer.php" ?>
<script src="/static/register.js"></script>
</body>
</html>

View File

@ -1,7 +1,9 @@
<?php ?>
<header class="header">
<img class="header-icon" src="/static/icon.png" alt="icon"/>
<a class="icon-link" href="/">
<img class="header-icon" src="/static/icon.png" alt="icon"/>
</a>
<h1 class="title">My Luggage Info</h1>
<div class="spacer"></div>
</header>

29
static/register.js Normal file
View File

@ -0,0 +1,29 @@
const form = document.getElementById("reg-form"); // Replace #my-form with your form's ID
form.addEventListener("submit", async (event) => {
event.preventDefault();
let userId = document.getElementById("user-id").value;
let msgBox = document.getElementById("msg-box");
try {
const response = await fetch(`/api/checkname/${userId}`, {
method: "GET",
});
if (response.status === 409) {
msgBox.innerText = "Entry with id \"" + userId + "\" already in use";
return;
} else if (!response.ok) {
throw new Error(`Server Error: ${response.status}`);
}
const data = await response.json();
console.log("Fetch successful:", data);
form.submit();
} catch (error) {
console.error("Fetch failed:", error);
msgBox.innerText = "Internal Error: " + error;
}
});

View File

@ -33,9 +33,8 @@
.header-icon {
display: block;
flex: 0 0 72px;
width: 20vw;
height: auto;
max-height: 85px;
width: 85px;
height: 85px;
}
.footer {
@ -51,7 +50,7 @@
max-width: 800px;
padding: 1.5rem;
background: white;
border-radius: 5px;
border-radius: 15px;
text-align: center;
}
@ -59,7 +58,7 @@
font-size: 16px;
}
.content button {
.btn {
color: var(--dark);
background-color: var(--light);
border-radius: 8px;
@ -76,6 +75,20 @@
align-items: flex-start;
margin-left: 5vw;
}
.inputs {
display: flex;
flex: 1 0 auto;
flex-direction: column;
}
.inputs div {
flex: 1 0 auto;
}
.inputs input {
margin-bottom: 10px;
}
}
@media only screen and (min-width: 700px) {
@ -100,12 +113,15 @@
flex: 0 0 64px;
}
.icon-link {
display: flex;
}
.header-icon {
display: block;
flex: 0 0 64px;
width: 15vw;
height: auto;
max-height: 80px;
width: 80px;
height: 80px;
}
.footer {
@ -129,7 +145,7 @@
font-size: 16px;
}
.content button {
.btn {
color: var(--dark);
background-color: var(--light);
border-radius: 8px;
@ -146,6 +162,22 @@
align-items: flex-start;
margin-left: 5vw;
}
.inputs {
display: flex;
flex: 1 0 auto;
flex-direction: row;
justify-content: space-between;
column-gap: 5vw;
}
.inputs div {
flex: 1 0 auto;
}
.inputs input {
margin-bottom: 10px;
}
}
.title {
@ -221,11 +253,17 @@
background-color: var(--dark-click);
}
.flex {
display: flex;
}
.flex-vertical {
/*display: flex;*/
flex-direction: column;
}
.flex-horizontal {
/*display: flex;*/
flex-direction: row;
}
@ -242,6 +280,14 @@
flex: 1 0 auto;
}
.label-left {
text-align: left;
}
#reg-form {
flex: 1 0 auto;
}
#status {
margin-bottom: 0;
}

View File

@ -9,10 +9,10 @@
<div class="section-one flex-horizontal">
<label for="code">Secret Code (SC):</label>
<input id="code" type="text">
<button id="submitBtn">Submit</button>
<button id="submitBtn" class="btn">Submit</button>
</div>
<div class="section-two flex-vertical">
<p id="status" class="hidden">Text</p>
<p id="status" class="hidden"></p>
</div>
</div>
</div>