sheba cardtocard online
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
VITE_TOKEN_NAME = 'dsc_token'
|
VITE_TOKEN_NAME = 'dsc_token'
|
||||||
VITE_REFRESH_TOKEN_NAME = 'dsc_refresh_token'
|
VITE_REFRESH_TOKEN_NAME = 'dsc_refresh_token'
|
||||||
# VITE_BASE_URL = 'https://danak-dsc-api.run.danakcorp.com'
|
VITE_BASE_URL = 'https://danak-dsc-api.run.danakcorp.com'
|
||||||
VITE_BASE_URL = 'http://192.168.0.221:4000'
|
# VITE_BASE_URL = 'http://192.168.0.221:4000'
|
||||||
+3
-1
@@ -277,12 +277,14 @@
|
|||||||
"submit_slip": "ثبت فیش",
|
"submit_slip": "ثبت فیش",
|
||||||
"sheba": "شبا",
|
"sheba": "شبا",
|
||||||
"pay_sheba": "پرداخت شبا",
|
"pay_sheba": "پرداخت شبا",
|
||||||
|
"select_sheba": "انتخاب شماره شبا",
|
||||||
"enter_sheba_deposit": "مبلغ شبا شده شده را وارد کنید",
|
"enter_sheba_deposit": "مبلغ شبا شده شده را وارد کنید",
|
||||||
"all_cards": "تمام کارت های عضو شتاب",
|
"all_cards": "تمام کارت های عضو شتاب",
|
||||||
"error_select_price": "لطفا مبلغ مورد نظر خود را انتخاب کنید",
|
"error_select_price": "لطفا مبلغ مورد نظر خود را انتخاب کنید",
|
||||||
"error_min_price": "حداقل مبلغ ۱۰۰ هزار تومان می باشد",
|
"error_min_price": "حداقل مبلغ ۱۰۰ هزار تومان می باشد",
|
||||||
"transfer_to_getway": "در حال انتقال به درگاه پرداخت",
|
"transfer_to_getway": "در حال انتقال به درگاه پرداخت",
|
||||||
"select_bank_account": "انتخاب کارت"
|
"select_bank_account": "انتخاب کارت",
|
||||||
|
"successful_transfer": "درخواست انتقال وجه با موفقیت انجام شد"
|
||||||
},
|
},
|
||||||
"notif": {
|
"notif": {
|
||||||
"natification": "اعلان ها"
|
"natification": "اعلان ها"
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { useFormik } from 'formik'
|
|||||||
import { DepositTransferType } from '../types/WalletTypes'
|
import { DepositTransferType } from '../types/WalletTypes'
|
||||||
import * as Yup from 'yup'
|
import * as Yup from 'yup'
|
||||||
import { useSingleUpload } from '../../ticket/hooks/useTicketData'
|
import { useSingleUpload } from '../../ticket/hooks/useTicketData'
|
||||||
|
import { toast } from 'react-toastify'
|
||||||
|
|
||||||
const CardtoCard: FC = () => {
|
const CardtoCard: FC = () => {
|
||||||
|
|
||||||
@@ -36,7 +37,13 @@ const CardtoCard: FC = () => {
|
|||||||
formData.append('file', file)
|
formData.append('file', file)
|
||||||
upload.mutate(formData, {
|
upload.mutate(formData, {
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
depositTransfer.mutate({ ...values, transferReceiptUrl: data.data.url })
|
depositTransfer.mutate({ ...values, amount: +values.amount, transferReceiptUrl: data.data.url }, {
|
||||||
|
onSuccess: () => {
|
||||||
|
formik.resetForm()
|
||||||
|
setFile(undefined)
|
||||||
|
toast.success(t('wallet.successful_transfer'))
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,95 @@
|
|||||||
import { FC } from 'react'
|
import { FC, Fragment, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import Input from '../../../components/Input'
|
import Input from '../../../components/Input'
|
||||||
import UploadBox from '../../../components/UploadBox'
|
import UploadBox from '../../../components/UploadBox'
|
||||||
import Button from '../../../components/Button'
|
import Button from '../../../components/Button'
|
||||||
|
import { useDepositTransfer, useGetBankAccount } from '../hooks/useWalletData'
|
||||||
|
import Select from '../../../components/Select'
|
||||||
|
import PageLoading from '../../../components/PageLoading'
|
||||||
|
import { useFormik } from 'formik'
|
||||||
|
import { DepositTransferType } from '../types/WalletTypes'
|
||||||
|
import * as Yup from 'yup'
|
||||||
|
import { useSingleUpload } from '../../ticket/hooks/useTicketData'
|
||||||
|
import { toast } from 'react-toastify'
|
||||||
|
|
||||||
const Sheba: FC = () => {
|
const CardtoCard: FC = () => {
|
||||||
|
|
||||||
const { t } = useTranslation('global')
|
const { t } = useTranslation('global')
|
||||||
|
const getBankAccount = useGetBankAccount()
|
||||||
|
const depositTransfer = useDepositTransfer()
|
||||||
|
const upload = useSingleUpload()
|
||||||
|
const [file, setFile] = useState<File>()
|
||||||
|
|
||||||
|
const formik = useFormik<DepositTransferType>({
|
||||||
|
initialValues: {
|
||||||
|
amount: 0,
|
||||||
|
transferReceiptUrl: '',
|
||||||
|
bankAccountId: '',
|
||||||
|
method: 'SHEBA'
|
||||||
|
},
|
||||||
|
validationSchema: Yup.object({
|
||||||
|
amount: Yup.number().required(t('errors.required')),
|
||||||
|
bankAccountId: Yup.string().required(t('errors.required')),
|
||||||
|
}),
|
||||||
|
onSubmit: (values) => {
|
||||||
|
if (file) {
|
||||||
|
const formData = new FormData()
|
||||||
|
formData.append('file', file)
|
||||||
|
upload.mutate(formData, {
|
||||||
|
onSuccess: (data) => {
|
||||||
|
depositTransfer.mutate({ ...values, amount: +values.amount, transferReceiptUrl: data.data.url }, {
|
||||||
|
onSuccess: () => {
|
||||||
|
formik.resetForm()
|
||||||
|
setFile(undefined)
|
||||||
|
toast.success(t('wallet.successful_transfer'))
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='mt-8 bg-white p-8 rounded-3xl'>
|
<div className='mt-8 bg-white p-8 rounded-3xl'>
|
||||||
|
{
|
||||||
|
getBankAccount.isPending ?
|
||||||
|
<PageLoading />
|
||||||
|
:
|
||||||
|
<Fragment>
|
||||||
<div>
|
<div>
|
||||||
{t('wallet.pay_sheba')}
|
{t('wallet.pay_sheba')}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className='mt-8'>
|
||||||
|
<Select
|
||||||
|
label={t('wallet.select_sheba')}
|
||||||
|
placeholder={t('select')}
|
||||||
|
items={getBankAccount.data?.data?.bankAccounts?.map((item: any) => ({
|
||||||
|
label: item.IBan,
|
||||||
|
value: item.id
|
||||||
|
}))}
|
||||||
|
name='bankAccountId'
|
||||||
|
onChange={formik.handleChange}
|
||||||
|
error_text={formik.touched.bankAccountId && formik.errors.bankAccountId ? formik.errors.bankAccountId : ''}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className='mt-8'>
|
<div className='mt-8'>
|
||||||
<Input
|
<Input
|
||||||
label={t('wallet.amount')}
|
label={t('wallet.amount')}
|
||||||
placeholder={t('wallet.enter_sheba_deposit')}
|
placeholder={t('wallet.enter_amount_card')}
|
||||||
|
name='amount'
|
||||||
|
onChange={formik.handleChange}
|
||||||
|
error_text={formik.touched.amount && formik.errors.amount ? formik.errors.amount : ''}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className='mt-8'>
|
<div className='mt-8'>
|
||||||
<UploadBox
|
<UploadBox
|
||||||
label={t('wallet.upload_deposit_slip')}
|
label={t('wallet.upload_deposit_slip')}
|
||||||
|
onChange={(file) => setFile(file[0])}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -31,11 +97,16 @@ const Sheba: FC = () => {
|
|||||||
<Button
|
<Button
|
||||||
label={t('wallet.submit_slip')}
|
label={t('wallet.submit_slip')}
|
||||||
className='w-[180px]'
|
className='w-[180px]'
|
||||||
|
onClick={() => formik.handleSubmit()}
|
||||||
|
isLoading={depositTransfer.isPending || upload.isPending}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
</Fragment>
|
||||||
|
}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Sheba
|
export default CardtoCard
|
||||||
Reference in New Issue
Block a user