import { type Activity } from "@/types/proto/api/v1/activity_service_pb";
import { fetchJson, parseResourceId } from "./apiClient";
import { activityFromApi } from "./converters";
import type { ApiActivity } from "./types";

export const activityServiceClient = {
  async listActivities(_request?: unknown): Promise<{ activities: Activity[]; nextPageToken: string }> {
    void _request;
    const data = await fetchJson<ApiActivity[]>("/activities", { method: "GET" });
    const activities = Array.isArray(data) ? data.map(activityFromApi) : [];
    return { activities, nextPageToken: "" };
  },
  async getActivity(request: { name: string }): Promise<Activity> {
    const activityId = parseResourceId(request.name);
    return activityFromApi({ id: activityId });
  },
};

