import { api } from "@/lib/api-client";
import type { Activity, ActivityType, ActivityCreateRequest } from "@/types/activity";
import type { PaginatedResponse, PaginationParams, ApiSuccessResponse } from "@/types";

export const activityService = {
  async listActivities(params?: PaginationParams): Promise<PaginatedResponse<Activity>> {
    return api.get<PaginatedResponse<Activity>>("/activities", params as Record<string, string | number | boolean | undefined>);
  },

  async createActivity(data: ActivityCreateRequest): Promise<Activity> {
    return api.post<Activity>("/activities", data);
  },

  async updateActivity(id: number, data: Partial<ActivityCreateRequest>): Promise<Activity> {
    return api.patch<Activity>(`/activities/${id}`, data);
  },

  async deleteActivity(id: number): Promise<ApiSuccessResponse> {
    return api.delete<ApiSuccessResponse>(`/activities/${id}`);
  },

  async listActivityTypes(params?: PaginationParams): Promise<PaginatedResponse<ActivityType>> {
    return api.get<PaginatedResponse<ActivityType>>("/activity-types", params as Record<string, string | number | boolean | undefined>);
  },

  async createActivityType(data: Pick<ActivityType, "name">): Promise<ActivityType> {
    return api.post<ActivityType>("/activity-types", data);
  },

  async deleteActivityType(id: number): Promise<ApiSuccessResponse> {
    return api.delete<ApiSuccessResponse>(`/activity-types/${id}`);
  },
};
