bots-frontend/repository/bots.js

41 lines
1.0 KiB
JavaScript

import {http} from "../utils/http";
import useSWR from "swr";
const url = {
findAllLockeyInLocations: (qrCode) => `/bots/find-all/Lockey/${qrCode}`,
findLocationByQrCode: (qrCode) => `/locations/findOne/${qrCode}`,
createOrder: () => `/bots/create-order`,
checkTransaction: (orderId) => `/bots/find/one-history/${orderId}`,
expiredOrder: (id) => `/bots/expired-status/${id}`,
}
const hooks = {
useGetAllLockey(qrCode) {
return useSWR(url.findAllLockeyInLocations(qrCode), http.fetcher);
},
useGetLocationByQR(qrCode) {
return useSWR(url.findLocationByQrCode(qrCode), http.fetcher);
}
}
const api = {
async useCheckTransactionByOrderId(orderId) {
const res = await http.fetcher(url.checkTransaction(orderId));
return res
},
async createOrder(body) {
return await http.post(url.createOrder(), body)
},
updateStatusExpiredOrder(id) {
return http.put(url.expiredOrder(id));
}
}
export const botsRepository = {
url,
hooks,
api
}