Skip to content

Commit

Permalink
feat: 임시 UT navigate 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
lgrin-byte committed Feb 8, 2025
1 parent 81a1c59 commit a56c803
Showing 1 changed file with 7 additions and 34 deletions.
41 changes: 7 additions & 34 deletions src/components/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,27 @@ export interface ScanResult {
}

const Home = () => {
const [abc, setAbc] = useState(false);
const { send } = useAppBridge();
const { navigateToReceiptEdit } = useRoute();

const testNavigate = () => {
if (window.response) {
window.response.receiveScanResult(
JSON.stringify([{ 가게명: "청담커피 앤 토스트" }, { 메뉴명: "아아" }]),
);
}
setTimeout(() => {
navigateToReceiptEdit();
}, 3000);
};

const { scanData, setScanData } = useScanDataStore();

const { navigateToReceiptEdit } = useRoute();

useEffect(() => {
window.response = {
receiveScanResult: (jsonData: string) => {
try {
const data: ScanResult[] = JSON.parse(jsonData);
setAbc(true);
setScanData(data);
// navigateToReceiptEdit();
} catch (error) {
Expand All @@ -48,25 +49,9 @@ const Home = () => {
<div className={styles.Home}>
<div className={styles.HomeTitle}>
<Text variant="titleLg" color="gradient" align="center" as="h1">
{abc && "스캔 완료 테스트용"}
{`영수증으로\nAI 음식 리뷰 남겨요`}
</Text>
<Text variant="bodyLg" color="secondary" align="center">
{scanData.length > 0 &&
scanData.map((data) => (
<>
{Object.keys(data).map((key) => (
<div key={key}>
<Text variant="bodyXsm" color="secondary">
{key}
</Text>
<Text variant="bodyXsm" color="secondary">
{data[key]}
</Text>
</div>
))}
</>
))}
손쉬운 음식 리뷰 작성
</Text>
</div>
Expand All @@ -78,30 +63,18 @@ const Home = () => {
text="갤러리"
iconName="gallery"
onClick={() => {
send({ type: AppBridgeMessageType.OPEN_GALLERY , payload: "" });
send({ type: AppBridgeMessageType.OPEN_GALLERY, payload: "" });
testNavigate();
}}
/>
<IconButton
text="카메라"
iconName="camera"
onClick={() => {
send({ type: AppBridgeMessageType.OPEN_CAMERA , payload: "" });
send({ type: AppBridgeMessageType.OPEN_CAMERA, payload: "" });
testNavigate();
}}
/>

<button
onClick={() => {
if (window.response) {
window.response.receiveScanResult(
JSON.stringify([{ sampleKey: "sampleValue" }, { sampleKey2: "sampleValue2" }]),
);
}
}}
>
테스트 데이터 전송
</button>
</div>
</div>
);
Expand Down

0 comments on commit a56c803

Please sign in to comment.