fixing required

This commit is contained in:
Narul Hidayah
2025-04-16 02:04:12 +07:00
parent d422c05894
commit 81c84dc1cd
2 changed files with 14 additions and 5 deletions

View File

@ -21,6 +21,10 @@ const TransactionDisbursement = () => {
const handleSubmit = async (e: any) => { const handleSubmit = async (e: any) => {
e.preventDefault(); e.preventDefault();
console.log('Submitted Data:', form); console.log('Submitted Data:', form);
if (form.amount == '' || form.customerId == '' || form.pin == '') {
toast.warning('Please fill in all required fields.')
return
}
try { try {
// let requestTopup = await PostData(`${API_URL}/transaction/request-topup`, { // let requestTopup = await PostData(`${API_URL}/transaction/request-topup`, {
// amount: form.topupAmount, // amount: form.topupAmount,
@ -64,7 +68,7 @@ const TransactionDisbursement = () => {
{/* form */} {/* form */}
<form onSubmit={handleSubmit} className="space-y-6"> <form onSubmit={handleSubmit} className="space-y-6">
<div> <div>
<label htmlFor="customerId">Customer ID</label> <label htmlFor="customerId">Customer ID</label><span className="text-red-500">*</span>
<Input <Input
id="customerId" id="customerId"
value={form.customerId} value={form.customerId}
@ -72,7 +76,7 @@ const TransactionDisbursement = () => {
/> />
</div> </div>
<div> <div>
<label htmlFor="amount">Amount</label> <label htmlFor="amount">Amount</label><span className="text-red-500">*</span>
<Input <Input
id="amount" id="amount"
type="number" type="number"
@ -81,7 +85,7 @@ const TransactionDisbursement = () => {
/> />
</div> </div>
<div> <div>
<label htmlFor="pin">PIN</label> <label htmlFor="pin">PIN</label><span className="text-red-500">*</span>
<Input <Input
id="pin" id="pin"
type="password" type="password"

View File

@ -20,6 +20,11 @@ const TransactionTopup = () => {
const handleSubmit = async (e: any) => { const handleSubmit = async (e: any) => {
e.preventDefault(); e.preventDefault();
console.log('Submitted Data:', form); console.log('Submitted Data:', form);
if (form.pin == '' || form.topupAmount) {
toast.warning('Please fill in all required fields.')
return
}
try { try {
let requestTopup = await PostData(`${API_URL}/transaction/request-topup`, { let requestTopup = await PostData(`${API_URL}/transaction/request-topup`, {
amount: form.topupAmount, amount: form.topupAmount,
@ -62,7 +67,7 @@ const TransactionTopup = () => {
{/* form */} {/* form */}
<form onSubmit={handleSubmit} className="space-y-6"> <form onSubmit={handleSubmit} className="space-y-6">
<div> <div>
<label htmlFor="topupAmount">Topup Amount</label> <label htmlFor="topupAmount">Topup Amount</label><span className="text-red-500">*</span>
<Input <Input
id="topupAmount" id="topupAmount"
type="number" type="number"
@ -71,7 +76,7 @@ const TransactionTopup = () => {
/> />
</div> </div>
<div> <div>
<label htmlFor="pin">PIN</label> <label htmlFor="pin">PIN</label><span className="text-red-500">*</span>
<Input <Input
id="pin" id="pin"
type="password" type="password"