feat(web): wire calendar page to real API data (#474)
Some checks failed
ci/woodpecker/push/web Pipeline failed
Some checks failed
ci/woodpecker/push/web Pipeline failed
Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
This commit was merged in pull request #474.
This commit is contained in:
@@ -7,84 +7,51 @@ import type { Event } from "@mosaic/shared";
|
||||
import { apiGet, type ApiResponse } from "./client";
|
||||
|
||||
export interface EventFilters {
|
||||
startDate?: Date;
|
||||
endDate?: Date;
|
||||
workspaceId?: string;
|
||||
/** Filter events starting from this date (inclusive) */
|
||||
startFrom?: Date;
|
||||
/** Filter events starting up to this date (inclusive) */
|
||||
startTo?: Date;
|
||||
/** Filter by project ID */
|
||||
projectId?: string;
|
||||
/** Filter by all-day events */
|
||||
allDay?: boolean;
|
||||
/** Page number (1-based) */
|
||||
page?: number;
|
||||
/** Items per page (max 100) */
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch events with optional filters
|
||||
*
|
||||
* @param workspaceId - Workspace ID sent via X-Workspace-Id header
|
||||
* @param filters - Optional query parameter filters
|
||||
*/
|
||||
export async function fetchEvents(filters?: EventFilters): Promise<Event[]> {
|
||||
export async function fetchEvents(workspaceId?: string, filters?: EventFilters): Promise<Event[]> {
|
||||
const params = new URLSearchParams();
|
||||
|
||||
if (filters?.startDate) {
|
||||
params.append("startDate", filters.startDate.toISOString());
|
||||
if (filters?.startFrom) {
|
||||
params.append("startFrom", filters.startFrom.toISOString());
|
||||
}
|
||||
if (filters?.endDate) {
|
||||
params.append("endDate", filters.endDate.toISOString());
|
||||
if (filters?.startTo) {
|
||||
params.append("startTo", filters.startTo.toISOString());
|
||||
}
|
||||
if (filters?.workspaceId) {
|
||||
params.append("workspaceId", filters.workspaceId);
|
||||
if (filters?.projectId) {
|
||||
params.append("projectId", filters.projectId);
|
||||
}
|
||||
if (filters?.allDay !== undefined) {
|
||||
params.append("allDay", String(filters.allDay));
|
||||
}
|
||||
if (filters?.page !== undefined) {
|
||||
params.append("page", String(filters.page));
|
||||
}
|
||||
if (filters?.limit !== undefined) {
|
||||
params.append("limit", String(filters.limit));
|
||||
}
|
||||
|
||||
const queryString = params.toString();
|
||||
const endpoint = queryString ? `/api/events?${queryString}` : "/api/events";
|
||||
|
||||
const response = await apiGet<ApiResponse<Event[]>>(endpoint);
|
||||
const response = await apiGet<ApiResponse<Event[]>>(endpoint, workspaceId);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mock events for development (until backend endpoints are ready)
|
||||
*/
|
||||
export const mockEvents: Event[] = [
|
||||
{
|
||||
id: "event-1",
|
||||
title: "Team standup",
|
||||
description: "Daily sync meeting",
|
||||
startTime: new Date("2026-01-29T10:00:00"),
|
||||
endTime: new Date("2026-01-29T10:30:00"),
|
||||
allDay: false,
|
||||
location: "Zoom",
|
||||
recurrence: null,
|
||||
creatorId: "user-1",
|
||||
workspaceId: "workspace-1",
|
||||
projectId: null,
|
||||
metadata: {},
|
||||
createdAt: new Date("2026-01-28"),
|
||||
updatedAt: new Date("2026-01-28"),
|
||||
},
|
||||
{
|
||||
id: "event-2",
|
||||
title: "Project review",
|
||||
description: "Quarterly project review session",
|
||||
startTime: new Date("2026-01-30T14:00:00"),
|
||||
endTime: new Date("2026-01-30T15:30:00"),
|
||||
allDay: false,
|
||||
location: "Conference Room A",
|
||||
recurrence: null,
|
||||
creatorId: "user-1",
|
||||
workspaceId: "workspace-1",
|
||||
projectId: null,
|
||||
metadata: {},
|
||||
createdAt: new Date("2026-01-28"),
|
||||
updatedAt: new Date("2026-01-28"),
|
||||
},
|
||||
{
|
||||
id: "event-3",
|
||||
title: "Focus time",
|
||||
description: "Dedicated time for deep work",
|
||||
startTime: new Date("2026-01-31T09:00:00"),
|
||||
endTime: new Date("2026-01-31T12:00:00"),
|
||||
allDay: false,
|
||||
location: null,
|
||||
recurrence: null,
|
||||
creatorId: "user-1",
|
||||
workspaceId: "workspace-1",
|
||||
projectId: null,
|
||||
metadata: {},
|
||||
createdAt: new Date("2026-01-28"),
|
||||
updatedAt: new Date("2026-01-28"),
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user