diff --git a/src/screens/ContributionScreen.tsx b/src/screens/ContributionScreen.tsx index cb6691b..ead24ba 100644 --- a/src/screens/ContributionScreen.tsx +++ b/src/screens/ContributionScreen.tsx @@ -6,7 +6,7 @@ import { Animated, Easing, } from "react-native"; -import {Ionicons} from "@react-native-vector-icons/ionicons"; +import { Ionicons } from "@react-native-vector-icons/ionicons"; import colors from "../components/colors"; import CustomModal from "../components/common/CustomModal"; @@ -77,9 +77,13 @@ const ContributionDetails: React.FC = ({ > Base Amount ₹{data?.baseAmount} + { + data?.alreadyPaid ? Already Paid Amount : + + Total Payable + ₹{data?.totalPayable} + } - Total Payable - ₹{data?.totalPayable} Due Date {data?.dueDate} diff --git a/src/screens/GroupCreation.tsx b/src/screens/GroupCreation.tsx index 16d1745..62a08bf 100644 --- a/src/screens/GroupCreation.tsx +++ b/src/screens/GroupCreation.tsx @@ -55,7 +55,7 @@ export default function GroupCreationForm() { if (!form.minParticipants || Number(form.minParticipants) <= 1) newErrors.minParticipants = "Min participants must be at least 2."; if (!form.maxParticipants || Number(form.maxParticipants) < Number(form.minParticipants)) newErrors.maxParticipants = "Max must be greater than or equal to min."; if (!form.contributionAmount || Number(form.contributionAmount) <= 0) newErrors.contributionAmount = "Amount must be greater than 0."; - if (form.cycleType === "CUSTOM" && (!form.customCycleDays || Number(form.customCycleDays) <= 0)) newErrors.customCycleDays = "Custom days must be greater than 0."; + // if (form.cycleType === "CUSTOM" && (!form.customCycleDays || Number(form.customCycleDays) <= 0)) newErrors.customCycleDays = "Custom days must be greater than 0."; if (form.lateFeeMode && (!form.lateFeeValue || Number(form.lateFeeValue) <= 0)) newErrors.lateFeeValue = "Late fee value is required."; setErrors(newErrors); @@ -76,6 +76,7 @@ export default function GroupCreationForm() { navigation.navigate("GroupReview", { form: payload }); } else { Alert.alert("Incomplete Form", "Please fill out all required fields correctly."); + setErrors('') } }; @@ -88,7 +89,7 @@ export default function GroupCreationForm() { > Create New Group - + handleChange("groupName", val)} icon="people" error={errors.groupName} /> handleChange("description", val)} multiline icon="document-text" error={errors.description} /> diff --git a/src/screens/GroupDetails.tsx b/src/screens/GroupDetails.tsx deleted file mode 100644 index e69de29..0000000 diff --git a/src/screens/GroupScreen.tsx b/src/screens/GroupScreen.tsx index 287f178..c7a82e3 100644 --- a/src/screens/GroupScreen.tsx +++ b/src/screens/GroupScreen.tsx @@ -44,16 +44,17 @@ interface Group { const GroupCard = ({ item, onJoin, onView, isGrid }: { item: Group; onJoin: (groupId: string) => void; onView: (group: Group) => void; isGrid?: boolean; }) => { const isFull = item.currentParticipants >= item.maxParticipants; const cardStyle = isGrid ? styles.gridCard : styles.listCard; - + const navigation = useNavigation() return ( + {/* navigation.navigate("GroupDetails" as never)}> */} {item.groupName} {item.description} @@ -62,6 +63,7 @@ const GroupCard = ({ item, onJoin, onView, isGrid }: { item: Group; onJoin: (gro {item.currentParticipants}/{item.maxParticipants} Members {item.cycleType} + {/* */} {/* onView(item)}> View @@ -81,7 +83,7 @@ const GroupCard = ({ item, onJoin, onView, isGrid }: { item: Group; onJoin: (gro const FeaturedGroupCard = ({ item }: { item: Group }) => { return ( - + {item.groupName} by {item.createdByName} @@ -167,11 +169,11 @@ export default function GroupScreen() { console.log("JOIN_GROUP_URL response:", res); - // if (res.statusCode === 200) { - // Alert.alert("Success", "You requested to join the group."); - // } else { - // Alert.alert("Error", res.message || "Failed to join group."); - // } + if (res.statusCode === 200) { + Alert.alert("Success", "You requested to join the group."); + } else { + Alert.alert("Error", res.message || "Failed to join group."); + } } catch (error) { console.error("Join Group Error:", error); Alert.alert("Error", "An unexpected error occurred."); @@ -307,7 +309,7 @@ export default function GroupScreen() { - {role === "ORGANIZER" ? (["My Groups", "Joined", "Public"].map((tab) => ( + {role === "ORGANIZER" ? (["Public"].map((tab) => ( setActiveTab(tab)}> {tab} @@ -358,7 +360,7 @@ const styles = StyleSheet.create({ listCard: { backgroundColor: '#fff', padding: 16, borderRadius: 12, marginBottom: 12, elevation: 1 }, gridCard: { backgroundColor: '#fff', padding: 12, borderRadius: 12, marginBottom: 12, elevation: 1, width: (width - 48) / 2 }, groupName: { fontSize: 16, fontWeight: 'bold', color: '#333' }, - groupDescription: { fontSize: 14, color: '#666', marginVertical: 4 }, + groupDescription: { fontSize: 14, color: '#666', marginVertical: 4, width: '40%' }, groupMeta: { flexDirection: 'row', justifyContent: 'space-between', marginTop: 8, borderTopWidth: 1, borderTopColor: '#f0f0f0', paddingTop: 8, marginBottom: 10 }, groupMetaText: { fontSize: 12, color: '#888', fontWeight: '500', textTransform: 'capitalize' }, emptyText: { textAlign: 'center', marginTop: 40, fontSize: 16, color: '#888' }, diff --git a/src/screens/home/user-home/GroupDetails.tsx b/src/screens/home/user-home/GroupDetails.tsx index 4f07746..e17e430 100644 --- a/src/screens/home/user-home/GroupDetails.tsx +++ b/src/screens/home/user-home/GroupDetails.tsx @@ -37,8 +37,9 @@ const GroupDetails = () => { const [memberData, setMemberData] = useState([]); const [loading, setLoading] = useState(false); const [openModal, setOpenModal] = useState(false) - const [payable, setPayable] = useState() + const [payable, setPayable] = useState() as any + console.log("route param ggggggggggg : ", route?.params) // Group object const group = { id: route.params.item?.id, @@ -108,7 +109,7 @@ const GroupDetails = () => { const confirmPayment = async () => { try { - const res = await apiCall(`${BASE_URL}payments/contribute/${group?.id}?amount=${group?.collected}`, 'POST') as any + const res = await apiCall(`${BASE_URL}payments/contribute/${group?.id}?amount=${payable?.totalPayable}`, 'POST') as any console.log("payment response : ", res) if (res.status) { ToastAndroid.show('Payment done!', ToastAndroid.SHORT) diff --git a/src/screens/management/EditGroupScreen.tsx b/src/screens/management/EditGroupScreen.tsx index dcf8abc..00c5996 100644 --- a/src/screens/management/EditGroupScreen.tsx +++ b/src/screens/management/EditGroupScreen.tsx @@ -153,14 +153,23 @@ const EditGroupScreen: React.FC = ({ route }) => { setLoading(false); } }, [groupId]); -const getPaymentStatus = async()=>{ - const response = await apiCall(`https://exotic-humpback-mistakenly.ngrok-free.app/api/payments/group/${groupId}/payment/paid`, 'GET') as { status: string; data?: { currentCycle: number ,status: boolean }; message?: string }; - console.log("paymentStatus",response) - if (response.status === 'success') { - setPaymentStatus(response.data?.status || false); - setCurrentCycle(response.data?.currentCycle || null); + // const getPaymentStatus = async()=>{ + // const response = await apiCall(`https://exotic-humpback-mistakenly.ngrok-free.app/api/payments/group/${groupId}/payment/paid`, 'GET') as { status: string; data?: { currentCycle: number ,status: boolean }; message?: string }; + // console.log("paymentStatus",response) + // if (response.status === 'success') { + // setPaymentStatus(response.data?.status || false); + // setCurrentCycle(response.data?.currentCycle || null); + // } + // } + + const getPaymentStatus = async () => { + const response = await apiCall(`https://exotic-humpback-mistakenly.ngrok-free.app/api/payments/group/${groupId}/payment/paid`, 'GET') as { status: string; data?: { currentCycle: number, allPaid: boolean }; message?: string }; + console.log("paymentStatus", response) + if (response.status === 'success') { + setPaymentStatus(response.data?.allPaid || false); + setCurrentCycle(response.data?.currentCycle || null); + } } -} useEffect(() => { @@ -199,7 +208,7 @@ const getPaymentStatus = async()=>{ } }; const handleDistribute = async () => { - navigation.navigate('RandomSelectUserScreen', { groupId: groupDetails?.id || '', cycleNumber: currentCycle || 0 }); + navigation.navigate('RandomSelectUserScreen', { groupId: groupDetails?.id || '', cycleNumber: currentCycle || 0 }); }; const handleStartGroup = async () => { @@ -235,7 +244,7 @@ const getPaymentStatus = async()=>{ if (!groupDetails) return; setInviting(true); try { - const response = await apiCall(`https://exotic-humpback-mistakenly.ngrok-free.app/api/invite/generate?groupId=${groupDetails.id}`, 'GET') as { data?: string }; + const response = await apiCall(`https://exotic-humpback-mistakenly.ngrok-free.app/api/invite/generate?groupId=${groupDetails.id}`, 'GET') as { data?: string }; const inviteLink = response.data; @@ -411,7 +420,7 @@ const getPaymentStatus = async()=>{ setSelectedImage(selectedImage.uri); }); }; - + const handleUpdateImage = async () => { try { const credentials = await Keychain.getGenericPassword(); @@ -522,19 +531,19 @@ const getPaymentStatus = async()=>{ ], 'groupInfo')} - {groupDetails.status === 'ACTIVE' ? - renderCard('Financial Rules', [ - { field: 'contributionAmount', label: 'Contribution', displayValue: () => `₹${groupDetails.contributionAmount.toLocaleString('en-IN')}` }, - { field: 'latePaymentCharge', label: 'Late Fee', displayValue: () => `₹${(groupDetails.latePaymentCharge ?? 0).toLocaleString('en-IN')}` }, - { field: 'maxParticipants', label: 'Current Participants', displayValue: () => `${groupDetails.totalParticipants}` }, - ], 'financialRules') - : - renderCard('Financial Rules', [ - { field: 'contributionAmount', label: 'Contribution', displayValue: () => `₹${groupDetails.contributionAmount.toLocaleString('en-IN')}` }, - { field: 'maxParticipants', label: 'Max Participants', displayValue: () => `${groupDetails.totalParticipants} / ${groupDetails.maxParticipants}` }, - { field: 'minParticipants', label: 'Min Participants', displayValue: () => `${groupDetails.minParticipants}` }, - { field: 'latePaymentCharge', label: 'Late Fee', displayValue: () => `₹${(groupDetails.latePaymentCharge ?? 0).toLocaleString('en-IN')}` }, - ], 'financialRules') + {groupDetails.status === 'ACTIVE' ? + renderCard('Financial Rules', [ + { field: 'contributionAmount', label: 'Contribution', displayValue: () => `₹${groupDetails.contributionAmount.toLocaleString('en-IN')}` }, + { field: 'latePaymentCharge', label: 'Late Fee', displayValue: () => `₹${(groupDetails.latePaymentCharge ?? 0).toLocaleString('en-IN')}` }, + { field: 'maxParticipants', label: 'Current Participants', displayValue: () => `${groupDetails.totalParticipants}` }, + ], 'financialRules') + : + renderCard('Financial Rules', [ + { field: 'contributionAmount', label: 'Contribution', displayValue: () => `₹${groupDetails.contributionAmount.toLocaleString('en-IN')}` }, + { field: 'maxParticipants', label: 'Max Participants', displayValue: () => `${groupDetails.totalParticipants} / ${groupDetails.maxParticipants}` }, + { field: 'minParticipants', label: 'Min Participants', displayValue: () => `${groupDetails.minParticipants}` }, + { field: 'latePaymentCharge', label: 'Late Fee', displayValue: () => `₹${(groupDetails.latePaymentCharge ?? 0).toLocaleString('en-IN')}` }, + ], 'financialRules') } @@ -580,7 +589,7 @@ const getPaymentStatus = async()=>{ )} - {paymentStatus && ( + {paymentStatus && ( = ({ route }) => { const payload = { groupId: groupId }; try { const response = await apiCall('https://exotic-humpback-mistakenly.ngrok-free.app/api/fund/method/based/userSelect', 'POST', payload) as any; - - if (response.status === 'success' && response.data?.id) { - const winnerData = { id: response.data.id, name: `${response.data.firstName} ${response.data.lastName}` }; + console.log("random select user response : ", response) + if (response.status === 'success' && response.data?.selectedUser?.id) { + const winnerData = { id: response?.data?.selectedUser?.id, name: `${response.data.selectedUser.firstName} ${response.data.selectedUser.lastName}` }; const winnerIndex = users.findIndex(u => u.id === winnerData.id); if (winnerIndex !== -1) { @@ -93,7 +93,7 @@ const RandomSelectUserScreen: React.FC<{ route: any }> = ({ route }) => { Alert.alert('Error', 'Failed to determine a winner from the API.'); } } catch (error) { - Alert.alert('Error', 'Could not connect to the server to fetch the winner.'); + // Alert.alert('Error', 'Could not connect to the server to fetch the winner.'); } finally { setIsAnimating(false); }