92 lines
2.8 KiB
TypeScript
92 lines
2.8 KiB
TypeScript
export async function load({ }) {
|
|
console.log("sludge fest application")
|
|
}
|
|
|
|
import { SMTP_USERNAME } from '$env/static/private'
|
|
import { transporter } from "$lib/email"
|
|
export const actions = {
|
|
default: async ({ request }) => {
|
|
let data = await request.formData();
|
|
// console.log("apply", data);
|
|
let artist = {
|
|
name: data.get('artist_name'),
|
|
city: data.get('artist_city'),
|
|
contact: {
|
|
name: data.get('artist_contact_name'),
|
|
number: data.get('artist_contact_number'),
|
|
email: data.get('artist_contact_email')
|
|
},
|
|
type: data.get("act_type") != 'other' ? data.get("act_type") : data.get('other_act'),
|
|
genre: data.get("act_genre"),
|
|
amount_performers: data.get("act_performer_amount"),
|
|
biography: data.get("act_bio"),
|
|
links: data.get("act_links"),
|
|
performance_time: data.get('perf_time') != 'other' ? data.get('perf_time') : data.get('other_time'),
|
|
performance_length: data.get('perf_length') != 'other' ? data.get('perf_length') : data.get('other_length'),
|
|
tech_needs: data.get("performance_needs"),
|
|
what_drew_you: data.get('olt_draw'),
|
|
any_other_questions: data.get("olt_know"),
|
|
donation_acceptance: data.get('donation_confirmation')
|
|
|
|
}
|
|
console.log("appl", artist)
|
|
|
|
const artist_string = [
|
|
artist.name,
|
|
artist.city,
|
|
artist.contact?.name,
|
|
artist.contact?.number,
|
|
artist.contact?.email,
|
|
artist.type,
|
|
artist.genre,
|
|
artist.amount_performers,
|
|
artist.biography,
|
|
artist.links,
|
|
artist.performance_time,
|
|
artist.performance_length,
|
|
artist.tech_needs,
|
|
artist.what_drew_you,
|
|
artist.any_other_questions,
|
|
artist.donation_acceptance
|
|
].map(v => {
|
|
// Escape for CSV safety
|
|
const s = String(v ?? '');
|
|
return s.includes(',') || s.includes('"') ? `"${s.replace(/"/g, '""')}"` : s;
|
|
}).join(', ');
|
|
|
|
// console.log(artist_string)
|
|
transporter.sendMail({
|
|
from: SMTP_USERNAME,
|
|
to: "fuckyou@sludge.link, black.ga@protonmail.com",
|
|
subject: "Sludge Fest Application for " + artist.name,
|
|
attachments: [{
|
|
|
|
filename: artist.name + '-application.csv',
|
|
content: artist_string
|
|
},
|
|
{
|
|
filename: artist.name + '-application.json',
|
|
content: JSON.stringify(artist)
|
|
}
|
|
],
|
|
html: `
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<body>
|
|
<h1>New App just dropped!! </h1>
|
|
<pre> ${JSON.stringify(artist, null, 2).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')} </pre>
|
|
</body>
|
|
</html
|
|
`
|
|
}, (error, info) => {
|
|
if (error) {
|
|
console.error("Error sending email:", error);
|
|
} else {
|
|
console.log("Email sent successfully:", info.response);
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
|