Fix registration API to accept simplified name/email-only form
- Update API route validation to only require name and email - Simplify RegistrationData interface - Keep sheet column layout unchanged for backward compatibility Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
7524d34e46
commit
ca8f786fb0
|
|
@ -5,10 +5,10 @@ export async function POST(request: NextRequest) {
|
||||||
try {
|
try {
|
||||||
const body = await request.json()
|
const body = await request.json()
|
||||||
|
|
||||||
const { name, email, contact, contributions, expectations, howHeard, dietary, crewConsent, wantFood } = body
|
const { name, email } = body
|
||||||
|
|
||||||
// Validate required fields
|
// Validate required fields
|
||||||
if (!name || !email || !contact || !contributions || !expectations || !crewConsent) {
|
if (!name || !email) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: "Missing required fields" },
|
{ error: "Missing required fields" },
|
||||||
{ status: 400 }
|
{ status: 400 }
|
||||||
|
|
@ -22,13 +22,6 @@ export async function POST(request: NextRequest) {
|
||||||
const rowNumber = await addRegistration({
|
const rowNumber = await addRegistration({
|
||||||
name,
|
name,
|
||||||
email,
|
email,
|
||||||
contact,
|
|
||||||
contributions,
|
|
||||||
expectations,
|
|
||||||
howHeard: howHeard || "",
|
|
||||||
dietary: Array.isArray(dietary) ? dietary.join(", ") : dietary || "",
|
|
||||||
crewConsent,
|
|
||||||
wantFood: wantFood || false,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(`[Register API] Registration added for ${name} at row ${rowNumber}`)
|
console.log(`[Register API] Registration added for ${name} at row ${rowNumber}`)
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,6 @@ const SHEET_NAME = process.env.GOOGLE_SHEET_NAME || "Registrations"
|
||||||
export interface RegistrationData {
|
export interface RegistrationData {
|
||||||
name: string
|
name: string
|
||||||
email?: string
|
email?: string
|
||||||
contact: string
|
|
||||||
contributions: string
|
|
||||||
expectations: string
|
|
||||||
howHeard: string
|
|
||||||
dietary: string
|
|
||||||
crewConsent: string
|
|
||||||
wantFood: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PaymentUpdateData {
|
export interface PaymentUpdateData {
|
||||||
|
|
@ -53,12 +46,12 @@ export async function addRegistration(data: RegistrationData): Promise<number> {
|
||||||
timestamp, // A: Timestamp
|
timestamp, // A: Timestamp
|
||||||
data.name, // B: Name
|
data.name, // B: Name
|
||||||
data.email || "", // C: Email
|
data.email || "", // C: Email
|
||||||
data.contact, // D: Contact
|
"", // D: Contact (unused)
|
||||||
data.contributions, // E: Contributions
|
"", // E: Contributions (unused)
|
||||||
data.expectations, // F: Expectations
|
"", // F: Expectations (unused)
|
||||||
data.howHeard || "", // G: How Heard
|
"", // G: How Heard (unused)
|
||||||
data.dietary, // H: Dietary
|
"", // H: Dietary (unused)
|
||||||
data.crewConsent, // I: Crew Consent
|
"", // I: Crew Consent (unused)
|
||||||
"Pending", // J: Payment Status
|
"Pending", // J: Payment Status
|
||||||
"", // K: Payment Method
|
"", // K: Payment Method
|
||||||
"", // L: Payment Session ID
|
"", // L: Payment Session ID
|
||||||
|
|
@ -66,7 +59,7 @@ export async function addRegistration(data: RegistrationData): Promise<number> {
|
||||||
"", // N: Payment Date
|
"", // N: Payment Date
|
||||||
"", // O: Accommodation Venue
|
"", // O: Accommodation Venue
|
||||||
"", // P: Accommodation Type
|
"", // P: Accommodation Type
|
||||||
data.wantFood ? "Yes" : "No", // Q: Want Food
|
"", // Q: Want Food (unused)
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue