align business logic organizer side

This commit is contained in:
Jaanu423
2025-10-01 15:44:11 +05:30
parent f854bd6765
commit 9154a1482c
15 changed files with 335 additions and 44 deletions
+8 -4
View File
@@ -5,6 +5,7 @@ import { Ionicons } from "@react-native-vector-icons/ionicons";
import colors from '../../components/colors';
import AppView from '../../components/AppView';
import { apiCall } from '../../utils/ApiHelper';
import { BASE_URL } from '../../utils/ApiUrls';
// --- CONSTANTS ---
const API_BASE_URL = 'https://exotic-humpback-mistakenly.ngrok-free.app/api/payments';
@@ -58,14 +59,17 @@ const Payments: React.FC = () => {
const fetchPaymentDetails = useCallback(async () => {
if (!refreshing) setLoading(true);
try {
const response = await apiCall(`${API_BASE_URL}/current/payment/details/${groupId}`, 'GET') as ApiResponse<PaymentDetails>;
const response = await apiCall(`${BASE_URL}payments/current/payment/details/${groupId}`, 'GET') as ApiResponse<PaymentDetails>;
console.log("payment response :", response)
if (response && response.statusCode === 200) {
setPaymentDetails(response.data);
} else {
Alert.alert("Error", response?.message || "Failed to fetch details.");
}
} catch (error: any) {
Alert.alert("Error", error.message || "An unexpected error occurred.");
// Alert.alert("Error", error.message || "An unexpected error occurred.");
console.log("payment error : ", error)
} finally {
setLoading(false);
setRefreshing(false);
@@ -105,9 +109,9 @@ const Payments: React.FC = () => {
try {
// Construct the exact URL as provided
const url = `${API_BASE_URL}/groups/${groupId}/cycles/${paymentDetails.currentCycle}/waive/${currentParticipant.userId}?amountToWaive=${amountToWaive}`;
const url = `${BASE_URL}groups/${groupId}/cycles/${paymentDetails.currentCycle}/waive/${currentParticipant.userId}?amountToWaive=${amountToWaive}`;
const response = await apiCall(url, 'PUT', {}); // Body is empty as amount is in URL
const response = await apiCall(url, 'PUT', {}) as any; // Body is empty as amount is in URL
if (response && response.statusCode === 200) {
Alert.alert("Success", `₹${amountToWaive} has been waived successfully.`);