Merge branch 'main' of http://45.93.137.91:3000/Rahaf/SweetHome
All checks were successful
Build frontend / build (push) Successful in 54s
All checks were successful
Build frontend / build (push) Successful in 54s
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -93,6 +93,18 @@ const AuthService = Object.freeze({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current authenticated user id
|
||||||
|
* @returns {number|string|null}
|
||||||
|
*/
|
||||||
|
getUserId() {
|
||||||
|
const user = this.getUser();
|
||||||
|
if (!user?.id) return null;
|
||||||
|
|
||||||
|
const parsedId = Number(user.id);
|
||||||
|
return Number.isFinite(parsedId) ? parsedId : user.id;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get roles array from JWT
|
* Get roles array from JWT
|
||||||
* @returns {string[]}
|
* @returns {string[]}
|
||||||
|
|||||||
@ -134,7 +134,7 @@ export async function getAvailableDateRanges(propertyId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getReservations() {
|
export async function getReservations() {
|
||||||
return apiFetch('/Reservations/GetReservations');
|
return apiFetch('/Reservations/GetAllReservations');
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getReservation(id) {
|
export async function getReservation(id) {
|
||||||
@ -380,6 +380,68 @@ export async function confirmDepositPayment(bookingId) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function adminConfirmDeposit(reservationId, adminId, comment = null) {
|
||||||
|
const token = AuthService.getToken();
|
||||||
|
const endpoint = `${API_BASE}/Reservations/AdminConfirmDeposit/admin-confirm-deposit`;
|
||||||
|
const normalizedComment =
|
||||||
|
typeof comment === 'string' && comment.trim()
|
||||||
|
? comment.trim()
|
||||||
|
: null;
|
||||||
|
const payload = {
|
||||||
|
reservationId,
|
||||||
|
adminId,
|
||||||
|
comment: normalizedComment,
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log('[API] AdminConfirmDeposit request', {
|
||||||
|
method: 'PUT',
|
||||||
|
endpoint,
|
||||||
|
payload,
|
||||||
|
adminIdSource: 'jwt-user-id',
|
||||||
|
hasToken: Boolean(token),
|
||||||
|
tokenPreview: token ? `${token.slice(0, 18)}...${token.slice(-8)}` : null,
|
||||||
|
});
|
||||||
|
|
||||||
|
const res = await fetch(endpoint, {
|
||||||
|
method: 'PUT',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
...(token && { Authorization: `Bearer ${token}` }),
|
||||||
|
},
|
||||||
|
body: JSON.stringify(payload),
|
||||||
|
});
|
||||||
|
|
||||||
|
const text = await res.text();
|
||||||
|
let data = null;
|
||||||
|
|
||||||
|
console.log('[API] AdminConfirmDeposit raw response', {
|
||||||
|
status: res.status,
|
||||||
|
ok: res.ok,
|
||||||
|
endpoint,
|
||||||
|
rawText: text,
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
data = text ? JSON.parse(text) : null;
|
||||||
|
if (data && typeof data === 'object' && 'data' in data) {
|
||||||
|
data = data.data;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
data = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
const message = typeof data === 'object' && data?.message ? data.message : null;
|
||||||
|
|
||||||
|
console.log('[API] AdminConfirmDeposit parsed response', {
|
||||||
|
status: res.status,
|
||||||
|
ok: res.ok,
|
||||||
|
message,
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
|
||||||
|
return { status: res.status, data, ok: res.ok, message };
|
||||||
|
}
|
||||||
|
|
||||||
export async function updateBookingStatus(bookingId, status) {
|
export async function updateBookingStatus(bookingId, status) {
|
||||||
return apiFetch('/Reservations/UpdateStatus', {
|
return apiFetch('/Reservations/UpdateStatus', {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
|
|||||||
Reference in New Issue
Block a user