-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
55 lines (48 loc) · 1.62 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
let selectedType = "";
// Показать форму при нажатии кнопок
document.getElementById("naqt-btn").addEventListener("click", () => {
selectedType = "Naqt";
showForm();
});
document.getElementById("karta-btn").addEventListener("click", () => {
selectedType = "Karta";
showForm();
});
function showForm() {
document.getElementById("form-container").style.display = "block";
}
// Отправка данных
document.getElementById("submit-btn").addEventListener("click", () => {
const sender = document.getElementById("sender").value;
const recipient = document.getElementById("recipient").value;
const amount = document.getElementById("amount").value;
const phone = document.getElementById("phone").value;
const region = document.getElementById("region").value;
if (!sender || !recipient || !amount || !phone) {
alert("Заполните все поля!");
return;
}
const payload = {
type: selectedType,
sender,
recipient,
amount,
phone,
region,
date: new Date().toLocaleDateString(),
telegramId: window.Telegram.WebApp.initDataUnsafe?.user?.id || "Unknown"
};
// Отправка данных в Google Apps Script
fetch("ВАШ_GOOGLE_APPS_SCRIPT_URL", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload)
})
.then(response => response.json())
.then(data => {
alert("Данные успешно отправлены!");
console.log(data);
window.Telegram.WebApp.close(); // Закрыть WebApp
})
.catch(error => console.error("Ошибка:", error));
});