diff --git a/src/App.tsx b/src/App.tsx
index f6ae8d2..4d32033 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,27 +1,17 @@
-import { Routes, Route } from "react-router-dom";
+import { useLoaderData } from "react-router-dom";
import Join from "@/routes/Join";
-import Layout from "@/components/Layout";
-import SecretWaitlistSkipper from "@/routes/SecretWaitlistSkipper";
import Home from "@/routes/Home";
-import Scanner from "@/routes/Scanner";
+import { WaitlistItem } from "./types";
function App() {
- let active = localStorage.getItem('active') || "";
+ const data = useLoaderData() as WaitlistItem | null;
+
return (
-
-
- {/* globals such as header will go here */}
-
-
- }>
- : } />
- } />
- } />
-
-
-
- );
+ <>
+ {data?.approval_date ? : }
+ >
+ )
}
export default App;
\ No newline at end of file
diff --git a/src/components/WaitlistAlreadyIn.tsx b/src/components/WaitlistAlreadyIn.tsx
index bccedfd..744c5e6 100644
--- a/src/components/WaitlistAlreadyIn.tsx
+++ b/src/components/WaitlistAlreadyIn.tsx
@@ -1,6 +1,5 @@
import Notes from "./Notes";
import { NostrProvider } from "nostr-react";
-import { useState } from "react";
const relayUrls = [
"wss://nostr.zebedee.cloud",
@@ -13,15 +12,6 @@ const relayUrls = [
]
export function WaitlistAlreadyIn() {
- const [skipCount, setSkipCount] = useState(0);
-
- function skipCounter() {
- setSkipCount(skipCount + 1);
- if (skipCount >= 6) {
- window.location.href = "/secretwaitlistskipper";
- }
- }
-
return (
You're on a list!
@@ -34,7 +24,6 @@ export function WaitlistAlreadyIn() {
- Skip
);
}
diff --git a/src/main.tsx b/src/main.tsx
index 3037eda..825a609 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -1,10 +1,31 @@
import ReactDOM from 'react-dom/client'
-import { BrowserRouter } from 'react-router-dom'
-import App from './App'
+import { createBrowserRouter, RouterProvider } from 'react-router-dom'
+import App from '@/App'
+import Scanner from '@/routes/Scanner';
import './index.css'
+import { fetchApprovedStatus } from './utils/fetchApprovedLoader';
+import Layout from './components/Layout';
+
+let waitlist_id = localStorage.getItem('waitlist_id')
+
+const router = createBrowserRouter([
+ {
+ path: "/",
+ element: ,
+ children: [
+ {
+ loader: async () => { return fetchApprovedStatus(waitlist_id || "") },
+ index: true,
+ element: ,
+ },
+ {
+ path: "scanner",
+ element: ,
+ },
+ ],
+ },
+]);
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
-
-
-
+
)
diff --git a/src/routes/SecretWaitlistSkipper.tsx b/src/routes/SecretWaitlistSkipper.tsx
deleted file mode 100644
index daaf76b..0000000
--- a/src/routes/SecretWaitlistSkipper.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-import button from "@/styles/button";
-import { useState } from "react";
-
-export default function SecretWaitlistSkipper() {
- const [active] = useState(localStorage.getItem('active') || "");
-
- function toggleSkipWaitlist() {
- // If active in localstorage is true, set to false, otherwie set to true
- if (active === "true") {
- localStorage.setItem("active", "false");
- } else {
- localStorage.setItem("active", "true");
- }
-
- // Redirect to index
- window.location.href = "/";
- }
- return (
-
-
- {active === "true" &&
- I love waiting, hate cheating
- }
- {active !== "true" &&
- I hate waiting, love cheating
- }
-
-
- )
-}
\ No newline at end of file
diff --git a/src/types/index.ts b/src/types/index.ts
new file mode 100644
index 0000000..cbc1a4b
--- /dev/null
+++ b/src/types/index.ts
@@ -0,0 +1,7 @@
+export type WaitlistItem = {
+ user_type: "nostr" | "email"
+ id: string
+ comment: string
+ date: string
+ approval_date: string
+}
\ No newline at end of file
diff --git a/src/utils/fetchApprovedLoader.ts b/src/utils/fetchApprovedLoader.ts
new file mode 100644
index 0000000..1cd13ab
--- /dev/null
+++ b/src/utils/fetchApprovedLoader.ts
@@ -0,0 +1,14 @@
+import { WaitlistItem } from "@/types";
+
+export async function fetchApprovedStatus(waitlistId: string): Promise {
+ // Fetch the waitlist status from the backend
+ // Will error if it doesn't exist so we just return undefined
+ try {
+ let res = await fetch(`https://waitlist.mutiny-waitlist.workers.dev/waitlist/${waitlistId}`)
+ let data = await res.json();
+ return data
+ } catch (e) {
+ console.error(e)
+ return null
+ }
+}
\ No newline at end of file