feat(events): Add comprehensive events management with dynamic fetching and UI
- Integrate Reka UI Tabs component for event browsing - Create useEvents composable for event data management - Implement events API integration with error handling - Add events page with upcoming and past events sections - Configure environment variables for API connection - Add internationalization support for events navigation
This commit is contained in:
parent
b8868f7971
commit
b8c881dea2
14 changed files with 316 additions and 7 deletions
28
src/lib/api/events.ts
Normal file
28
src/lib/api/events.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import type { Event, EventsApiError } from '../types/event'
|
||||
|
||||
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || 'http://lnbits'
|
||||
const API_KEY = import.meta.env.VITE_API_KEY
|
||||
|
||||
export async function fetchEvents(allWallets = true): Promise<Event[]> {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${API_BASE_URL}/events/api/v1/events?all_wallets=${allWallets}`,
|
||||
{
|
||||
headers: {
|
||||
'accept': 'application/json',
|
||||
'X-API-KEY': API_KEY,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
if (!response.ok) {
|
||||
const error: EventsApiError = await response.json()
|
||||
throw new Error(error.detail[0]?.msg || 'Failed to fetch events')
|
||||
}
|
||||
|
||||
return await response.json() as Event[]
|
||||
} catch (error) {
|
||||
console.error('Error fetching events:', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue