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

export const DEPARTMENT_ROUTES = {
    INDEX: "/api/departments",
    BY_ID: "/api/departments/{id}",
    SET_FAVORITE: "/api/set-favorite-department",
    REMOVE_FAVORITE: "/api/remove-favorite-department",
} as const satisfies Record<string, ApiPath>

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

    async setFavorite(payload: ApiRequestBody<typeof DEPARTMENT_ROUTES.SET_FAVORITE, "post">) {
        return this.post(DEPARTMENT_ROUTES.SET_FAVORITE, payload)
    }

    async removeFavorite(payload: ApiRequestBody<typeof DEPARTMENT_ROUTES.REMOVE_FAVORITE, "post">) {
        return this.post(DEPARTMENT_ROUTES.REMOVE_FAVORITE, payload)
    }
}
