diff --git a/src/routes/shirts/+page.server.ts b/src/routes/shirts/+page.server.ts index 9f77f65..155be03 100644 --- a/src/routes/shirts/+page.server.ts +++ b/src/routes/shirts/+page.server.ts @@ -14,49 +14,57 @@ export const actions = { amount: data.get('amount'), estimated_price: data.get('estimated_price'), } - console.log("appl", order, data) + // console.log("shirt", order, data) - const shirt_string = "test" - // const shirt_string = [ - // shirt.name, - // shirt.city, - // shirt.contact?.name, - // ].map(v => { - // // Escape for CSV safety - // const s = String(v ?? ''); - // return s.includes(',') || s.includes('"') ? `"${s.replace(/"/g, '""')}"` : s; - // }).join(', '); + const type = data.getAll('type') + const color = data.getAll('color') + const size = data.getAll('size') - console.log(shirt_string) - // transporter.sendMail({ - // from: SMTP_USERNAME, - // to: "farm@sludge.link", - // subject: "Sludge Farm Shirt Preorder", - // attachments: [{ - // filename: order.name + '-shirts.csv', - // content: shirt_string - // }, - // { - // filename: order.name + '-shirts.json', - // content: JSON.stringify(order) - // } - // ], - // html: ` - // - // - // - //

new order for ${order.name}!!

- //
 ${JSON.stringify(order, null, 2).replace(/&/g, '&').replace(//g, '>')} 
- // - // { - // if (error) { - // console.error("Error sending email:", error); - // } else { - // console.log("Email sent successfully:", info.response); - // } - // }) + // console.log({ type, color, size }) + + if (Array.isArray(type)) { + for (let index in type) { + console.log(index) + const key = `tshirt-${index}` + const value = { + type: type[index], + color: color[index], + size: size[index] + } + order = { + ...order, + [key]: value + } + } + } + + console.log("shirt", order) + + transporter.sendMail({ + from: SMTP_USERNAME, + to: "farm@sludge.link", + subject: "Sludge Farm Shirt Preorder", + attachments: [{ + filename: order.name + '-shirts.json', + content: JSON.stringify(order) + } + ], + html: ` + + + +

new order for ${order.name}!!

+
 ${JSON.stringify(order, null, 2).replace(/&/g, '&').replace(//g, '>')} 
+ + { + if (error) { + console.error("Error sending email:", error); + } else { + console.log("Email sent successfully:", info.response); + } + }) } } diff --git a/src/routes/shirts/+page.svelte b/src/routes/shirts/+page.svelte index 39f6cf5..93170ba 100644 --- a/src/routes/shirts/+page.svelte +++ b/src/routes/shirts/+page.svelte @@ -1,12 +1,12 @@
@@ -86,16 +73,10 @@
- {shirts.length} shirt{shirts.length > 1 ? "s" : ""} for roughly ≈ + {shirts} shirt{shirts > 1 ? "s" : ""} for roughly ≈ {USD.format(estimated_price)} - +
- +
+ + +
@@ -193,6 +174,7 @@ box-sizing: border-box; background: var(--primary-8); border-radius: var(--br); + color: var(--primary-1); border: none; padding: 0.25rem 0.5rem; font-size: 1rem;