Implement resolution submission API, initialize Airtable integration, and update package dependencies.

This commit is contained in:
Dhamari Trice-Hanson 2026-01-02 15:44:09 -05:00
parent 12625e973d
commit 894cdb9bd3
3 changed files with 1642 additions and 0 deletions

1597
resolution-frontend/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,13 @@
import Airtable from 'airtable';
import { AIRTABLE_API_TOKEN, AIRTABLE_BASE_ID } from '$env/static/private';
if (!AIRTABLE_API_TOKEN) {
throw new Error('AIRTABLE_API_TOKEN is not defined in .env');
}
if (!AIRTABLE_BASE_ID) {
throw new Error('AIRTABLE_BASE_ID is not defined in .env');
}
const client = new Airtable({ apiKey: AIRTABLE_API_TOKEN });
export const base = client.base(AIRTABLE_BASE_ID);

View file

@ -0,0 +1,32 @@
import { AIRTABLE_API_TOKEN, AIRTABLE_BASE_ID, AIRTABLE_TABLE_ID } from '$env/static/private';
import Airtable from 'airtable';
import { json } from '@sveltejs/kit';
export async function POST({ request, getClientAddress }) {
try {
const { email } = await request.json();
const ip = getClientAddress();
if (!email) {
return json({ error: 'Email is required' }, { status: 400 });
}
console.log(`Submitting email: ${email} from IP: ${ip}`);
const base = new Airtable({ apiKey: AIRTABLE_API_TOKEN }).base(AIRTABLE_BASE_ID);
await base(AIRTABLE_TABLE_ID).create([
{
"fields": {
"Email": email,
"IP-Addres": ip
}
}
]);
return json({ success: true });
} catch (err) {
console.error('Airtable submission error:', err);
return json({ error: 'Failed to submit application. Please try again.' }, { status: 500 });
}
}