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

export const TASK_SECTION_ROUTES = {
    INDEX: "/api/task-sections",
    BY_ID: "/api/task-sections/{id}",
    SET_DEFAULT: "/api/set-default-task-section",
    REMOVE_DEFAULT: "/api/remove-default-task-section",
    CHANGE_ARRANGEMENT: "/api/change-task-section-arrangement",
} as const satisfies Record<string, ApiPath>

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

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

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

    async changeSectionArrangement(payload: ApiRequestBody<typeof TASK_SECTION_ROUTES.CHANGE_ARRANGEMENT, "post">) {
        return this.post(TASK_SECTION_ROUTES.CHANGE_ARRANGEMENT, payload)
    }
}
