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

export const TASK_TYPE_ROUTES = {
    INDEX: "/api/task-types",
    BY_ID: "/api/task-types/{id}",
    SET_DEFAULT: "/api/set-default-task-type",
    REMOVE_DEFAULT: "/api/remove-default-task-type",
} as const satisfies Record<string, ApiPath>

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

    async setDefault(payload: ApiRequestBody<typeof TASK_TYPE_ROUTES.SET_DEFAULT, "post">) {
        return this.post(TASK_TYPE_ROUTES.SET_DEFAULT, payload)
    }

    async removeDefault(payload: ApiRequestBody<typeof TASK_TYPE_ROUTES.REMOVE_DEFAULT, "post">) {
        return this.post(TASK_TYPE_ROUTES.REMOVE_DEFAULT, payload)
    }
}
