Merge branch 'main' of http://45.93.137.91:3000/Rahaf/SweetHome
All checks were successful
Build frontend / build (push) Successful in 1m30s

This commit is contained in:
Rahaf
2026-06-24 15:04:59 +03:00
11 changed files with 1132 additions and 204 deletions

View File

@ -25,7 +25,7 @@ import {
} from 'lucide-react';
import toast, { Toaster } from 'react-hot-toast';
import AuthService from '@/app/services/AuthService';
import { payDeposit } from '@/app/utils/api';
import { payDeposit, getMyTransaction } from '@/app/utils/api';
const STATUS_MAP = ['pending', 'ownerConfirmed', 'depositPaid', 'depositConfirmed', 'completed', 'cancelled'];
@ -87,35 +87,10 @@ export default function PaymentsPage() {
const [isGuest, setIsGuest] = useState(null);
const [selectedPayment, setSelectedPayment] = useState('cash');
const getAuthToken = () => {
if (typeof window === 'undefined') return '';
return (
AuthService?.getToken?.() ||
AuthService?.getAccessToken?.() ||
localStorage.getItem('token') ||
localStorage.getItem('accessToken') ||
localStorage.getItem('authToken') ||
''
);
};
const loadReservations = useCallback(async () => {
try {
const token = getAuthToken();
const res = await fetch('http://45.93.137.91/api/Customer/GetMyTransaction', {
method: 'GET',
headers: {
...(token ? { Authorization: `Bearer ${token}` } : {}),
},
});
if (!res.ok) {
throw new Error('فشل تحميل المدفوعات');
}
const json = await res.json();
const items = Array.isArray(json?.data) ? json.data : Array.isArray(json) ? json : [];
const json = await getMyTransaction();
const items = Array.isArray(json) ? json : [];
const mapped = items.map((item) => {
const deposit = item?.diposit || item?.deposit || {};