mirror of
https://gitlab.com/sarlink/kyc.git
synced 2025-07-28 17:52:39 +00:00
[feat] Too many features to count....
This commit is contained in:
@ -2,8 +2,20 @@ const fs = require("fs")
|
||||
const FormData = require('form-data');
|
||||
const axios = require('axios').default;
|
||||
|
||||
async function sendInfo(filepath, customer_name, mac_address, device_name, roaming) {
|
||||
const caption = `Customer Name: \`${customer_name}\`\nMAC Address: \`${mac_address}\`\nDevice Name: \`${device_name}\`\nRoaming: **${roaming ? "Yes" : "No"}**`
|
||||
function kebabToTitleCase(str) {
|
||||
return str.split("_").map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(" ")
|
||||
}
|
||||
|
||||
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 = "";
|
||||
for (const key in details) {
|
||||
if (key.startsWith("is")) {
|
||||
details[key] = details[key] === "on" ? "Yes" : "No"
|
||||
}
|
||||
|
||||
caption += `${kebabToTitleCase(key)}: \`${details[key]}\`\n`
|
||||
}
|
||||
|
||||
var formData = new FormData();
|
||||
formData.append("photo", fs.createReadStream(filepath));
|
||||
|
@ -13,20 +13,28 @@
|
||||
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");
|
||||
|
||||
customerName.value = localStorage.getItem("customer_name") || "";
|
||||
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";
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
function clearForm() {
|
||||
@ -38,17 +46,23 @@
|
||||
document.getElementById("device_name").value = "";
|
||||
}
|
||||
|
||||
function setRoaming() {
|
||||
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 amount = document.getElementById("amount");
|
||||
const isGaming = document.getElementById("is_gaming");
|
||||
const amountLabel = document.getElementById("amount");
|
||||
let amount = normalPrice;
|
||||
if (isRoaming.checked) {
|
||||
amount.textContent = `Amount: ${roamingPrice} ${currency}`;
|
||||
} else {
|
||||
amount.textContent = `Amount: ${normalPrice} ${currency}`;
|
||||
amount += roamingPrice;
|
||||
}
|
||||
if (isGaming.checked) {
|
||||
amount += gamingPrice;
|
||||
}
|
||||
amountLabel.textContent = `Amount: ${amount} ${currency}`;
|
||||
saveForm();
|
||||
}
|
||||
|
||||
function fillDeviceName() {
|
||||
@ -346,7 +360,24 @@
|
||||
name="is_roaming"
|
||||
checked="checked"
|
||||
class="checkbox"
|
||||
oninput="setRoaming()"
|
||||
oninput="setPricing()"
|
||||
/>
|
||||
</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>
|
||||
@ -457,5 +488,6 @@
|
||||
</body>
|
||||
<script>
|
||||
recoverForm();
|
||||
setPricing();
|
||||
</script>
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user