import {useEffect} from "react";
import {TriPOS} from "redacted";
import {useLiveQuery} from "dexie-react-hooks";
import {db} from "../../dexie-utils/db";
import {useToast} from "../../hooks/useToast";
export default function TriPOSHelper() {
const { showToast } = useToast();
const restaurant = useLiveQuery(async ()=>{
return db.restaurant.get(1);
})
const station = useLiveQuery(async ()=>{
return db.station.get(1);
})
useEffect(()=>{
if(restaurant && station) {
TriPOS.initialize({
terminalId: "123",
accountToken: restaurant.fis_acct_token,
accountId: restaurant.fis_acct_id,
acceptorId: restaurant.fis_acceptor_id,
bluetoothIdentifier: station.terminal_device_id,
})
.then(()=>{
showToast({
message: "TriPOS Initialized Successfully!",
type: "success",
})
})
.catch(()=>{
showToast({
message: "TriPOS Initialization Error",
type: "error",
})
})
}
},[restaurant, station])
return null
}
import {useEffect} from "react";
import {TriPOS} from "redacted";
import {useLiveQuery} from "dexie-react-hooks";
import {db} from "../../dexie-utils/db";
import {useToast} from "../../hooks/useToast";
export default function TriPOSHelper() {
const { showToast } = useToast();
const restaurant = useLiveQuery(async ()=>{
return db.restaurant.get(1);
})
const station = useLiveQuery(async ()=>{
return db.station.get(1);
})
useEffect(()=>{
if(restaurant && station) {
TriPOS.initialize({
terminalId: "123",
accountToken: restaurant.fis_acct_token,
accountId: restaurant.fis_acct_id,
acceptorId: restaurant.fis_acceptor_id,
bluetoothIdentifier: station.terminal_device_id,
})
.then(()=>{
showToast({
message: "TriPOS Initialized Successfully!",
type: "success",
})
})
.catch(()=>{
showToast({
message: "TriPOS Initialization Error",
type: "error",
})
})
}
},[restaurant, station])
return null
}