transaction topup & disbursement fixing
This commit is contained in:
@ -11,7 +11,7 @@ import { toast } from 'sonner';
|
||||
|
||||
const TransactionDisbursement = () => {
|
||||
const [form, setForm] = useState({
|
||||
customerId: '',
|
||||
msisdn: '',
|
||||
amount: '',
|
||||
pin: ''
|
||||
});
|
||||
@ -21,22 +21,21 @@ const TransactionDisbursement = () => {
|
||||
const handleSubmit = async (e: any) => {
|
||||
e.preventDefault();
|
||||
console.log('Submitted Data:', form);
|
||||
if (form.amount == '' || form.customerId == '' || form.pin == '') {
|
||||
if (form.amount == '' || form.msisdn == '' || form.pin == '') {
|
||||
toast.warning('Please fill in all required fields.')
|
||||
return
|
||||
}
|
||||
try {
|
||||
// let requestTopup = await PostData(`${API_URL}/transaction/request-topup`, {
|
||||
// amount: form.topupAmount,
|
||||
// pin: form.pin
|
||||
// })
|
||||
// console.log(requestTopup)
|
||||
// if (requestTopup?.status == true) {
|
||||
// toast.success('Success Request Topup')
|
||||
// } else {
|
||||
// toast.warning(`${requestTopup?.message}`)
|
||||
// }
|
||||
toast.warning('Failed')
|
||||
let requestTopup = await PostData(`${API_URL}/transaction/topup-downline`, {
|
||||
msisdn_destination: form.msisdn,
|
||||
amount: form.amount,
|
||||
pin: form.pin
|
||||
})
|
||||
if (requestTopup?.status == true) {
|
||||
toast.success('Success Request Topup')
|
||||
} else {
|
||||
toast.warning(`${requestTopup?.message}`)
|
||||
}
|
||||
} catch (error) {
|
||||
toast.warning('Failed')
|
||||
}
|
||||
@ -68,11 +67,12 @@ const TransactionDisbursement = () => {
|
||||
{/* form */}
|
||||
<form onSubmit={handleSubmit} className="space-y-6">
|
||||
<div>
|
||||
<label htmlFor="customerId">Customer ID</label><span className="text-red-500">*</span>
|
||||
<label htmlFor="msisdn">Destination MSISDN</label><span className="text-red-500">*</span>
|
||||
<Input
|
||||
id="customerId"
|
||||
value={form.customerId}
|
||||
onChange={(e) => setForm({ ...form, customerId: e.target.value })}
|
||||
id="msisdn"
|
||||
type="number"
|
||||
value={form.msisdn}
|
||||
onChange={(e) => setForm({ ...form, msisdn: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
@ -30,7 +30,6 @@ const TransactionTopup = () => {
|
||||
amount: form.topupAmount,
|
||||
pin: form.pin
|
||||
})
|
||||
console.log(requestTopup)
|
||||
if (requestTopup?.status == true) {
|
||||
toast.success('Success Request Topup')
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user