import { CrudClient } from "../infra/crud-client"
import { type ApiClientOptions } from "../infra/client"
import type { ApiPath, ApiRequestBody } from "../infra/types"

export const TIME_SHEET_ROUTES = {
    INDEX: "/api/time-sheets",
    BY_ID: "/api/time-sheets/{id}",
    CLOCK_IN: "/api/time-sheet/clock-in",
    CLOCK_OUT: "/api/time-sheet/clock-out",
} as const satisfies Record<string, ApiPath>

export class TimeSheetsClient extends CrudClient<
    typeof TIME_SHEET_ROUTES.INDEX,
    typeof TIME_SHEET_ROUTES.BY_ID
> {
    constructor(baseUrl?: string, defaultOptions?: ApiClientOptions) {
        super(baseUrl, defaultOptions, TIME_SHEET_ROUTES.INDEX, TIME_SHEET_ROUTES.BY_ID)
    }

    async clockIn(payload: ApiRequestBody<typeof TIME_SHEET_ROUTES.CLOCK_IN, "post">) {
        return this.post(TIME_SHEET_ROUTES.CLOCK_IN, payload)
    }

    async clockOut(payload: ApiRequestBody<typeof TIME_SHEET_ROUTES.CLOCK_OUT, "post">) {
        return this.post(TIME_SHEET_ROUTES.CLOCK_OUT, payload)
    }
}
