diff --git a/website/app/routes/app-announcements.tsx b/website/app/routes/app-announcements.tsx index 6c36ec6..15dc75c 100644 --- a/website/app/routes/app-announcements.tsx +++ b/website/app/routes/app-announcements.tsx @@ -1,7 +1,5 @@ -import { trace } from '@opentelemetry/api' import { json } from '@remix-run/server-runtime' import { CACHE_CONTROL } from '~/lib/http.server' -import { resolveError } from '~/lib/resolve-error' export type GoogleFormUpdates = { Timestamp: string @@ -10,45 +8,60 @@ export type GoogleFormUpdates = { /** This route is used by the app for on the day announcements */ export async function loader() { - const apiKey = process.env.GOOGLE_FORMS_API_KEY - const fileId = process.env.GOOGLE_FORMS_FILE_ID - if (!apiKey || !fileId) { - return new Response(JSON.stringify({ message: 'No Google Forms API key or form ID' }), { status: 404 }) - } + // const apiKey = process.env.GOOGLE_FORMS_API_KEY + // const fileId = process.env.GOOGLE_FORMS_FILE_ID + // if (!apiKey || !fileId) { + // return new Response(JSON.stringify({ message: 'No Google Forms API key or form ID' }), { status: 404 }) + // } - try { - const BASE_URL = `https://www.googleapis.com/drive/v3/files/${fileId}?alt=media&key=${apiKey}` + // try { + // const BASE_URL = `https://www.googleapis.com/drive/v3/files/${fileId}?alt=media&key=${apiKey}` - const response = await fetch(BASE_URL, { - headers: { - 'Content-Type': 'application/json', - Accept: 'application/json', - }, - }) + // const response = await fetch(BASE_URL, { + // headers: { + // 'Content-Type': 'application/json', + // Accept: 'application/json', + // }, + // }) - const responseData = (await response.json()) as GoogleFormUpdates[] + // const responseData = (await response.json()) as GoogleFormUpdates[] - const announcementData = responseData - .map((row) => { - return { createdTime: row.Timestamp, update: row.Message } - }) - .sort((a, b) => { - return new Date(b.createdTime).getTime() - new Date(a.createdTime).getTime() - }) + // const announcementData = responseData + // .map((row) => { + // return { createdTime: row.Timestamp, update: row.Message } + // }) + // .sort((a, b) => { + // return new Date(b.createdTime).getTime() - new Date(a.createdTime).getTime() + // }) - return json(announcementData, { - headers: { - 'Cache-Control': CACHE_CONTROL.announce, - 'Access-Control-Allow-Origin': '*', + // return json(announcementData, { + // headers: { + // 'Cache-Control': CACHE_CONTROL.announce, + // 'Access-Control-Allow-Origin': '*', + // }, + // }) + // } catch (err) { + // trace.getActiveSpan()?.recordException(resolveError(err)) + // return json([], { + // headers: { + // 'Cache-Control': CACHE_CONTROL.announce, + // 'Access-Control-Allow-Origin': '*', + // }, + // }) + // } + + return json( + [ + { + createdTime: new Date().toISOString(), + update: 'Get your 2024 Yearbook from the Info Desk!', }, - }) - } catch (err) { - trace.getActiveSpan()?.recordException(resolveError(err)) - return json([], { + ], + { headers: { 'Cache-Control': CACHE_CONTROL.announce, 'Access-Control-Allow-Origin': '*', }, - }) - } + }, + ) }