import { CustomPrintCalculationApi } from '@/api/codeManage'

export default () => {
  const { fetchData: customPrintCalculationApi } = CustomPrintCalculationApi()
  // 更新合计数据
  const updateCustomOrderTotal = (updateData) => {
    return async(dispatch) => {
      const res = await customPrintCalculationApi(updateData)
      if (res.success) {
        dispatch({
          type: 'setCustomTotal',
          data: {
            total_weight_error: res?.data?.total_weight_error,
            otal_sale_weight: res?.data?.total_sale_weight,
            total_amount: res?.data?.total_amount,
          },
        })
      }
    }
  }
  return {
    updateCustomOrderTotal,
  }
}
