[feat] Implement per device addons

This commit is contained in:
WovenCoast 2024-02-14 16:59:01 +05:00
parent 0d7257a47e
commit 09b83a6c97
Signed by: flamexode
GPG Key ID: BB7D370708288E23
6 changed files with 656 additions and 673 deletions

2
.gitignore vendored
View File

@ -129,7 +129,7 @@ dist
.yarn/install-state.gz
.pnp.*
sarlink.jpg
sarlink*
uploads/

View File

@ -1,10 +1,10 @@
# SAR Link Customer Registration form.
## Todo
- [ ] Implement per device addons.
- [ ] Add all devices and their corresponding addons.
- [x] Implement per device addons.
- [x] Add all devices and their corresponding addons.
- [ ] Generate a connection request receipt including all information entered by the user.
- [ ] Incorporate a step to ask for the customer's phone number.
- [x] Incorporate a step to ask for the customer's phone number.
- [ ] Create a link with instructions on how to connect, including how to disable MAC randomization and providing the network password.
- [ ] Dhivehi support, Dhivehi to be the default language

View File

@ -21,6 +21,7 @@ function loadEnv() {
currency: process.env.PRICE_CURRENCY || "MVR",
}
}
console.log(`Registration is now ${registrationOpen ? "open" : "closed"}`)
}
loadEnv()
@ -31,7 +32,6 @@ fs.watchFile(path.join(__dirname, ".env"), (curr, prev) => {
delete require.cache[require.resolve("dotenv")]
require("dotenv").config({ override: true })
loadEnv()
console.log(`Registration is now ${registrationOpen ? "open" : "closed"}`)
})
// initialize express
@ -46,7 +46,7 @@ app.use(express.urlencoded({ extended: true }))
// add multer
const multer = require("multer")
if (!fs.existsSync("uploads")) fs.mkdirSync("uploads", { recursive: true })
if (!fs.existsSync("registrations.csv")) fs.writeFileSync("registrations.csv", "Customer Name,MAC Address,Device Name,Roaming,Gaming,Wired,Receipt\n", { encoding: "utf-8" });
if (!fs.existsSync("registrations.csv")) fs.writeFileSync("registrations.csv", "Customer Name,Phone Number,MAC Address,Device Name,Roaming,Gaming,Wired,Receipt\n", { encoding: "utf-8" });
const upload = multer({
storage: multer.diskStorage({
destination: (req, file, cb) => {
@ -70,21 +70,19 @@ app.post("/register", upload.single("transfer_receipt"), (req, res) => {
return;
}
let { customer_name, mac_address, device_name, is_roaming, is_gaming } = req.body
let { customer_name, phone_number, mac_address, device_name, is_roaming, is_gaming } = req.body
const receipt = req.file;
if (!is_roaming || is_roaming === "false") is_roaming = false
if (!is_gaming || is_gaming === "false") is_gaming = false
if (!customer_name || !mac_address || !device_name || !receipt) {
if (!customer_name || !phone_number || !mac_address || !device_name || !receipt) {
res.render("index", { branding, message: "Please fill all fields" })
return;
}
console.log(is_roaming, is_gaming)
// save info to csv file
const csv = `${customer_name},${mac_address},${device_name},${is_roaming ? "true" : "false"},${is_gaming ? "true" : "false"},false,${receipt.path}\n`
const csv = `${customer_name},${phone_number},${mac_address.replace(/,/g, " ")},${device_name.replace(/,/g, " ")},${is_roaming.replace(/,/g, " ")},${is_gaming.replace(/,/g, " ")},false,${receipt.path}\n`
fs.appendFile("registrations.csv", csv, (err) => {
if (err) {
console.error(err)
@ -93,7 +91,7 @@ app.post("/register", upload.single("transfer_receipt"), (req, res) => {
});
// send receipt to telegram
sendInfo(receipt.path, { customer_name, mac_address, device_name, is_roaming, is_gaming })
sendInfo(receipt.path, { customer_name, phone_number, mac_address, device_name, is_roaming, is_gaming })
.then(() => {
res.render("success", { branding })
})

View File

@ -1441,38 +1441,19 @@ html {
align-items: center;
}
.select {
display: inline-flex;
.radio {
flex-shrink: 0;
--chkbg: var(--bc);
height: 1.5rem;
width: 1.5rem;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
height: 3rem;
min-height: 3rem;
padding-left: 1rem;
padding-right: 2.5rem;
font-size: 0.875rem;
line-height: 1.25rem;
line-height: 2;
border-radius: var(--rounded-btn, 0.5rem);
border-radius: 9999px;
border-width: 1px;
border-color: transparent;
--tw-bg-opacity: 1;
background-color: var(--fallback-b1,oklch(var(--b1)/var(--tw-bg-opacity)));
background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
linear-gradient(135deg, currentColor 50%, transparent 50%);
background-position: calc(100% - 20px) calc(1px + 50%),
calc(100% - 16.1px) calc(1px + 50%);
background-size: 4px 4px,
4px 4px;
background-repeat: no-repeat;
}
.select[multiple] {
height: auto;
border-color: var(--fallback-bc,oklch(var(--bc)/var(--tw-border-opacity)));
--tw-border-opacity: 0.2;
}
.steps {
@ -1503,15 +1484,6 @@ html {
--alert-bg-mix: var(--fallback-b1,oklch(var(--b1)/1));
}
.badge-secondary {
--tw-border-opacity: 1;
border-color: var(--fallback-s,oklch(var(--s)/var(--tw-border-opacity)));
--tw-bg-opacity: 1;
background-color: var(--fallback-s,oklch(var(--s)/var(--tw-bg-opacity)));
--tw-text-opacity: 1;
color: var(--fallback-sc,oklch(var(--sc)/var(--tw-text-opacity)));
}
.badge-error {
border-color: transparent;
--tw-bg-opacity: 1;
@ -1520,11 +1492,6 @@ html {
color: var(--fallback-erc,oklch(var(--erc)/var(--tw-text-opacity)));
}
.badge-outline.badge-secondary {
--tw-text-opacity: 1;
color: var(--fallback-s,oklch(var(--s)/var(--tw-text-opacity)));
}
.badge-outline.badge-error {
--tw-text-opacity: 1;
color: var(--fallback-er,oklch(var(--er)/var(--tw-text-opacity)));
@ -1587,6 +1554,14 @@ html {
border-color: var(--btn-color, var(--fallback-b2));
}
.btn-primary {
--btn-color: var(--fallback-p);
}
.btn-accent {
--btn-color: var(--fallback-a);
}
.btn-info {
--btn-color: var(--fallback-in);
}
@ -1643,7 +1618,21 @@ html {
outline-offset: 2px;
}
.btn-primary {
--tw-text-opacity: 1;
color: var(--fallback-pc,oklch(var(--pc)/var(--tw-text-opacity)));
outline-color: var(--fallback-p,oklch(var(--p)/1));
}
@supports (color: oklch(0 0 0)) {
.btn-primary {
--btn-color: var(--p);
}
.btn-accent {
--btn-color: var(--a);
}
.btn-info {
--btn-color: var(--in);
}
@ -1657,6 +1646,12 @@ html {
}
}
.btn-accent {
--tw-text-opacity: 1;
color: var(--fallback-ac,oklch(var(--ac)/var(--tw-text-opacity)));
outline-color: var(--fallback-a,oklch(var(--a)/1));
}
.btn-info {
--tw-text-opacity: 1;
color: var(--fallback-inc,oklch(var(--inc)/var(--tw-text-opacity)));
@ -2268,6 +2263,32 @@ details.collapse summary::-webkit-details-marker {
}
}
.radio:focus {
box-shadow: none;
}
.radio:focus-visible {
outline-style: solid;
outline-width: 2px;
outline-offset: 2px;
outline-color: var(--fallback-bc,oklch(var(--bc)/1));
}
.radio:checked,
.radio[aria-checked="true"] {
--tw-bg-opacity: 1;
background-color: var(--fallback-bc,oklch(var(--bc)/var(--tw-bg-opacity)));
background-image: none;
animation: radiomark var(--animation-input, 0.2s) ease-out;
box-shadow: 0 0 0 4px var(--fallback-b1,oklch(var(--b1)/1)) inset,
0 0 0 4px var(--fallback-b1,oklch(var(--b1)/1)) inset;
}
.radio:disabled {
cursor: not-allowed;
opacity: 0.2;
}
@keyframes radiomark {
0% {
box-shadow: 0 0 0 12px var(--fallback-b1,oklch(var(--b1)/1)) inset,
@ -2299,55 +2320,6 @@ details.collapse summary::-webkit-details-marker {
}
}
.select-bordered {
border-color: var(--fallback-bc,oklch(var(--bc)/0.2));
}
.select:focus {
box-shadow: none;
border-color: var(--fallback-bc,oklch(var(--bc)/0.2));
outline-style: solid;
outline-width: 2px;
outline-offset: 2px;
outline-color: var(--fallback-bc,oklch(var(--bc)/0.2));
}
.select-disabled,
.select:disabled,
.select[disabled] {
cursor: not-allowed;
--tw-border-opacity: 1;
border-color: var(--fallback-b2,oklch(var(--b2)/var(--tw-border-opacity)));
--tw-bg-opacity: 1;
background-color: var(--fallback-b2,oklch(var(--b2)/var(--tw-bg-opacity)));
color: var(--fallback-bc,oklch(var(--bc)/var(--tw-text-opacity)));
--tw-text-opacity: 0.2;
}
.select-disabled::-moz-placeholder, .select:disabled::-moz-placeholder, .select[disabled]::-moz-placeholder {
color: var(--fallback-bc,oklch(var(--bc)/var(--tw-placeholder-opacity)));
--tw-placeholder-opacity: 0.2;
}
.select-disabled::placeholder,
.select:disabled::placeholder,
.select[disabled]::placeholder {
color: var(--fallback-bc,oklch(var(--bc)/var(--tw-placeholder-opacity)));
--tw-placeholder-opacity: 0.2;
}
.select-multiple,
.select[multiple],
.select[size].select:not([size="1"]) {
background-image: none;
padding-right: 1rem;
}
[dir="rtl"] .select {
background-position: calc(0% + 12px) calc(1px + 50%),
calc(0% + 16px) calc(1px + 50%);
}
@keyframes skeleton {
from {
background-position: 150%;
@ -2653,6 +2625,10 @@ details.collapse summary::-webkit-details-marker {
margin-right: auto;
}
.mt-4 {
margin-top: 1rem;
}
.mt-8 {
margin-top: 2rem;
}
@ -2661,8 +2637,12 @@ details.collapse summary::-webkit-details-marker {
margin-top: 0.25rem;
}
.mt-4 {
margin-top: 1rem;
.mt-2 {
margin-top: 0.5rem;
}
.mb-1 {
margin-bottom: 0.25rem;
}
.flex {
@ -2681,8 +2661,8 @@ details.collapse summary::-webkit-details-marker {
height: 100vh;
}
.w-10 {
width: 2.5rem;
.w-12 {
width: 3rem;
}
.w-6 {
@ -2741,6 +2721,15 @@ details.collapse summary::-webkit-details-marker {
border-radius: 0.25rem;
}
.border {
border-width: 1px;
}
.border-base-300 {
--tw-border-opacity: 1;
border-color: var(--fallback-b3,oklch(var(--b3)/var(--tw-border-opacity)));
}
.bg-base-100 {
--tw-bg-opacity: 1;
background-color: var(--fallback-b1,oklch(var(--b1)/var(--tw-bg-opacity)));
@ -2765,6 +2754,14 @@ details.collapse summary::-webkit-details-marker {
stroke: currentColor;
}
.text-center {
text-align: center;
}
.align-middle {
vertical-align: middle;
}
.text-3xl {
font-size: 1.875rem;
line-height: 2.25rem;
@ -2817,3 +2814,35 @@ details.collapse summary::-webkit-details-marker {
.filter {
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
}
@media (min-width: 1024px) {
.lg\:join-horizontal.join {
flex-direction: row;
}
.lg\:join-horizontal.join .join-item:first-child:not(:last-child),.lg\:join-horizontal
.join *:first-child:not(:last-child) .join-item {
border-end-end-radius: 0;
border-start-end-radius: 0;
border-end-start-radius: inherit;
border-start-start-radius: inherit;
}
.lg\:join-horizontal.join .join-item:last-child:not(:first-child),.lg\:join-horizontal
.join *:last-child:not(:first-child) .join-item {
border-end-start-radius: 0;
border-start-start-radius: 0;
border-end-end-radius: inherit;
border-start-end-radius: inherit;
}
.lg\:join-horizontal.join > :where(*:not(:first-child)) {
margin-top: 0px;
margin-bottom: 0px;
margin-inline-start: -1px;
}
.lg\:mb-0 {
margin-bottom: 0px;
}
}

View File

@ -9,7 +9,7 @@ function kebabToTitleCase(str) {
async function sendInfo(filepath, details) {
// const caption = `Customer Name: \`${customer_name}\`\nMAC Address: \`${mac_address}\`\nDevice Name: \`${device_name}\`\nRoaming: **${roaming ? "Yes" : "No"}**\nGaming: **${gaming ? "Yes" : "No"}**`
let caption = "";
let manualHandles = ["mac_address", "device_name"];
let manualHandles = ["mac_address", "device_name", "is_roaming", "is_gaming"];
for (const key in details) {
if (manualHandles.includes(key)) continue;
@ -24,7 +24,9 @@ async function sendInfo(filepath, details) {
let macAddresses = details["mac_address"].split(",");
let deviceNames = details["device_name"].split(",");
caption += "\n" + macAddresses.map((macAddress, index) => `- \`${macAddress}\` : \`${deviceNames[index]}\``).join("\n");
let isRoaming = details["is_roaming"].split(",");
let isGaming = details["is_gaming"].split(",");
caption += macAddresses.map((macAddress, index) => `\n\`${deviceNames[index]}\`\nMAC Address: \`${macAddress}\`\nIs Roaming: **${isRoaming[index] === "true" ? "Yes" : "No"}**\nIs Gaming: **${isGaming[index] === "true" ? "Yes" : "No"}**`).join("\n");
caption = caption.replace(/-/g, '\\-')

View File

@ -1,5 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
@ -11,6 +12,16 @@
let macAddressElements = [];
function saveCustomerName() {
localStorage.setItem("customer_name", document.getElementById("customer_name").value);
document.getElementById("customer_name").value = localStorage.getItem("customer_name")
}
function savePhoneNumber() {
localStorage.setItem("phone_number", document.getElementById("phone_number").value);
document.getElementById("phone_number").value = localStorage.getItem("phone_number")
}
function saveMACAddresses() {
localStorage.setItem("mac_address", macAddressElements.map(macAddressElement => document.getElementById(macAddressElement).value).join(","));
document.getElementById("mac_address").value = localStorage.getItem("mac_address")
@ -21,7 +32,19 @@
document.getElementById("device_name").value = localStorage.getItem("device_name")
}
function addMACAddress(macAddress = "", deviceName = "") {
function saveIsRoaming() {
localStorage.setItem("is_roaming", macAddressElements.map(macAddressElement => document.getElementById(`${macAddressElement}_roaming`).checked).join(","));
document.getElementById("is_roaming").value = localStorage.getItem("is_roaming")
setPricing()
}
function saveIsGaming() {
localStorage.setItem("is_gaming", macAddressElements.map(macAddressElement => document.getElementById(`${macAddressElement}_gaming`).checked).join(","));
document.getElementById("is_gaming").value = localStorage.getItem("is_gaming")
setPricing()
}
function addMACAddress(macAddress = "", deviceName = "", isRoaming = false, isGaming = false) {
let nextIndex = macAddressElements.length;
let nextMacAddressElement = `mac_address_${nextIndex}`;
while (macAddressElements.includes(nextMacAddressElement)) {
@ -29,40 +52,40 @@
nextMacAddressElement = `mac_address_${nextIndex}`;
}
const template = `
<div id="${nextMacAddressElement}_container" class="join w-full mt-4">
<div id="${nextMacAddressElement}_container" class="w-full">
<div class="join w-full mt-4">
<div class="w-full flex flex-row justify-stretch">
<div class="flex-grow">
<input
id="${nextMacAddressElement}"
class="input input-bordered join-item w-full"
placeholder="00:00:00:00:00:00"
oninput="validateMACAddress('${nextMacAddressElement}')"
onchange="saveMACAddresses()"
<input id="${nextMacAddressElement}" class="input input-bordered join-item w-full"
value="${macAddress}"
/>
placeholder="00:00:00:00:00:00" oninput="validateMACAddress('${nextMacAddressElement}')"
onchange="saveMACAddresses()" />
</div>
<div class="flex-grow">
<input
id="${nextMacAddressElement}_device"
class="input input-bordered join-item w-full"
onchange="saveMACAddresses()"
placeholder="iphone-12"
onclick="fillDeviceName('${nextMacAddressElement}')"
oninput="saveDeviceNames()"
<input id="${nextMacAddressElement}_device" class="input input-bordered join-item w-full"
value="${deviceName}"
/>
onchange="saveMACAddresses()" placeholder="iphone-12"
onclick="fillDeviceName('${nextMacAddressElement}')" />
</div>
</div>
<button
class="indicator"
onclick="event.preventDefault();removeMACAddress('${nextMacAddressElement}')"
>
<button class="indicator" onclick="event.preventDefault();removeMACAddress('${nextMacAddressElement}')">
<span class="indicator-item badge badge-error">-</span>
</button>
</div>`
</div>
<div class="join align-middle mt-2">
<button class="btn join-item btn-accent" onclick="event.preventDefault()">Add-ons</button>
<input class="join-item btn" type="checkbox" id="${nextMacAddressElement}_roaming" onchange="saveIsRoaming()"
${isRoaming === "true" ? "checked" : ""}
aria-label="Roaming" />
<input class="join-item btn" type="checkbox" id="${nextMacAddressElement}_gaming" onchange="saveIsGaming()"
${isGaming === "true" ? "checked" : ""}
aria-label="Gaming" />
</div>
</div>`;
// document.getElementById("mac_addresses").innerHTML += template;
document.getElementById("mac_addresses").insertAdjacentHTML("beforeend", template)
macAddressElements.push(nextMacAddressElement)
setPricing()
}
function removeMACAddress(id) {
@ -73,43 +96,41 @@
saveMACAddresses();
saveDeviceNames();
saveIsGaming();
saveIsRoaming();
}
function recoverForm() {
const customerName = document.getElementById("customer_name");
const phoneNumber = document.getElementById("phone_number");
// const macAddress = document.getElementById("mac_address");
// const deviceName = document.getElementById("device_name");
const isRoaming = document.getElementById("is_roaming");
const isGaming = document.getElementById("is_gaming");
// const isRoaming = document.getElementById("is_roaming");
// const isGaming = document.getElementById("is_gaming");
customerName.value = localStorage.getItem("customer_name") || "";
phoneNumber.value = localStorage.getItem("phone_number") || "";
// macAddress.value = localStorage.getItem("mac_address") || "";
// deviceName.value = localStorage.getItem("device_name") || "";
isRoaming.value = localStorage.getItem("is_roaming") === "true";
isGaming.value = localStorage.getItem("is_gaming") === "true";
// isRoaming.value = localStorage.getItem("is_roaming") === "true";
// isGaming.value = localStorage.getItem("is_gaming") === "true";
const macAddresses = localStorage.getItem("mac_address") || "";
const deviceNames = localStorage.getItem("device_name") || "";
macAddresses.split(",").forEach((macAddress, index) => {
addMACAddress(macAddress, deviceNames[index]);;
const macAddresses = (localStorage.getItem("mac_address") || "").split(",");
const deviceNames = (localStorage.getItem("device_name") || "").split(",");
const isRoaming = (localStorage.getItem("is_roaming") || "").split(",");
const isGaming = (localStorage.getItem("is_gaming") || "").split(",");
macAddresses.forEach((macAddress, index) => {
addMACAddress(macAddress, deviceNames[index], isRoaming[index], isGaming[index]);
});
}
function saveForm() {
const customerName = document.getElementById("customer_name");
// const macAddress = document.getElementById("mac_address");
// const deviceName = document.getElementById("device_name");
const isRoaming = document.getElementById("is_roaming");
const isGaming = document.getElementById("is_gaming");
localStorage.setItem("customer_name", customerName.value);
// localStorage.setItem("mac_address", macAddress.value);
// localStorage.setItem("device_name", deviceName.value);
localStorage.setItem("is_roaming", isRoaming.checked? "true": "false");
localStorage.setItem("is_gaming", isGaming.checked? "true": "false");
saveCustomerName();
savePhoneNumber();
saveMACAddresses();
saveDeviceNames();
saveIsRoaming();
saveIsGaming();
}
function clearForm() {
@ -123,22 +144,16 @@
}
function setPricing() {
const normalPrice = <%- branding.price.normal %>;
const roamingPrice = <%- branding.price.roaming %>;
const gamingPrice = <%- branding.price.gaming %>;
const currency = "<%- branding.price.currency %>";
const isRoaming = document.getElementById("is_roaming");
const isGaming = document.getElementById("is_gaming");
const normalPrice = <%= branding.price.normal %>;
const roamingPrice = <%= branding.price.roaming %>;
const gamingPrice = <%= branding.price.gaming %>;
const currency = "<%= branding.price.currency %>";
const amountLabel = document.getElementById("amount");
let amount = normalPrice;
if (isRoaming.checked) {
amount += roamingPrice;
}
if (isGaming.checked) {
amount += gamingPrice;
}
amountLabel.textContent = `Amount: ${amount} ${currency}`;
saveForm();
const amount = (normalPrice * macAddressElements.length) + (roamingPrice * document.querySelectorAll("input[id$='_roaming']:checked").length) + (gamingPrice * document.querySelectorAll("input[id$='_gaming']:checked").length);
amountLabel.textContent = `${amount} ${currency}`;
}
function fillDeviceName(id) {
@ -248,45 +263,30 @@
}
</script>
</head>
<body>
<header>
<div class="navbar bg-base-300">
<button class="btn btn-ghost text-xl">
<img class="w-10 rounded" src="<%- branding.logo %>" />
<img class="w-12 rounded" src="<%- branding.logo %>" />
<%- branding.title %>
</button>
</div>
</header>
<% if (message) { %>
<div
role="alert"
class="alert alert-error w-[80vw] mx-auto mt-8"
style="z-index: 1000"
onclick="this.style.display = 'none'"
>
<svg
xmlns="http://www.w3.org/2000/svg"
class="stroke-current shrink-0 h-6 w-6"
fill="none"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"
/>
<div role="alert" class="alert alert-error w-[80vw] mx-auto mt-8" style="z-index: 1000"
onclick="this.style.display = 'none'">
<svg xmlns="http://www.w3.org/2000/svg" class="stroke-current shrink-0 h-6 w-6" fill="none" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<span><%= message %></span>
<span>
<%= message %>
</span>
</div>
<% } %>
<main>
<form
class="flex justify-center"
action="/register"
method="post"
enctype="multipart/form-data"
>
<form class="flex justify-center" action="/register" method="post" enctype="multipart/form-data">
<div class="w-[80vw]">
<div class="join-horizontal mt-8">
<div class="join-vertical justify-center">
@ -296,78 +296,67 @@
</p>
</div>
<br />
<button
class="btn btn-block btn-outline btn-error"
onclick="clearForm();event.preventDefault()"
>
Clear Form
</button>
<br />
<br />
<div class="join-vertical">
<div class="form-control">
<label class="label">
<span class="label-text font-bold text-lg text-base-content"
>Customer Name</span
>
<span class="label-text font-bold text-lg text-base-content">Customer Name</span>
</label>
<input
type="text"
id="customer_name"
name="customer_name"
placeholder="John Doe"
class="input input-bordered"
onchange="validateForm()"
/>
<input type="text" id="customer_name" name="customer_name" placeholder="John Doe"
class="input input-bordered" onchange="validateForm()" />
</div>
</div>
<br />
<div class="join-vertical">
<div class="form-control">
<label class="label">
<span class="label-text font-bold text-lg text-base-content"
>MAC Addresses</span
>
<span class="label-text font-bold text-lg text-base-content">Phone Number</span>
</label>
<input type="tel" id="phone_number" name="phone_number" placeholder="9696969"
class="input input-bordered" onchange="validateForm()" />
</div>
</div>
<br />
<div class="join-vertical">
<div class="form-control">
<label class="label">
<span class="label-text font-bold text-lg text-base-content">MAC Addresses</span>
</label>
<input type="hidden" name="mac_address" id="mac_address" />
<input type="hidden" name="device_name" id="device_name" />
<input type="hidden" name="is_roaming" id="is_roaming" />
<input type="hidden" name="is_gaming" id="is_gaming" />
<div id="mac_addresses">
<!-- <div id="mac_address_1_container" class="join w-full mt-4">
<!-- <div id="mac_address_1_container" class="w-full">
<div class="join w-full mt-4">
<div class="w-full flex flex-row justify-stretch">
<div class="flex-grow">
<input
id="mac_address_1"
class="input input-bordered join-item w-full"
placeholder="00:00:00:00:00:00"
oninput="validateMACAddress('mac_address_1')"
onchange="saveMACAddresses()"
/>
<input id="mac_address_1" class="input input-bordered join-item w-full"
placeholder="00:00:00:00:00:00" oninput="validateMACAddress('mac_address_1')"
onchange="saveMACAddresses()" />
</div>
<div class="flex-grow">
<input
id="mac_address_1_device"
class="input input-bordered join-item w-full"
onchange="saveMACAddresses()"
placeholder="iphone-12"
onclick="fillDeviceName('mac_address_1')"
/>
<input id="mac_address_1_device" class="input input-bordered join-item w-full"
onchange="saveMACAddresses()" placeholder="iphone-12"
onclick="fillDeviceName('mac_address_1')" />
</div>
</div>
<button
class="indicator"
onclick="event.preventDefault();removeMACAddress('mac_address_1')"
>
<button class="indicator" onclick="event.preventDefault();removeMACAddress('mac_address_1')">
<span class="indicator-item badge badge-error">-</span>
</button>
</div>
<div class="join align-middle mt-2">
<button class="btn join-item btn-accent" onclick="event.preventDefault()">Add-ons</button>
<input class="join-item btn" type="checkbox" id="mac_address_1_roaming" onchange="saveForm()"
aria-label="Roaming?" />
<input class="join-item btn" type="checkbox" id="mac_address_1_gaming" onchange="saveForm()"
aria-label="Gaming?" />
</div>
</div> -->
</div>
<button
class="btn btn-block btn-success mt-4"
onclick="event.preventDefault();addMACAddress()"
>
Add
<button class="btn btn-block btn-success mt-4" onclick="event.preventDefault();addMACAddress()">
Add another device
</button>
</div>
</div>
@ -453,41 +442,14 @@
</div>
</div>
</div>
<br />
<div class="join-vertical">
<div class="form-control">
<label class="label cursor-pointer">
<span class="label-text">Is Device Roaming?</span>
<input
type="checkbox"
id="is_roaming"
name="is_roaming"
checked="checked"
class="checkbox"
oninput="setPricing()"
/>
</label>
<br>
<br>
<div tabindex="0" class="collapse collapse-open border border-base-300 bg-primary text-primary-content">
<div class="collapse-title text-xl font-medium">
Amount: <label class="text-lg" id="amount"></label>
</div>
</div>
<br />
<div class="join-vertical">
<div class="form-control">
<label class="label cursor-pointer">
<span class="label-text"
>Is device going to be used for gaming?</span
>
<input
type="checkbox"
id="is_gaming"
name="is_gaming"
class="checkbox"
oninput="setPricing()"
/>
</label>
</div>
</div>
<br />
<br />
<div class="collapse bg-base-200">
<input type="checkbox" />
<div class="collapse-title text-xl font-medium">
@ -508,17 +470,13 @@
<li>
Account Name: <%- branding.bankDetails.accountName %>
</li>
<li id="amount">
Amount: <%- branding.price.roaming %> <%-
branding.price.currency %>
</li>
<!-- <li id="amount">
Amount: <%- branding.price.roaming %> <%- branding.price.currency %>
</li> -->
</ul>
<br />
<button
type="button"
class="btn btn-block btn-info"
onclick="navigator.clipboard.writeText('<%- branding.bankDetails.accountNumber %>');event.target.textContent = 'Copied';setTimeout(() => { event.target.textContent = 'Copy Account Number'; }, 2000);"
>
<button type="button" class="btn btn-block btn-info"
onclick="navigator.clipboard.writeText('<%- branding.bankDetails.accountNumber %>');event.target.textContent = 'Copied';setTimeout(() => { event.target.textContent = 'Copy Account Number'; }, 2000);">
Copy Account Number
</button>
</div>
@ -561,29 +519,24 @@
<div class="join-vertical">
<div class="form-control">
<label class="label">
<span class="label-text font-bold text-lg text-base-content"
>Transfer Receipt</span
>
<span class="label-text font-bold text-lg text-base-content">Transfer Receipt</span>
</label>
<input
type="file"
id="transfer_receipt"
name="transfer_receipt"
class="file-input file-input-bordered max-w"
accept="image/*"
onchange="validateForm()"
/>
<input type="file" id="transfer_receipt" name="transfer_receipt"
class="file-input file-input-bordered max-w" accept="image/*" onchange="validateForm()" />
</div>
</div>
<br />
<button
class="btn btn-info btn-block"
onclick="if (!validateForm()) event.preventDefault()"
>
<div class="join w-full join-vertical lg:join-horizontal">
<button class="btn join-item btn-outline btn-error flex-grow"
onclick="event.preventDefault();clearForm()">
Clear Form
</button>
<button class="btn join-item btn-info flex-grow" onclick="if (!validateForm()) event.preventDefault()">
Submit
</button>
</div>
</div>
</div>
</form>
<footer>
<div style="height: 10em"></div>
@ -594,4 +547,5 @@
recoverForm();
setPricing();
</script>
</html>