integrate read events from social layer into explore events, interests events tab, and map groups / related dao events to dao page. Merge with currents events.json on fetch and filter in with date. #51
Labels
feature-request
new feature request
Blocker
Read all events' filter based on activity
in future add event registration
Resources
// Import the node-fetch polyfill
import fetch, { Headers, Request, Response } from 'node-fetch';
// Assign fetch polyfills to global scope if not already defined
if (!globalThis.fetch) {
globalThis.fetch = fetch;
globalThis.Headers = Headers;
globalThis.Request = Request;
globalThis.Response = Response;
}
// Import necessary modules from graphql-request
import { gql, GraphQLClient } from 'graphql-request';
// Define the GraphQL client pointing to the API URL
const endpoint = 'https://graph.sola.day/v1/graphql';
const client = new GraphQLClient(endpoint);
// Define the GraphQL query for events starting from now to 24 hours later
const query = gql
query FetchUpcomingEvents($currentTime: timestamp!, $twentyFourHoursLater: timestamp!) { events( where: { display: {_neq: "private"}, start_time: {_gte: $currentTime, _lte: $twentyFourHoursLater}, status: {_in: ["open", "new", "normal"]} }, order_by: {start_time: asc}, limit: 10 ) { id title start_time end_time location participants_count cover_url owner { username image_url } } }
;// Function to fetch upcoming events
async function fetchUpcomingEvents() {
const currentTime = new Date().toISOString();
const twentyFourHoursLater = new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString();
const variables = {
currentTime: currentTime.split('.')[0] + 'Z',
twentyFourHoursLater: twentyFourHoursLater.split('.')[0] + 'Z'
};
try {
const data = await client.request(query, variables);
return data;
} catch (error) {
console.error('Error fetching events:', error);
}
}
// Fetch and display upcoming events
const eventData = await fetchUpcomingEvents();
console.log(eventData);
// Export the function for external usage
export { fetchUpcomingEvents };
The text was updated successfully, but these errors were encountered: