check status

This commit is contained in:
Jaanu423
2025-10-28 15:18:21 +05:30
parent e34b6fd165
commit 0957236098
3 changed files with 30 additions and 10 deletions
+21 -2
View File
@@ -2,7 +2,7 @@ import React, { FC } from 'react';
import { View, Text, StyleSheet, TouchableOpacity, ToastAndroid } from 'react-native';
import colors from './colors';
import { useNavigation } from '@react-navigation/native';
import { BASE_URL } from '../utils/ApiUrls';
import { BASE_URL, CONTRIBUTE } from '../utils/ApiUrls';
import { apiCall } from '../utils/ApiHelper';
interface JoinedGroup {
@@ -65,13 +65,14 @@ export const JoinedGroupCard: FC<JoinedGroupCardProps> = ({ item, onViewPress, h
const statusStyle = getStatusStyle(item.status);
const navigation = useNavigation<any>();
const [loading, setLoading] = React.useState(false);
const [payable, setPayable] = React.useState<any>();
const onPayPress = async () => {
// Navigate to payment screen or handle payment logic
// navigation.navigate('PaymentScreen', { groupId: item.id, amount: item.contributionAmount });
setLoading(true);
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)
if (res.status === 200 || res.status === 201 || res.statusCode === 200) {
ToastAndroid.show('Payment done!', ToastAndroid.SHORT);
@@ -83,6 +84,18 @@ export const JoinedGroupCard: FC<JoinedGroupCardProps> = ({ item, onViewPress, h
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 (
<TouchableOpacity style={styles.card} onPress={() => navigation.navigate("GroupDetails", { item, color: colors.black })}>
{/* Header */}
@@ -104,6 +117,12 @@ export const JoinedGroupCard: FC<JoinedGroupCardProps> = ({ item, onViewPress, h
<Text style={styles.infoValue}>{item.cycleType}</Text>
</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 */}
<View style={styles.footer}>
<Text style={styles.dateText}>
+2 -1
View File
@@ -127,7 +127,8 @@ const UserProfileStatus: React.FC<UserProfileStatusProps> = ({
}
setSubmitting(true);
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)
// const response = await fetch(
+7 -7
View File
@@ -80,7 +80,7 @@ const GroupDetails = () => {
const [cycleDashboardData, setCycleDashboardData] = useState<any>();
const [selectedCycleNumber, setSelectedCycleNumber] = useState(null);
const [cycleItems, setCycleItems] = useState([]);
const [selectedUser, setSelectedUser] = useState() as any
const [selectedUser, setSelectedUser] = useState() as string | any;
const group = {
@@ -96,10 +96,10 @@ const GroupDetails = () => {
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 };
console.log("paymentStatus", response.data?.selectedUser)
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)
if (response.status === 'success') {
setSelectedUser(response.data?.selectedUser);
setSelectedUser(response.data);
}
}
@@ -237,7 +237,7 @@ const GroupDetails = () => {
placeholder="Select a Cycle"
/>
)}
{selectedCycleData && cycleDashboardData && (
<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}>
<Text style={styles.buttonText}>Contribute</Text>
</TouchableOpacity>
@@ -423,7 +423,7 @@ const styles = StyleSheet.create({
},
floatingWinnerContainer: {
position: 'absolute',
bottom: 80,
bottom: 80,
alignSelf: 'center',
backgroundColor: colors.pastelBlue,
paddingHorizontal: 15,