/**
 * @desc 增加/更新地区
 */
import { defaultSuccess, defaultError, http } from '@/plugins/axios'
import type { AxiosResponse } from 'axios'
export default async function (
	/** 请求体 */
	requestBody: material.Type,

	success: (data: material.Type) => void = defaultSuccess,
	fail: (error: { code: string; error?: string }) => void = defaultError,
): Promise<void> {
	return http({
		method: 'post',
		url: `/area`,
		data: requestBody,
	})
		.then((data: AxiosResponse<material.Type, unknown>) => {
			success(data.data)
		})
		.catch((error: { code: string; error?: string }) => fail(error))
}
