payment screen fixes | Aman Sethi (#125)
* payment screen fixes * fix toast messages * remove extra feature * add toast messsaged to variable
This commit is contained in:
committed by
GitHub Enterprise
parent
1b720c0ddc
commit
07590595a7
14
App.tsx
14
App.tsx
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { LogBox } from 'react-native';
|
||||
import { KeyboardAvoidingView,LogBox } from 'react-native';
|
||||
import {Provider} from 'react-redux';
|
||||
import store, {persistor} from './src/store/store';
|
||||
import {PersistGate} from 'redux-persist/integration/react';
|
||||
@@ -36,12 +36,20 @@ const App = () => {
|
||||
loading={<FullScreenLoader loading />}
|
||||
persistor={persistor}>
|
||||
<NavigationContainer ref={navigationRef}>
|
||||
<StatusBar backgroundColor={COLORS.BACKGROUND.INDIGO_DARK} />
|
||||
<StatusBar backgroundColor={COLORS.BACKGROUND.INDIGO_DARK} />
|
||||
<ErrorBoundary>
|
||||
<ProtectedRouter />
|
||||
</ErrorBoundary>
|
||||
</NavigationContainer>
|
||||
{<ToastContainer config={toastConfigs} position='bottom' />}
|
||||
{
|
||||
<KeyboardAvoidingView
|
||||
behavior='position'>
|
||||
<ToastContainer
|
||||
config={toastConfigs}
|
||||
position="bottom"
|
||||
/>
|
||||
</KeyboardAvoidingView>
|
||||
}
|
||||
</PersistGate>
|
||||
</Provider>
|
||||
);
|
||||
|
||||
@@ -76,14 +76,14 @@ const ProtectedRouter = () => {
|
||||
|
||||
registerNavigateAndDispatch(dispatch);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const loanIdToValueStored = await getLoanIdToValueFromLocal();
|
||||
if (loanIdToValueStored) {
|
||||
dispatch(setLoanIdToValue(loanIdToValueStored));
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
// useEffect(() => {
|
||||
// (async () => {
|
||||
// const loanIdToValueStored = await getLoanIdToValueFromLocal();
|
||||
// if (loanIdToValueStored) {
|
||||
// dispatch(setLoanIdToValue(loanIdToValueStored));
|
||||
// }
|
||||
// })();
|
||||
// }, []);
|
||||
|
||||
return (
|
||||
<Stack.Navigator>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ToastMessages } from './../screens/allCases/contants';
|
||||
import { ILoanIdToValue } from './../reducer/paymentSlice';
|
||||
import { paymentData } from './../mock-api/data/addressesGeolocation';
|
||||
import { setAsyncStorageItem } from './../components/utlis/commonFunctions';
|
||||
import { Dispatch } from '@reduxjs/toolkit';
|
||||
import {
|
||||
@@ -47,17 +47,16 @@ export const generatePaymentLinkAction =
|
||||
const currentTime = Date.now();
|
||||
const { loanAccountNumber } = payload;
|
||||
const value = loanIdToValue?.[loanAccountNumber];
|
||||
if (
|
||||
value &&
|
||||
Number(value?.expiresAt) > currentTime &&
|
||||
String(value?.alternateContactNumber) ===
|
||||
String(payload.alternateContactNumber) &&
|
||||
value?.customAmount.amount === payload.customAmount.amount
|
||||
) {
|
||||
dispatch(setPaymentLink(value.paymentLink));
|
||||
dispatch(setLoading(false));
|
||||
return;
|
||||
}
|
||||
// if (
|
||||
// value &&
|
||||
// Number(value?.expiresAt) > currentTime &&
|
||||
// value?.alternateContactNumber === payload.alternateContactNumber &&
|
||||
// value?.customAmount.amount === payload.customAmount.amount
|
||||
// ) {
|
||||
// dispatch(setPaymentLink(value.paymentLink));
|
||||
// dispatch(setLoading(false));
|
||||
// return;
|
||||
// }
|
||||
axiosInstance
|
||||
.post(url, payload)
|
||||
.then(async response => {
|
||||
@@ -77,29 +76,25 @@ export const generatePaymentLinkAction =
|
||||
[loanAccountNumber]: storePayload,
|
||||
}),
|
||||
);
|
||||
await setAsyncStorageItem(
|
||||
LocalStorageKeys.LOAN_ID_TO_VALUE,
|
||||
{
|
||||
...loanIdToValue,
|
||||
[loanAccountNumber]: storePayload,
|
||||
},
|
||||
);
|
||||
// await setAsyncStorageItem(
|
||||
// LocalStorageKeys.LOAN_ID_TO_VALUE,
|
||||
// {
|
||||
// ...loanIdToValue,
|
||||
// [loanAccountNumber]: storePayload,
|
||||
// },
|
||||
// );
|
||||
toast({
|
||||
type: 'success',
|
||||
text1: ToastMessages.PAYMENT_LINK_SUCCESS,
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
if (err.response.status === API_STATUS_CODE.NOT_FOUND) {
|
||||
toast({
|
||||
type: 'error',
|
||||
text1: 'error in api response',
|
||||
});
|
||||
} else {
|
||||
const errorMessage = getErrorMessage(err);
|
||||
toast({
|
||||
type: 'error',
|
||||
text1: errorMessage,
|
||||
});
|
||||
}
|
||||
toast({
|
||||
type: 'error',
|
||||
text1: ToastMessages.PAYMENT_LINK_ERROR,
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
dispatch(setLoading(false));
|
||||
|
||||
@@ -45,5 +45,8 @@ export const ToastMessages = {
|
||||
SUCCESS_COPYING_LAN: 'LAN Copied Successfully!!',
|
||||
FEEDBACK_SUCCESSFUL: 'Feedback submitted successfully!',
|
||||
FEEDBACK_FAILED: 'Feedback submission failed',
|
||||
FIRESTORE_SIGNIN_FAILED: 'Error signing in to Firestore'
|
||||
FIRESTORE_SIGNIN_FAILED: 'Error signing in to Firestore',
|
||||
PAYMENT_LINK_ERROR: 'Payment link could not be shared',
|
||||
PAYMENT_LINK_SUCCESS: 'Payment link shared successfully',
|
||||
SUCCESS_COPYING_PAYMENT_LINK: 'Link copied successfully',
|
||||
};
|
||||
|
||||
@@ -19,6 +19,7 @@ import { useAppDispatch, useAppSelector } from '../../hooks';
|
||||
import DropdownItem from './DropdownItem';
|
||||
import { PhoneNumber } from '../caseDetails/interface';
|
||||
import { setPaymentLink } from '../../reducer/paymentSlice';
|
||||
import { ToastMessages } from '../allCases/contants';
|
||||
|
||||
interface IRegisterForm {
|
||||
selectedPhoneNumber: string;
|
||||
@@ -53,7 +54,7 @@ const RegisterPayments: React.FC<IRegisterPayments> = ({ route }) => {
|
||||
const {
|
||||
control,
|
||||
getValues,
|
||||
formState: { isValid, defaultValues },
|
||||
formState: { isValid, defaultValues, errors },
|
||||
setValue,
|
||||
trigger,
|
||||
} = useForm<IRegisterForm>({
|
||||
@@ -81,13 +82,25 @@ const RegisterPayments: React.FC<IRegisterPayments> = ({ route }) => {
|
||||
copyToClipboard(paymentLink);
|
||||
toast({
|
||||
type: 'info',
|
||||
text1: 'Payment link copied successfully',
|
||||
text1: ToastMessages.SUCCESS_COPYING_PAYMENT_LINK,
|
||||
});
|
||||
}
|
||||
};
|
||||
const isPaymentButtonDisabled = !isValid || !isOnline;
|
||||
const isCopyButtonDisabled =
|
||||
!isValid || !isOnline || !paymentLink || paymentLink === '';
|
||||
let errorMessage = '';
|
||||
switch (errors.amount?.type) {
|
||||
case 'required':
|
||||
errorMessage = 'This is a required field';
|
||||
break;
|
||||
case 'min':
|
||||
errorMessage = 'Amount should be greater than min amount';
|
||||
break;
|
||||
case 'max':
|
||||
errorMessage = 'Amount should be less than max amount';
|
||||
break;
|
||||
}
|
||||
|
||||
const generatePaymentLink = () => {
|
||||
dispatch(
|
||||
@@ -115,7 +128,10 @@ const RegisterPayments: React.FC<IRegisterPayments> = ({ route }) => {
|
||||
};
|
||||
}, []);
|
||||
|
||||
const getBottomSheetHeight = getDynamicBottomSheetHeightPercentageFn(HEADER_HEIGHT, ROW_HEIGHT);
|
||||
const getBottomSheetHeight = getDynamicBottomSheetHeightPercentageFn(
|
||||
HEADER_HEIGHT,
|
||||
ROW_HEIGHT,
|
||||
);
|
||||
|
||||
return (
|
||||
<Layout>
|
||||
@@ -137,9 +153,12 @@ const RegisterPayments: React.FC<IRegisterPayments> = ({ route }) => {
|
||||
placeholder="Select number"
|
||||
onValueChange={number => {
|
||||
setValue('selectedPhoneNumber', number);
|
||||
dispatch(setPaymentLink(''));
|
||||
trigger();
|
||||
}}
|
||||
bottomSheetHeight={getBottomSheetHeight(numbers?.length)}
|
||||
bottomSheetHeight={getBottomSheetHeight(
|
||||
numbers?.length,
|
||||
)}
|
||||
header="Select number"
|
||||
value={value}>
|
||||
{ChildComponents}
|
||||
@@ -157,15 +176,20 @@ const RegisterPayments: React.FC<IRegisterPayments> = ({ route }) => {
|
||||
titleStyle={{ color: COLORS.TEXT.BLACK }}
|
||||
keyboardType="decimal-pad"
|
||||
title="Enter amount"
|
||||
onChangeText={s => onChange(s)}
|
||||
onChangeText={s => {
|
||||
dispatch(setPaymentLink(''));
|
||||
onChange(s);
|
||||
}}
|
||||
onBlur={onBlur}
|
||||
placeholder="Enter amount"
|
||||
value={value}
|
||||
LeftComponent={<Text dark>₹</Text>}
|
||||
error={errors?.amount ? true : false}
|
||||
errorMessage={errorMessage}
|
||||
/>
|
||||
)}
|
||||
name="amount"
|
||||
rules={{ required: true, min: 1 }}
|
||||
rules={{ required: true, min: 1, max: caseDetail?.pos }}
|
||||
/>
|
||||
</View>
|
||||
<Button
|
||||
|
||||
Reference in New Issue
Block a user