import api from 'src/config/api';
import { type Pagination } from 'src/types/services';

import {
  type ConfirmSessionAttendanceParams,
  type GetSessionsParams,
  type Session,
  type SessionDetail,
} from './types';

export const getSessions = (params: GetSessionsParams) =>
  api.get<Pagination<Session[]>>('/learning-sessions', { params });

export const getSession = (id: number) =>
  api.get<SessionDetail>(`/learning-sessions/${id}`);

export const confirmSessionAttendance = (
  params: ConfirmSessionAttendanceParams,
) =>
  api.patch(`/learning-sessions/${params.learningSessionId}/attendance`, {
    assisted: params.assisted,
  });

export const getCertificate = (id: number | string) =>
  api.post<SessionDetail>(`/learning-sessions/${id}/cert-generation`);

export const getSessionICS = (id: number) =>
  api.get(`/learning-sessions/${id}/ics`);
