import {api} from "./api";
import {requests} from "../../requests";
import {getComparator} from "../../components/core/getComparator";

class GlassClient {

    getGlassList(setGlass, createError) {
        api().get(requests.glass.list)
            .then((r) => setGlass(r.data.sort(getComparator())
                .map((item, i) => {
                    return {id: i, name: item}
                })))
            .catch(() => createError("Ошибка получения посуды"))
    }
}

export const glassClient = new GlassClient();