Advertisement
mhamdani049

actions / metodePembayaran.js

Jun 16th, 2021
705
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import Promise from 'promise';
  2. import { fieldValidation } from './registrasi';
  3. import { setToastMessage } from './statusRequest';
  4. import { getPaymentLogo, sprintf } from '../utils/Functions';
  5. import lang from '../lang';
  6.  
  7. /**
  8.  * Load metode pembayaran
  9.  */
  10. export const loadMetodePembayaran = () => () => new Promise((resolve) => {
  11.     resolve({
  12.         status: '',
  13.         message: '',
  14.         data: [
  15.             {
  16.                 id: '1',
  17.                 name: 'G-Cash BNI',
  18.                 icon: getPaymentLogo('gCashBNI'),
  19.                 selected: true
  20.             },
  21.             {
  22.                 id: '2',
  23.                 name: 'G-Cash BRI',
  24.                 icon: getPaymentLogo('gCashBRI'),
  25.                 selected: false
  26.             },
  27.             {
  28.                 id: '3',
  29.                 name: 'ShopeePay',
  30.                 icon: getPaymentLogo('shopeepay'),
  31.                 selected: false
  32.             }
  33.         ]
  34.     });
  35. });
  36.  
  37. /**
  38.  * Load rekening
  39.  */
  40. export const loadRekening = () => () => new Promise((resolve) => {
  41.     resolve({
  42.         status: '',
  43.         message: '',
  44.         data: [
  45.             {
  46.                 id: '1',
  47.                 title: 'ShopeePay',
  48.                 subtitle: 'Rp 10.000.000 (500.000 koin)'
  49.             },
  50.             {
  51.                 id: '2',
  52.                 title: 'G-Cash BRI',
  53.                 subtitle: 'Rp 50.000'
  54.             }
  55.         ]
  56.     });
  57. });
  58.  
  59. /**
  60.  * Delete metode pembayaran
  61.  */
  62. export const deleteMetodePembayaran = (params) => (dispatch) => new Promise((resolve) => {
  63.     dispatch(
  64.         setToastMessage(
  65.             sprintf(
  66.                 lang.metodePembayaranXBerhasilDihapus,
  67.                 params.title
  68.             ),
  69.             'success'
  70.         )
  71.     );
  72.     resolve({
  73.         status: '',
  74.         message: '',
  75.         data: null
  76.     });
  77. });
  78.  
  79. export const postValidasiMetodePembayaran = (param) => () => new Promise((resolve, reject) => {
  80.     if (__DEV__) console.log('METODE PEMBAYARAN PAYLOAD', param);
  81.     const fields = [{
  82.         key: 'handphone', label: lang.nomorHandphone, regexType: 'phone', value: param.handphone
  83.     }];
  84.  
  85.     fieldValidation(fields).then(() => {
  86.         resolve({
  87.             status: '',
  88.             message: '',
  89.             data: null
  90.         });
  91.     }).catch((errorJSON) => {
  92.         reject(errorJSON);
  93.     });
  94. });
  95.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement