Skip to content

Instantly share code, notes, and snippets.

@oomusou
Created February 14, 2019 05:27
Show Gist options
  • Save oomusou/85bccece851ded1b145687e3aa747411 to your computer and use it in GitHub Desktop.
Save oomusou/85bccece851ded1b145687e3aa747411 to your computer and use it in GitHub Desktop.
import { pipe, gt, any, not, either, propEq } from 'ramda';
import { getGetter, renderState, getState } from '@/helpers/vuex';
import { paymentEnum } from '@/constant/payment-info';
/** 由 [取得運費 + 應付金額] API 取得 [分期門檻] */
const installmentLimit = renderState('AmountDetail', 'installmentLimit');
/** 小於 [信用卡分期門檻] */
const lessThanInstallmentLimit = pipe(
getGetter('AmountDetail', 'realAmount'),
gt(installmentLimit),
);
/** PaymentInfo 的 payments 天生就沒有 [信用卡分期] */
const noIstallmentInPayments = pipe(
getState('PaymentInfo', 'payments'),
any(propEq('payment', paymentEnum.creditCardInstallment)),
not,
);
/** 小於 [信用卡分期門檻] */
/** 或 */
/** PaymentInfo 的 payments 天生就沒有 [信用卡分期] */
/** 就顯示提示訊息 */
export const isShowDesc = either(
lessThanInstallmentLimit,
noIstallmentInPayments,
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment