/**
 * @desc 批量生成条形码
 */
import { defaultSuccess, defaultError, http } from '@/plugins/axios'
import type { AxiosResponse } from 'axios'
export interface Params {
	/** 条形码数量 */
	count: number
}

export default async function (
	/** 物料id */
	id: number,

	params: Params,
	success: (data: Array<string>) => void = defaultSuccess,
	fail: (error: { code: string; error?: string }) => void = defaultError,
): Promise<void> {
	return http({
		method: 'post',
		url: `/material/${id}/generate-barcodes`,

		params,
	})
		.then((data: AxiosResponse<Array<string>, unknown>) => {
			success(data.data)
		})
		.catch((error: { code: string; error?: string }) => fail(error))
}
