Skip to content

Commit 7c5d0d3

Browse files
Refactor form submission and update messages
Signed-off-by: abdurhamanmohammeda-a11y <abdurhamanmohammeda@gmail.com>
1 parent 68bad58 commit 7c5d0d3

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

index.html

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,7 @@ <h2>👨‍🔧 Request Service</h2>
9191
<textarea name="data[message]" id="userMsg" rows="4" placeholder="Describe the machine problem..." required></textarea>
9292

9393
<button type="submit" id="submitBtn" class="btn btn-wa">💬 Send to Excel & WhatsApp</button>
94-
</form>
95-
</div>
96-
97-
<script>
94+
<script>
9895
const form = document.getElementById('sheetdb-form');
9996

10097
form.addEventListener("submit", e => {
@@ -104,26 +101,37 @@ <h2>👨‍🔧 Request Service</h2>
104101
const nameVal = document.getElementById('userName').value;
105102
const msgVal = document.getElementById('userMsg').value;
106103

107-
Mallattoo processing agarsiisuu
104+
Button "Processing" gochuu
108105
btn.innerText = "Processing... ⏳";
109106
btn.disabled = true;
110107

111-
Gara SheetDB erguu
108+
Data qopheessuu (Format SheetDB jaallatu)
109+
const postData = {
110+
"data": [
111+
{
112+
"name": nameVal,
113+
"message": msgVal,
114+
"date": new Date().toLocaleString()
115+
}
116+
]
117+
};
118+
119+
Gara SheetDB erguu
112120
fetch('https://sheetdb.io/api/v1/49bhx2brvk9r3', {
113121
method : 'POST',
114-
body: new FormData(form),
122+
headers: {
123+
'Content-Type': 'application/json'
124+
},
125+
body: JSON.stringify(postData)
115126
})
116127
.then(res => {
117128
if(res.ok) {
118129
alert("✅ Galatoomi! Odeeffannoon kee Excel irratti galmaa'eera.");
119-
120-
WhatsApp banuu (Kun sirriitti hojjeta)
121-
let whatsappURL = `https://wa.me/251904267186?text=Hello Abdurhaman, I am ${nameVal}. Issue: ${msgVal}`;
122-
window.open(whatsappURL, '_blank');
123-
130+
WhatsApp banuu
131+
window.open(`https://wa.me/251904267186?text=Hello Abdurhaman, I am ${nameVal}. Issue: ${msgVal}`, '_blank');
124132
form.reset();
125133
} else {
126-
alert("❌ Database Error: API Link kee ilaali.");
134+
alert("❌ App error: Check SheetDB Row 1 (name, message)");
127135
}
128136
})
129137
.catch(err => {
@@ -136,7 +144,7 @@ <h2>👨‍🔧 Request Service</h2>
136144
});
137145
});
138146

139-
Search fi Diagnostics (Akkuma duraatti itti fufa) ---
147+
Search Function (Haquu hin barbaachisu, dhiisuu dandeessa) ---
140148
function searchParts() {
141149
let input = document.getElementById("partSearch").value.toUpperCase();
142150
let tr = document.getElementById("partsTable").getElementsByTagName("tr");
@@ -147,7 +155,7 @@ <h2>👨‍🔧 Request Service</h2>
147155
}
148156
</script>
149157

150-
// --- 2. SEARCH LOGIC ---
158+
2. SEARCH LOGIC
151159
function searchParts() {
152160
let input = document.getElementById("partSearch").value.toUpperCase();
153161
let tr = document.getElementById("partsTable").getElementsByTagName("tr");
@@ -157,7 +165,7 @@ <h2>👨‍🔧 Request Service</h2>
157165
}
158166
}
159167

160-
// --- 3. DIAGNOSTICS LOGIC ---
168+
3. DIAGNOSTICS LOGIC ---
161169
function checkMachineHealth() {
162170
let temp = prompt("Enter Machine Temp (°C):");
163171
if (temp === null || temp === "") return;

0 commit comments

Comments
 (0)