Skip to content

Commit c8bd800

Browse files
committed
mkae shit work + move membership form buttons back to center (i hate vibe coding) + reload localstored info on form submission for subseq purchases
1 parent 205919a commit c8bd800

File tree

5 files changed

+72
-4
lines changed

5 files changed

+72
-4
lines changed

public/member/appscriptPOST.gs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,66 @@
1111
/**
1212
* Handle POST requests
1313
*/
14+
15+
/**
16+
* Appends data to the specified sheet, creating new columns if needed
17+
*
18+
* @param {Object} data - The data object to append
19+
* @param {String} sheetName - The name of the sheet to append to
20+
* @return {Object} Information about the operation
21+
*/
22+
function appendDataToSheet(data, sheetName) {
23+
const ss = SpreadsheetApp.getActiveSpreadsheet();
24+
25+
// Get the sheet - it should exist based on our earlier validation
26+
let sheet = ss.getSheetByName(sheetName);
27+
28+
// Check if the first cell is empty to determine if headers need to be added
29+
const firstCell = sheet.getRange(1, 1).getValue();
30+
if (firstCell === '') {
31+
// Initialize with default headers if the sheet is empty
32+
sheet.appendRow(['TIMESTAMP', 'EID']);
33+
}
34+
35+
// Get existing headers
36+
const headerRange = sheet.getRange(1, 1, 1, sheet.getLastColumn());
37+
const headers = headerRange.getValues()[0];
38+
39+
// Check for new fields and add headers if needed
40+
let updatedHeaders = [...headers];
41+
const newHeaders = [];
42+
43+
Object.keys(data).forEach(key => {
44+
if (!headers.includes(key)) {
45+
updatedHeaders.push(key);
46+
newHeaders.push(key);
47+
}
48+
});
49+
50+
// If there are new headers, upd//https://script.google.com/macros/s/AKfycbzkHNj7J8ai6G9AFmm373TQqI0o02b9WLVkDJwPvavGOlw7XRTC8kacCEkoeblVPKCB/execate the header row
51+
if (newHeaders.length > 0) {
52+
// Add new columns
53+
sheet.getRange(1, headers.length + 1, 1, newHeaders.length)
54+
.setValues([newHeaders]);
55+
56+
// Get updated headers
57+
const updatedHeaderRange = sheet.getRange(1, 1, 1, sheet.getLastColumn());
58+
updatedHeaders = updatedHeaderRange.getValues()[0];
59+
}
60+
61+
// Prepare row data to match all headers
62+
const rowData = updatedHeaders.map(header => data[header] || '');
63+
64+
// Append the new row
65+
sheet.appendRow(rowData);
66+
67+
return {
68+
'sheetName': sheetName,
69+
'newHeaders': newHeaders,
70+
'rowAdded': rowData
71+
};
72+
}
73+
1474
function doPost(e) {
1575
try {
1676
// Parse the incoming JSON data

public/member/eidStats.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ export function clearSavedEid() {
338338
* Refresh data in the background
339339
* @param {string} eid - The EID to refresh data for
340340
*/
341-
async function refreshDataInBackground(eid) {
341+
export async function refreshDataInBackground(eid) {
342342
if (!eid) return;
343343

344344
console.log(`Starting background refresh for EID: ${eid}`);

public/member/index.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
<!-- Import the styles.css file -->
88
<link rel="stylesheet" href="styles.css">
99
<!-- Additional styles for EID submit button -->
10-
<link rel="stylesheet" href="styles-additions.css">
11-
<!-- Fix for radio button alignment -->
1210

1311
</head>
1412
<body>

public/member/membershipForm.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import { GOOGLE_APPS_SCRIPT_URL } from './constants.js';
77
import { postToAppsScript } from './apiService.js';
8+
import { refreshDataInBackground } from './eidStats.js';
89

910
/**
1011
* Initialize membership form functionality
@@ -178,9 +179,19 @@ function submitMembershipForm(form, data, submitButton, originalButtonText) {
178179
submitButton.disabled = false;
179180
submitButton.textContent = originalButtonText;
180181

182+
// Get the EID from the form data
183+
const eid = data.EID;
184+
181185
// Hide the form after successful submission
182186
setTimeout(() => {
183187
form.style.display = 'none';
188+
189+
// Refresh EID data after a short delay to allow the server to process the form submission
190+
if (eid) {
191+
setTimeout(() => {
192+
refreshDataInBackground(eid);
193+
}, 3000);
194+
}
184195
}, 2000);
185196
},
186197
// Error callback

public/member/styles.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ input { padding: .55rem; box-sizing: border-box; margin-top: .6rem; }
324324
}
325325

326326
.form-group input {
327-
width: 100%;
328327
padding: 10px;
329328
border: 1px solid #ccc;
330329
border-radius: 4px;

0 commit comments

Comments
 (0)