Skip to content

Commit

Permalink
Fix/드림 테스트 전 영수증 속도 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
choiyoubin committed Mar 26, 2024
1 parent a0c4314 commit 868b1a5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/hooks/usePrintHandler.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useContext, useState } from "react";
import { render } from "react-thermal-printer";
// import { useContext } from "react";
// import { useRecoilState } from "recoil";
// import { portState } from "../Atom/status";
import UserReceipt from "../components/UserReceipt";
Expand All @@ -11,6 +12,7 @@ const usePrintHandler = () => {
console.log(selectedInfo);
// const [savePort, setSavePort] = useRecoilState(portState);
const [savePort, setSavePort] = useState(null);
console.log(savePort);

const onClickPrintHandler = async () => {
const data = await render(UserReceipt(selectedInfo[0]));
Expand All @@ -19,13 +21,14 @@ const usePrintHandler = () => {
if (savePort === null) {
port = await window.navigator?.serial?.requestPort();
setSavePort(port);
} else if (savePort !== null) {
} else if (savePort !== null ) {
port = savePort;
}

console.log(port);
if (port.writable === null) {
await port.open({ baudRate: 38400 });
// await port.open({ baudRate: 38400 });
await port.open({ baudRate: 9600 });
}
const writer = port.writable?.getWriter();
if (writer !== null) {
Expand Down

0 comments on commit 868b1a5

Please sign in to comment.