simple get inventory
This commit is contained in:
@@ -20,6 +20,9 @@ export function HotelProvider({ accessToken, children, resClientId}) {
|
||||
|
||||
|
||||
// --- API FUNCTIONS ---
|
||||
|
||||
// ROOMS
|
||||
|
||||
async function fetchRooms() {
|
||||
const res = await fetch( `${API_BASE}/rooms/rooms`, {
|
||||
headers: { Authorization: `Bearer ${accessTokenSingle}` },
|
||||
@@ -27,7 +30,7 @@ export function HotelProvider({ accessToken, children, resClientId}) {
|
||||
return res.json();
|
||||
}
|
||||
|
||||
async function updateRoomStatus(roomId, status) {
|
||||
async function updateRoomStatus(roomId, status) {
|
||||
await fetch(`${API_BASE}/rooms/clean_db_update/${roomId}`, {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
@@ -41,27 +44,11 @@ export function HotelProvider({ accessToken, children, resClientId}) {
|
||||
const updated = await fetchRooms();
|
||||
setRooms(updated);
|
||||
}
|
||||
|
||||
|
||||
async function fetchHotelUsers() {
|
||||
const res = await fetch(`${API_BASE}/chat/hotel_users`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessTokenSingle}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
const users = await res.json();
|
||||
|
||||
// CHAT
|
||||
|
||||
const map = {};
|
||||
for (const u of users) {
|
||||
map[u.id] = u.username;
|
||||
}
|
||||
setUsersById(map);
|
||||
|
||||
// setUsers(users)
|
||||
return users;
|
||||
}
|
||||
|
||||
async function createConversation(name) {
|
||||
|
||||
@@ -186,6 +173,48 @@ export function HotelProvider({ accessToken, children, resClientId}) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// INVENTORY
|
||||
|
||||
|
||||
async function fetchHotelInventory() {
|
||||
|
||||
const res = await fetch ( `${API_BASE}/inventory/get_item/`, {
|
||||
headers: { Authorization: `Bearer ${accessTokenSingle}`},
|
||||
});
|
||||
|
||||
console.log ("fetched inventory")
|
||||
|
||||
return res.json()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function fetchHotelUsers() {
|
||||
const res = await fetch(`${API_BASE}/chat/hotel_users`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessTokenSingle}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
const users = await res.json();
|
||||
|
||||
const map = {};
|
||||
for (const u of users) {
|
||||
map[u.id] = u.username;
|
||||
}
|
||||
setUsersById(map);
|
||||
|
||||
// setUsers(users)
|
||||
return users;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// --- INITIAL DATA LOADING ---
|
||||
useEffect(() => {
|
||||
if (!accessToken) return;
|
||||
@@ -222,7 +251,8 @@ export function HotelProvider({ accessToken, children, resClientId}) {
|
||||
sendMessage,
|
||||
fetchHotelUsers,
|
||||
addUserToConv,
|
||||
createConversation
|
||||
createConversation,
|
||||
fetchHotelInventory
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
|
||||
Reference in New Issue
Block a user