diff --git a/src/components/Home/Home.tsx b/src/components/Home/Home.tsx
index 8d1c044..3cb9852 100644
--- a/src/components/Home/Home.tsx
+++ b/src/components/Home/Home.tsx
@@ -16,31 +16,159 @@ export interface ScanResult {
[key: string]: string;
}
+// const Home = () => {
+// const { send } = useAppBridge();
+// const { receive } = useWebBridge();
+
+// const { scanData, setScanData } = useScanDataStore();
+
+// const { navigateToReceiptEdit } = useRoute();
+
+// // receive({ type: WebBridgeMessageType.RECEIVE_SCAN_RESULT, payload: scanData });
+
+// useEffect(() => {
+// // receive({ type: WebBridgeMessageType.RECEIVE_SCAN_RESULT, payload: scanData });
+// // window.response = {
+// // receiveScanResult: (jsonData: string) => {
+// // try {
+// // const data: ScanResult[] = JSON.parse(jsonData);
+// // setAbc(true);
+// // setScanData(data);
+// // // navigateToReceiptEdit();
+// // } catch (error) {
+// // console.error("Error parsing scan result JSON:", error);
+// // }
+// // },
+// // };
+// }, []);
+
+// return (
+//
+//
+//
+// {`영수증으로\nAI 음식 리뷰 남겨요`}
+//
+//
+// {scanData.length > 0 &&
+// scanData.map((data) => (
+// <>
+// {Object.keys(data).map((key) => (
+//
+//
+// {key}
+//
+//
+// {data[key]}
+//
+//
+// ))}
+// >
+// ))}
+// 손쉬운 음식 리뷰 작성
+//
+//
+//
+//

+//
+//
+// send({ type: AppBridgeMessageType.OPEN_GALLERY, payload: "" })}
+// />
+// {
+// send({ type: AppBridgeMessageType.OPEN_CAMERA, payload: "" });
+
+// // 네이티브 데이터 수신 핸들러 등록
+// window.response = {
+// receiveScanResult: (jsonData: string) => {
+// try {
+// const data: ScanResult[] = JSON.parse(jsonData);
+// receive({
+// type: WebBridgeMessageType.RECEIVE_SCAN_RESULT,
+// payload: data,
+// });
+
+// // 데이터 저장 및 페이지 이동
+// setScanData(data);
+// setTimeout(() => {
+// navigateToReceiptEdit();
+// }, 0);
+// // navigateToReceiptEdit();
+// } catch (error) {
+// console.error("Error parsing scan result JSON:", error);
+// }
+// },
+// };
+// }}
+// />
+
+// {/* */}
+
+//
+//
+//
+// );
+// };
+
+// export default Home;
+
const Home = () => {
const { send } = useAppBridge();
const { receive } = useWebBridge();
-
const { scanData, setScanData } = useScanDataStore();
-
const { navigateToReceiptEdit } = useRoute();
- // receive({ type: WebBridgeMessageType.RECEIVE_SCAN_RESULT, payload: scanData });
-
useEffect(() => {
// receive({ type: WebBridgeMessageType.RECEIVE_SCAN_RESULT, payload: scanData });
- // window.response = {
- // receiveScanResult: (jsonData: string) => {
- // try {
- // const data: ScanResult[] = JSON.parse(jsonData);
- // setAbc(true);
- // setScanData(data);
- // // navigateToReceiptEdit();
- // } catch (error) {
- // console.error("Error parsing scan result JSON:", error);
- // }
- // },
- // };
- }, []);
+ if (typeof window !== "undefined" && !window.response) {
+ window.response = {
+ receiveScanResult: (jsonData: string) => {
+ try {
+ const data: ScanResult[] = JSON.parse(jsonData);
+ receive({
+ type: WebBridgeMessageType.RECEIVE_SCAN_RESULT,
+ payload: data,
+ });
+
+ // 데이터 저장 및 페이지 이동
+ setScanData(data);
+ setTimeout(() => {
+ navigateToReceiptEdit();
+ }, 0);
+ } catch (error) {
+ console.error("Error parsing scan result JSON:", error);
+ }
+ },
+ };
+ }
+ }, [receive, navigateToReceiptEdit, setScanData]);
return (
@@ -81,47 +209,31 @@ const Home = () => {
iconName="camera"
onClick={() => {
send({ type: AppBridgeMessageType.OPEN_CAMERA, payload: "" });
+ // 네이티브에서 데이터를 수신하는 핸들러 설정
+ if (typeof window !== "undefined" && !window.response) {
+ window.response = {
+ receiveScanResult: (jsonData: string) => {
+ try {
+ const data: ScanResult[] = JSON.parse(jsonData);
+ receive({
+ type: WebBridgeMessageType.RECEIVE_SCAN_RESULT,
+ payload: data,
+ });
- // 네이티브 데이터 수신 핸들러 등록
- window.response = {
- receiveScanResult: (jsonData: string) => {
- try {
- const data: ScanResult[] = JSON.parse(jsonData);
- receive({
- type: WebBridgeMessageType.RECEIVE_SCAN_RESULT,
- payload: data,
- });
-
- // 데이터 저장 및 페이지 이동
- setScanData(data);
- setTimeout(() => {
- navigateToReceiptEdit();
- }, 0);
- // navigateToReceiptEdit();
- } catch (error) {
- console.error("Error parsing scan result JSON:", error);
- }
- },
- };
+ // 데이터 저장 및 페이지 이동
+ setScanData(data);
+ setTimeout(() => {
+ navigateToReceiptEdit();
+ }, 0);
+ } catch (error) {
+ console.error("Error parsing scan result JSON:", error);
+ }
+ },
+ };
+ }
}}
/>
-
- {/* */}
-
+ {/* 테스트용 버튼 */}