bots-frontend/repository/bots.js
2022-11-11 17:03:31 +07:00

32 lines
811 B
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}`,
}
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
},
}
export const botsRepository = {
url,
hooks,
api
}