@@ -24,11 +24,12 @@ const ReceiptEdit = () => {
2424 const [ focusState , setFocusState ] = useState < { [ key : string ] : boolean } > ( { } ) ;
2525
2626 useEffect ( ( ) => {
27- if ( Array . isArray ( scanData ) && scanData . length > 0 ) {
28- setFormData ( scanData ) ;
27+ if ( Array . isArray ( scanData . parsed ) && scanData . parsed . length > 0 ) {
28+ setFormData ( scanData . parsed ) ;
2929
30- const initialFocusState = scanData . reduce (
31- ( acc , data ) => {
30+ const initialFocusState = scanData . parsed . reduce (
31+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
32+ ( acc : any , data : any ) => {
3233 const keys = Object . keys ( data ) ;
3334 keys . forEach ( ( key ) => ( acc [ key ] = false ) ) ;
3435 return acc ;
@@ -49,7 +50,12 @@ const ReceiptEdit = () => {
4950
5051 const handleInputChange = ( index : number , key : string , value : string ) => {
5152 setFormData ( ( prevData ) =>
52- prevData . map ( ( item , idx ) => ( idx === index ? { ...item , [ key ] : value } : item ) ) ,
53+ prevData . map ( ( item , idx ) => {
54+ if ( idx === index ) {
55+ return { ...item , [ key ] : value } ;
56+ }
57+ return item ;
58+ } ) ,
5359 ) ;
5460 } ;
5561
@@ -79,9 +85,7 @@ const ReceiptEdit = () => {
7985 < div className = { styles . Top } >
8086 < div className = { styles . TitleBox } >
8187 < Text variant = "titleM" color = "primary" as = "h1" truncated >
82- { formData . length > 0 &&
83- Object . keys ( formData [ 0 ] ) . length > 0 &&
84- formData [ 0 ] [ Object . keys ( formData [ 0 ] ) [ 0 ] ] }
88+ { formData . length > 0 && Object . keys ( formData [ 0 ] ) . length > 0 && formData [ 0 ] . value }
8589 </ Text >
8690 < Text variant = "titleM" color = "primary" as = "h1" >
8791 에
@@ -94,21 +98,19 @@ const ReceiptEdit = () => {
9498 < div className = { styles . InfoList } >
9599 { formData . map ( ( data , index ) => (
96100 < div key = { index } className = { styles . InfoItem } >
97- { Object . keys ( data ) . map ( ( key ) => (
98- < div key = { key } className = { styles . InfoItem } >
99- < Text variant = "bodyXsm" color = "secondary" >
100- { key }
101- </ Text >
102- < Input
103- placeholder = { `${ key } 입력` }
104- value = { data [ key ] }
105- onFocus = { ( ) => handleFocus ( key ) }
106- onBlur = { ( ) => handleBlur ( key ) }
107- isFocus = { focusState [ key ] || false }
108- onChange = { ( e ) => handleInputChange ( index , key , e . target . value ) }
109- />
110- </ div >
111- ) ) }
101+ < div className = { styles . InfoItem } >
102+ < Text variant = "bodyXsm" color = "secondary" >
103+ { data . key }
104+ </ Text >
105+ < Input
106+ placeholder = { `${ data . key } 입력` }
107+ value = { data . value }
108+ onFocus = { ( ) => handleFocus ( data . key ) }
109+ onBlur = { ( ) => handleBlur ( data . key ) }
110+ isFocus = { focusState [ data . key ] || false }
111+ onChange = { ( e ) => handleInputChange ( index , data . key , e . target . value ) }
112+ />
113+ </ div >
112114 </ div >
113115 ) ) }
114116 </ div >
0 commit comments