File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
sample/src/components/organisms/products Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,13 @@ import { validationSchema } from '@/reducks/products/types'
4
4
import React , { ChangeEvent , useCallback } from 'react'
5
5
import { z } from 'zod'
6
6
7
- const BulkImportButton = React . memo ( function BulkImportButton ( ) {
7
+ type Props = {
8
+ acceptedFile ?: File
9
+ }
10
+
11
+ const BulkImportButton = React . memo ( function BulkImportButton ( {
12
+ acceptedFile,
13
+ } : Props ) {
8
14
const inputRef = React . useRef < HTMLInputElement > ( null )
9
15
const onChange = useCallback ( async ( event : ChangeEvent < HTMLInputElement > ) => {
10
16
const file = event . target . files ?. [ 0 ]
@@ -15,8 +21,13 @@ const BulkImportButton = React.memo(function BulkImportButton() {
15
21
} , [ ] )
16
22
17
23
const upload = useCallback ( ( ) => {
24
+ if ( acceptedFile ) {
25
+ alert ( JSON . stringify ( acceptedFile ) )
26
+ // todo ファイルが登録されている場合はそのままアップロードする
27
+ return
28
+ }
18
29
inputRef . current ?. click ( )
19
- } , [ ] )
30
+ } , [ acceptedFile ] )
20
31
21
32
return (
22
33
< div >
You can’t perform that action at this time.
0 commit comments