check status
This commit is contained in:
@@ -2,7 +2,7 @@ import React, { FC } from 'react';
|
|||||||
import { View, Text, StyleSheet, TouchableOpacity, ToastAndroid } from 'react-native';
|
import { View, Text, StyleSheet, TouchableOpacity, ToastAndroid } from 'react-native';
|
||||||
import colors from './colors';
|
import colors from './colors';
|
||||||
import { useNavigation } from '@react-navigation/native';
|
import { useNavigation } from '@react-navigation/native';
|
||||||
import { BASE_URL } from '../utils/ApiUrls';
|
import { BASE_URL, CONTRIBUTE } from '../utils/ApiUrls';
|
||||||
import { apiCall } from '../utils/ApiHelper';
|
import { apiCall } from '../utils/ApiHelper';
|
||||||
|
|
||||||
interface JoinedGroup {
|
interface JoinedGroup {
|
||||||
@@ -65,13 +65,14 @@ export const JoinedGroupCard: FC<JoinedGroupCardProps> = ({ item, onViewPress, h
|
|||||||
const statusStyle = getStatusStyle(item.status);
|
const statusStyle = getStatusStyle(item.status);
|
||||||
const navigation = useNavigation<any>();
|
const navigation = useNavigation<any>();
|
||||||
const [loading, setLoading] = React.useState(false);
|
const [loading, setLoading] = React.useState(false);
|
||||||
|
const [payable, setPayable] = React.useState<any>();
|
||||||
|
|
||||||
const onPayPress = async () => {
|
const onPayPress = async () => {
|
||||||
// Navigate to payment screen or handle payment logic
|
// Navigate to payment screen or handle payment logic
|
||||||
// navigation.navigate('PaymentScreen', { groupId: item.id, amount: item.contributionAmount });
|
// navigation.navigate('PaymentScreen', { groupId: item.id, amount: item.contributionAmount });
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const res = await apiCall(`${BASE_URL}payments/contribute/${item?.id}?amount=${item?.contributionAmount}`, 'POST') as any;
|
const res = await apiCall(`${BASE_URL}payments/contribute/${item?.id}?amount=${payable?.totalPayable}`, 'POST') as any;
|
||||||
console.log('payment res ', res)
|
console.log('payment res ', res)
|
||||||
if (res.status === 200 || res.status === 201 || res.statusCode === 200) {
|
if (res.status === 200 || res.status === 201 || res.statusCode === 200) {
|
||||||
ToastAndroid.show('Payment done!', ToastAndroid.SHORT);
|
ToastAndroid.show('Payment done!', ToastAndroid.SHORT);
|
||||||
@@ -83,6 +84,18 @@ export const JoinedGroupCard: FC<JoinedGroupCardProps> = ({ item, onViewPress, h
|
|||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleContribution = async () => {
|
||||||
|
try {
|
||||||
|
const res = await apiCall(`${CONTRIBUTE}${item.id}/calculate-contribution`, 'GET') as any;
|
||||||
|
setPayable(res.data);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error in handleContribution: ", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
React.useEffect(() => {
|
||||||
|
handleContribution();
|
||||||
|
}, []);
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity style={styles.card} onPress={() => navigation.navigate("GroupDetails", { item, color: colors.black })}>
|
<TouchableOpacity style={styles.card} onPress={() => navigation.navigate("GroupDetails", { item, color: colors.black })}>
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
@@ -104,6 +117,12 @@ export const JoinedGroupCard: FC<JoinedGroupCardProps> = ({ item, onViewPress, h
|
|||||||
<Text style={styles.infoValue}>{item.cycleType}</Text>
|
<Text style={styles.infoValue}>{item.cycleType}</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
{payable?.effectiveLateFee && (
|
||||||
|
<>
|
||||||
|
<Text style={{ marginBottom: 8, fontSize: 14, color: '#050911ff' }}>Total Payable: ₹{payable?.totalPayable.toLocaleString('en-IN')}</Text>
|
||||||
|
<Text style={{ marginBottom: 8, fontSize: 14, color: '#050911ff' }}>Effective Late Fee : ₹{payable?.effectiveLateFee.toLocaleString('en-IN')}</Text>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
{/* Footer with Dates & Buttons */}
|
{/* Footer with Dates & Buttons */}
|
||||||
<View style={styles.footer}>
|
<View style={styles.footer}>
|
||||||
<Text style={styles.dateText}>
|
<Text style={styles.dateText}>
|
||||||
|
|||||||
@@ -127,7 +127,8 @@ const UserProfileStatus: React.FC<UserProfileStatusProps> = ({
|
|||||||
}
|
}
|
||||||
setSubmitting(true);
|
setSubmitting(true);
|
||||||
try {
|
try {
|
||||||
const response = await apiCall(PAY_ALL_URL, 'POST',{ groupIds: selectedGroupIds, payAllDue: true }, undefined, "Payment failed. Try again.") as any;
|
const response = await apiCall(PAY_ALL_URL, 'POST',{ groupIds: selectedGroupIds }, undefined, "Payment failed. Try again.") as any;
|
||||||
|
|
||||||
console.log("-=-=-=-=-=-=-=-=-=-=-=",response)
|
console.log("-=-=-=-=-=-=-=-=-=-=-=",response)
|
||||||
|
|
||||||
// const response = await fetch(
|
// const response = await fetch(
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ const GroupDetails = () => {
|
|||||||
const [cycleDashboardData, setCycleDashboardData] = useState<any>();
|
const [cycleDashboardData, setCycleDashboardData] = useState<any>();
|
||||||
const [selectedCycleNumber, setSelectedCycleNumber] = useState(null);
|
const [selectedCycleNumber, setSelectedCycleNumber] = useState(null);
|
||||||
const [cycleItems, setCycleItems] = useState([]);
|
const [cycleItems, setCycleItems] = useState([]);
|
||||||
const [selectedUser, setSelectedUser] = useState() as any
|
const [selectedUser, setSelectedUser] = useState() as string | any;
|
||||||
|
|
||||||
|
|
||||||
const group = {
|
const group = {
|
||||||
@@ -96,10 +96,10 @@ const GroupDetails = () => {
|
|||||||
|
|
||||||
|
|
||||||
const getPaymentStatus = async () => {
|
const getPaymentStatus = async () => {
|
||||||
const response = await apiCall(`${BASE_URL}payments/group/${group.id || route?.params?.groupId}/payment/paid`, 'GET') as { status: string; data?: { currentCycle: number, allPaid: boolean, selectedUser: any }; message?: string };
|
const response = await apiCall(`${BASE_URL}payments/group/${group.id || route?.params?.groupId}/payment/paid`, 'GET') as { status: string; data?: { currentCycle: number, allPaid: boolean, selectedUser: string }; message?: string };
|
||||||
console.log("paymentStatus", response.data?.selectedUser)
|
console.log("paymentStatus", response.data)
|
||||||
if (response.status === 'success') {
|
if (response.status === 'success') {
|
||||||
setSelectedUser(response.data?.selectedUser);
|
setSelectedUser(response.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,7 +237,7 @@ const GroupDetails = () => {
|
|||||||
placeholder="Select a Cycle"
|
placeholder="Select a Cycle"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{selectedCycleData && cycleDashboardData && (
|
{selectedCycleData && cycleDashboardData && (
|
||||||
<CycleDashboard data={{ ...cycleDashboardData, cycles: [selectedCycleData] }} />
|
<CycleDashboard data={{ ...cycleDashboardData, cycles: [selectedCycleData] }} />
|
||||||
)}
|
)}
|
||||||
@@ -263,7 +263,7 @@ const GroupDetails = () => {
|
|||||||
))}
|
))}
|
||||||
|
|
||||||
|
|
||||||
{cycleDashboardData?.status === 'ACTIVE' && !payable?.hasPaid && (
|
{cycleDashboardData?.status === 'ACTIVE' || cycleDashboardData?.status === 'DELAY' && !payable?.hasPaid && (
|
||||||
<TouchableOpacity onPress={() => setOpenModal(true)} style={styles.button}>
|
<TouchableOpacity onPress={() => setOpenModal(true)} style={styles.button}>
|
||||||
<Text style={styles.buttonText}>Contribute</Text>
|
<Text style={styles.buttonText}>Contribute</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
@@ -423,7 +423,7 @@ const styles = StyleSheet.create({
|
|||||||
},
|
},
|
||||||
floatingWinnerContainer: {
|
floatingWinnerContainer: {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
bottom: 80,
|
bottom: 80,
|
||||||
alignSelf: 'center',
|
alignSelf: 'center',
|
||||||
backgroundColor: colors.pastelBlue,
|
backgroundColor: colors.pastelBlue,
|
||||||
paddingHorizontal: 15,
|
paddingHorizontal: 15,
|
||||||
|
|||||||
Reference in New Issue
Block a user