|
| 1 | +import { useState } from "react"; |
| 2 | + |
1 | 3 | import styles from "@/components/ReceiptEdit/ReceiptEdit.module.scss"; |
2 | 4 | import Button from "@/components/ui/Button/Button"; |
3 | 5 | import Input from "@/components/ui/Input/Input"; |
4 | 6 | import Text from "@/components/ui/Text/Text"; |
5 | 7 |
|
| 8 | +import { useFocus } from "@/hooks/common/useFocus"; |
| 9 | + |
6 | 10 | const ReceiptEdit = () => { |
7 | | - const placeName = "청담커피 앤 토스트"; |
| 11 | + const [placeName, setPlaceName] = useState("청담커피 앤 토스트"); |
| 12 | + const [foodName, setFoodName] = useState("카야토스트+음료세트"); |
| 13 | + |
| 14 | + const { isFocus: isPlaceFocus, onFocus: handlePlaceFocus, onBlur: handlePlaceBlur } = useFocus(); |
| 15 | + const { isFocus: isFoodFocus, onFocus: handleFoodFocus, onBlur: handleFoodBlur } = useFocus(); |
8 | 16 |
|
9 | 17 | return ( |
10 | 18 | <div className={styles.ReceiptEdit}> |
11 | 19 | <div className={styles.Top}> |
12 | | - <Text variant="titleM" color="primary" align="center" as="h1"> |
13 | | - {`${placeName}에\n다녀오셨네요!`} |
| 20 | + <div className={styles.TitleBox}> |
| 21 | + <Text variant="titleM" color="primary" as="h1" truncated> |
| 22 | + {placeName} |
| 23 | + </Text> |
| 24 | + <Text variant="titleM" color="primary" as="h1"> |
| 25 | + 에 |
| 26 | + </Text> |
| 27 | + </div> |
| 28 | + <Text variant="titleM" color="primary" as="h1" align="center"> |
| 29 | + 다녀오셨네요! |
14 | 30 | </Text> |
| 31 | + |
15 | 32 | <div className={styles.InfoList}> |
16 | 33 | <div className={styles.InfoItem}> |
17 | | - <p>가게명</p> |
18 | | - <Input placeholder="가게 이름" /> |
| 34 | + <Text variant="bodyXsm" color="secondary"> |
| 35 | + 가게명 |
| 36 | + </Text> |
| 37 | + <Input |
| 38 | + placeholder="가게 이름" |
| 39 | + value={placeName} |
| 40 | + onChange={(e) => setPlaceName(e.target.value)} |
| 41 | + onFocus={handlePlaceFocus} |
| 42 | + onBlur={handlePlaceBlur} |
| 43 | + isFocus={isPlaceFocus} |
| 44 | + /> |
| 45 | + </div> |
| 46 | + <div className={styles.InfoItem}> |
| 47 | + <Text variant="bodyXsm" color="secondary"> |
| 48 | + 음식명 |
| 49 | + </Text> |
| 50 | + <Input |
| 51 | + placeholder="음식 이름" |
| 52 | + value={foodName} |
| 53 | + onChange={(e) => setFoodName(e.target.value)} |
| 54 | + onFocus={handleFoodFocus} |
| 55 | + onBlur={handleFoodBlur} |
| 56 | + isFocus={isFoodFocus} |
| 57 | + /> |
19 | 58 | </div> |
20 | 59 | </div> |
21 | 60 | </div> |
22 | 61 |
|
23 | 62 | <div className={styles.Bottom}> |
24 | | - <Button text="다시 스캔하기" variant="secondary" /> |
25 | | - <Button text="정보가 맞아요" /> |
| 63 | + {isPlaceFocus || isFoodFocus ? ( |
| 64 | + <Button text="수정하기" disabled={!placeName || !foodName} /> |
| 65 | + ) : ( |
| 66 | + <> |
| 67 | + <Button text="다시 스캔하기" variant="secondary" /> |
| 68 | + <Button text="정보가 맞아요" disabled={!placeName || !foodName} /> |
| 69 | + </> |
| 70 | + )} |
26 | 71 | </div> |
27 | 72 | </div> |
28 | 73 | ); |
|
0 commit comments