Restructure progress
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { getOAuthClient } from '$lib/google/server.js';
|
||||
import { googleAuthServer } from '$lib/google/server.ts';
|
||||
|
||||
export const POST: RequestHandler = async ({ request }) => {
|
||||
try {
|
||||
@@ -10,7 +10,7 @@ export const POST: RequestHandler = async ({ request }) => {
|
||||
return json({ error: 'Refresh token is required' }, { status: 400 });
|
||||
}
|
||||
|
||||
const oauth = getOAuthClient();
|
||||
const oauth = googleAuthServer.getOAuthClient();
|
||||
oauth.setCredentials({ refresh_token: refreshToken });
|
||||
|
||||
const { credentials } = await oauth.refreshAccessToken();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { getOAuthClient } from '$lib/google/server.js';
|
||||
import { googleAuthServer } from '$lib/google/server.ts';
|
||||
import { google } from 'googleapis';
|
||||
|
||||
export const GET: RequestHandler = async ({ request }) => {
|
||||
@@ -14,7 +14,7 @@ export const GET: RequestHandler = async ({ request }) => {
|
||||
const accessToken = authHeader.slice(7);
|
||||
|
||||
// Create OAuth client with the token
|
||||
const oauth = getOAuthClient();
|
||||
const oauth = googleAuthServer.getOAuthClient();
|
||||
oauth.setCredentials({ access_token: accessToken });
|
||||
|
||||
// Call the userinfo endpoint to get user details
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { getSpreadsheetData } from '$lib/google/server.js';
|
||||
import { sheets } from '$lib/google/index.js';
|
||||
|
||||
export const GET: RequestHandler = async ({ params, request }) => {
|
||||
try {
|
||||
@@ -12,7 +12,7 @@ export const GET: RequestHandler = async ({ params, request }) => {
|
||||
}
|
||||
|
||||
const refreshToken = authHeader.slice(7);
|
||||
const sheetData = await getSpreadsheetData(refreshToken, sheetId, 'A1:Z10');
|
||||
const sheetData = await sheets.getSpreadsheetData(refreshToken, sheetId, 'A1:Z10');
|
||||
|
||||
return json(sheetData);
|
||||
} catch (error) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { getRecentSpreadsheets } from '$lib/google/server.js';
|
||||
import { sheets } from '$lib/google/index.js';
|
||||
|
||||
export const GET: RequestHandler = async ({ request }) => {
|
||||
try {
|
||||
@@ -10,7 +10,7 @@ export const GET: RequestHandler = async ({ request }) => {
|
||||
}
|
||||
|
||||
const refreshToken = authHeader.slice(7);
|
||||
const spreadsheets = await getRecentSpreadsheets(refreshToken, 20);
|
||||
const spreadsheets = await sheets.getRecentSpreadsheets(refreshToken, 20);
|
||||
|
||||
return json(spreadsheets);
|
||||
} catch (error) {
|
||||
|
||||
0
src/routes/private/events/+page.server.ts
Normal file
0
src/routes/private/events/+page.server.ts
Normal file
@@ -1,85 +1,24 @@
|
||||
<script lang="ts">
|
||||
// Get the supabase client
|
||||
let { data } = $props();
|
||||
|
||||
// Create reactive states for events and loading
|
||||
let events = $state([]);
|
||||
let loading = $state(true);
|
||||
let error = $state(null);
|
||||
|
||||
// Load events when component mounts
|
||||
$effect(() => {
|
||||
loadEvents();
|
||||
});
|
||||
|
||||
async function loadEvents() {
|
||||
loading = true;
|
||||
error = null;
|
||||
|
||||
try {
|
||||
const { data: eventsData, error: supabaseError } = await data.supabase
|
||||
.from('events')
|
||||
.select('*')
|
||||
.order('date', { ascending: false });
|
||||
|
||||
if (supabaseError) throw supabaseError;
|
||||
|
||||
events = eventsData || [];
|
||||
} catch (err) {
|
||||
console.error('Error fetching events:', err);
|
||||
error = 'Failed to load events';
|
||||
} finally {
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
export let data;
|
||||
</script>
|
||||
|
||||
<h1 class="text-2xl font-bold mb-4 mt-2 text-center">All Events</h1>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 max-w-2xl mx-auto">
|
||||
{#if loading}
|
||||
<!-- Loading placeholders -->
|
||||
{#each Array(4) as _}
|
||||
<div class="border border-gray-300 rounded bg-white p-4 animate-pulse">
|
||||
<div class="flex flex-col gap-1">
|
||||
<div class="h-5 bg-gray-200 rounded w-3/4 mb-2"></div>
|
||||
<div class="h-4 bg-gray-100 rounded w-1/2"></div>
|
||||
</div>
|
||||
{#each data.events as event}
|
||||
<a
|
||||
href={`/private/events/event?id=${event.id}`}
|
||||
class="block border border-gray-300 rounded bg-white p-4 shadow-none transition cursor-pointer hover:border-blue-500 group"
|
||||
>
|
||||
<div class="flex flex-col gap-1">
|
||||
<span class="font-semibold text-lg text-black-700 group-hover:underline">{event.name}</span>
|
||||
<span class="text-gray-500 text-sm">{event.date}</span>
|
||||
</div>
|
||||
{/each}
|
||||
{:else if error}
|
||||
<!-- Error state -->
|
||||
<div class="col-span-full text-center p-4 text-red-600">
|
||||
{error}
|
||||
<button
|
||||
onclick={loadEvents}
|
||||
class="ml-2 text-blue-600 underline"
|
||||
>
|
||||
Try again
|
||||
</button>
|
||||
</div>
|
||||
{:else if events.length === 0}
|
||||
<!-- Empty state -->
|
||||
<div class="col-span-full text-center p-4 text-gray-500">
|
||||
No events found
|
||||
</div>
|
||||
{:else}
|
||||
<!-- Events list -->
|
||||
{#each events as event}
|
||||
<a
|
||||
href={`/private/events/event?id=${event.id}`}
|
||||
class="block border border-gray-300 rounded bg-white p-4 shadow-none transition cursor-pointer hover:border-blue-500 group"
|
||||
>
|
||||
<div class="flex flex-col gap-1">
|
||||
<span class="font-semibold text-lg text-black-700 group-hover:underline">{event.name}</span>
|
||||
<span class="text-gray-500 text-sm">{event.date}</span>
|
||||
</div>
|
||||
</a>
|
||||
{/each}
|
||||
{/if}
|
||||
</a>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<a
|
||||
href="/private/events/event/new"
|
||||
href="/private/creator"
|
||||
class="fixed bottom-6 left-1/2 -translate-x-1/2 z-50 bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-8 rounded-full shadow-none border border-gray-300"
|
||||
>
|
||||
New Event
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { isTokenValid, refreshAccessToken, getUserInfo, revokeToken } from '$lib/google/client.js';
|
||||
import type { GoogleSheet } from '$lib/google/client/types.js';
|
||||
import { isTokenValid, getUserInfo, revokeToken } from '$lib/google/auth/client.js';
|
||||
import type { GoogleSheet } from '$lib/google/sheets/client.js';
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
// Import Components
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import type { GoogleSheet } from '$lib/google/client/types.js';
|
||||
import type { GoogleSheet } from '$lib/google/sheets';
|
||||
|
||||
// Props
|
||||
let { sheetsData, errors, loadRecentSheets, selectSheet, toggleSheetList } = $props<{
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
import QRScanner from './QRScanner.svelte';
|
||||
import TicketDisplay from './TicketDisplay.svelte';
|
||||
|
||||
import type { TicketData } from '$lib/types';
|
||||
import { ScanState, defaultTicketData } from '$lib/types';
|
||||
import type { TicketData } from '$lib/types/types';
|
||||
import { ScanState, defaultTicketData } from '$lib/types/types';
|
||||
|
||||
let { data } = $props();
|
||||
let scanned_id = $state<string>("");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import type { TicketData } from '$lib/types';
|
||||
import { ScanState } from '$lib/types';
|
||||
import type { TicketData } from '$lib/types/types';
|
||||
import { ScanState } from '$lib/types/types';
|
||||
|
||||
let { ticket_data, scan_state }: { ticket_data: TicketData; scan_state: ScanState } = $props();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user