mirror of
https://github.com/System-End/campfire.git
synced 2026-04-19 23:22:56 +00:00
feat: better error comms
This commit is contained in:
parent
2dc42d2fa6
commit
b0f905ceb9
4 changed files with 23 additions and 5 deletions
|
|
@ -7,9 +7,10 @@ const FORM_URL_SIGN_UP = "https://forms.hackclub.com/campfire-signup";
|
|||
interface UnderConstructionProps {
|
||||
event_name: string;
|
||||
record_id?: string;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
function UnderConstruction({ event_name, record_id }: UnderConstructionProps) {
|
||||
function UnderConstruction({ event_name, record_id, error = "" }: UnderConstructionProps) {
|
||||
const [email, setEmail] = useState("");
|
||||
const emailRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
|
|
@ -86,7 +87,7 @@ function UnderConstruction({ event_name, record_id }: UnderConstructionProps) {
|
|||
textShadow: "5px 8px 0px rgba(0,0,0,0.25)"
|
||||
}}
|
||||
>
|
||||
{event_name.toUpperCase()}
|
||||
{event_name.toUpperCase().replaceAll("-", " ").replace("CAMPFIRE", "")}
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -98,7 +99,13 @@ function UnderConstruction({ event_name, record_id }: UnderConstructionProps) {
|
|||
textShadow: "0px 4px 4px rgba(0,0,0,0.25)"
|
||||
}}
|
||||
>
|
||||
This event is confirmed, but we’re still finalizing the exact schedule! The site will be live in 3-4 business days
|
||||
{
|
||||
error ? (
|
||||
<>
|
||||
This site is temporarily down! <br /> (Organizers: {error})
|
||||
</>
|
||||
) : "This event is confirmed, but we’re still finalizing the exact schedule! The site will be live in 3-4 business days"
|
||||
}
|
||||
</p>
|
||||
<p
|
||||
className="text-white text-4xl md:text-3xl xl:text-4xl font-bold font-ember-and-fire text-center"
|
||||
|
|
|
|||
|
|
@ -170,6 +170,7 @@ export async function getSatelliteData(slug: string) {
|
|||
// }
|
||||
|
||||
export type SatelliteContent = {
|
||||
error?: string;
|
||||
localization: {
|
||||
hero: {
|
||||
campfire: string;
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ const satelliteData = await getSatelliteData(slug);
|
|||
|
||||
</head>
|
||||
<body>
|
||||
{!satelliteData?.active && <UnderConstruction client:only="react" event_name={slug} record_id={satelliteData?.recordId} />}
|
||||
{(!satelliteData?.active || (satelliteData.data as SatelliteContent).error) && <UnderConstruction client:only="react" event_name={slug} record_id={satelliteData?.recordId} error={(satelliteData?.data as SatelliteContent)?.error || ""} />}
|
||||
{satelliteData?.active && <Satellite client:only="react" slug={slug} content={satelliteData.data as SatelliteContent} />}
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import 'dotenv/config';
|
||||
import Airtable from 'airtable';
|
||||
import { prisma } from './prisma';
|
||||
import { error } from 'node:console';
|
||||
|
||||
Airtable.configure({
|
||||
apiKey: process.env.AIRTABLE_API_KEY,
|
||||
|
|
@ -23,6 +24,8 @@ export async function listOfEventWebsiteData() {
|
|||
|
||||
const POLL_INTERVAL = parseInt(process.env.AIRTABLE_POLL_INTERVAL || '300000', 10);
|
||||
|
||||
const VERSION = 2;
|
||||
|
||||
class AirtableSyncWorker {
|
||||
private intervalId: NodeJS.Timeout | null = null;
|
||||
private isRunning = false;
|
||||
|
|
@ -48,9 +51,16 @@ class AirtableSyncWorker {
|
|||
let data: any;
|
||||
try {
|
||||
data = websiteJson ? JSON.parse(websiteJson) : {};
|
||||
if (websiteActive && data.version !== VERSION) {
|
||||
data = {
|
||||
error: "Your JSON is outdated. Please update it!"
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error parsing JSON for slug ${slug}:`, error);
|
||||
data = {};
|
||||
data = {
|
||||
error: "Error parsing JSON. Make sure the JSON is valid!"
|
||||
};
|
||||
}
|
||||
|
||||
await prisma.satellite.upsert({
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue