mirror of
https://github.com/hazemKrimi/crimson-quirks-ui.git
synced 2026-05-01 18:20:28 +00:00
Fix payments bugs
This commit is contained in:
@@ -102,7 +102,7 @@ const Payments = () => {
|
||||
.typeError('CVC must be a number')
|
||||
.required('CVC is required'),
|
||||
}),
|
||||
onSubmit: async ({ number, expMonth, expYear, cvc }) => {
|
||||
onSubmit: async ({ number, expMonth, expYear, cvc }, { resetForm }) => {
|
||||
try {
|
||||
setPaymentLoading(true);
|
||||
let amount = 0;
|
||||
@@ -152,11 +152,15 @@ const Payments = () => {
|
||||
setPaymentLoading(false);
|
||||
setTransactionsData(transactionsResult);
|
||||
setSuccess(true);
|
||||
setSelectedChunk(undefined);
|
||||
resetForm();
|
||||
setTimeout(() => setSuccess(false), 3000);
|
||||
}
|
||||
} catch (err) {
|
||||
setPaymentLoading(false);
|
||||
setError(err);
|
||||
setSelectedChunk(undefined);
|
||||
resetForm();
|
||||
setTimeout(() => setError(''), 3000);
|
||||
}
|
||||
},
|
||||
@@ -235,7 +239,16 @@ const Payments = () => {
|
||||
</Text>
|
||||
<Box>
|
||||
<Button
|
||||
text='Select'
|
||||
text={
|
||||
transactionsData &&
|
||||
transactionsData.transactions &&
|
||||
!!Array.from(transactionsData.transactions).find(
|
||||
(transaction: any) =>
|
||||
transaction.selectedOption === 0
|
||||
)
|
||||
? 'Paid'
|
||||
: 'Select'
|
||||
}
|
||||
color={role || 'client'}
|
||||
disabled={
|
||||
selectedChunk === 0 ||
|
||||
@@ -266,14 +279,23 @@ const Payments = () => {
|
||||
}}
|
||||
>
|
||||
<Text variant='headline' weight='bold'>
|
||||
#1
|
||||
#2
|
||||
</Text>
|
||||
<Text variant='headline' weight='bold'>
|
||||
{project?.paymentOption.optTwo}%
|
||||
</Text>
|
||||
<Box>
|
||||
<Button
|
||||
text='Select'
|
||||
text={
|
||||
transactionsData &&
|
||||
transactionsData.transactions &&
|
||||
!!Array.from(transactionsData.transactions).find(
|
||||
(transaction: any) =>
|
||||
transaction.selectedOption === 1
|
||||
)
|
||||
? 'Paid'
|
||||
: 'Select'
|
||||
}
|
||||
color={role || 'client'}
|
||||
disabled={
|
||||
selectedChunk === 1 ||
|
||||
@@ -304,14 +326,23 @@ const Payments = () => {
|
||||
}}
|
||||
>
|
||||
<Text variant='headline' weight='bold'>
|
||||
#1
|
||||
#3
|
||||
</Text>
|
||||
<Text variant='headline' weight='bold'>
|
||||
{project?.paymentOption.optThree}%
|
||||
</Text>
|
||||
<Box>
|
||||
<Button
|
||||
text='Select'
|
||||
text={
|
||||
transactionsData &&
|
||||
transactionsData.transactions &&
|
||||
!!Array.from(transactionsData.transactions).find(
|
||||
(transaction: any) =>
|
||||
transaction.selectedOption === 2
|
||||
)
|
||||
? 'Paid'
|
||||
: 'Select'
|
||||
}
|
||||
color={role || 'client'}
|
||||
disabled={
|
||||
selectedChunk === 2 ||
|
||||
@@ -345,8 +376,12 @@ const Payments = () => {
|
||||
>
|
||||
<Text variant='subheader'>Paid Costs</Text>
|
||||
<Text variant='subheader' weight='bold'>
|
||||
{project && transactionsData
|
||||
? project.totalPrice - transactionsData.remaining_amount
|
||||
{transactionsData?.remaining_amount && project?.totalPrice
|
||||
? project.totalPrice ===
|
||||
transactionsData.remaining_amount
|
||||
? project.totalPrice
|
||||
: project.totalPrice -
|
||||
transactionsData.remaining_amount
|
||||
: 0}
|
||||
$
|
||||
</Text>
|
||||
@@ -366,6 +401,7 @@ const Payments = () => {
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
{selectedChunk !== undefined && (
|
||||
<Box
|
||||
background='#FFFFFF'
|
||||
padding='15px 20px'
|
||||
@@ -447,6 +483,7 @@ const Payments = () => {
|
||||
/>
|
||||
</form>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
Reference in New Issue
Block a user