@@ -18,8 +18,10 @@ export const FileSelector: React.VFC<{
18
18
openContentPlayer : ( _ : ContentPlayerPlayingContent ) => Promise < number >
19
19
requestDialog : Parameters < InitPluginInRenderer > [ 0 ] [ "rpc" ] [ "requestDialog" ]
20
20
} > = ( { services, setPlayingContent, openContentPlayer, requestDialog } ) => {
21
- const [ filePath , setFilePath ] = useState ( "" )
22
- const [ startAt , setStartAt ] = useState ( "" )
21
+ const [ url , setFilePath ] = useState ( "" )
22
+ const [ startAt , setStartAt ] = useState (
23
+ dayjs ( ) . startOf ( "hour" ) . format ( "YYYY-MM-DDTHH:mm" )
24
+ )
23
25
const [ duration , setDuration ] = useState ( 30 )
24
26
const [ serviceId , setServiceId ] = useState ( - 1 )
25
27
@@ -34,13 +36,13 @@ export const FileSelector: React.VFC<{
34
36
</ div >
35
37
< div className = "w-full flex overflow-auto p-4" >
36
38
< form
39
+ className = { clsx ( "w-full" ) }
37
40
onSubmit = { ( e ) => {
38
41
e . preventDefault ( )
39
- if ( ! filePath ) {
42
+ if ( ! url ) {
40
43
return
41
44
}
42
45
const contentType = "Local"
43
- const url = "file://" + filePath
44
46
const service = services . find (
45
47
( service ) => service . serviceId === serviceId
46
48
)
@@ -77,11 +79,12 @@ export const FileSelector: React.VFC<{
77
79
className = { clsx (
78
80
"block mt-1 form-input rounded-l-md w-full text-gray-900 focus:outline-none cursor-pointer"
79
81
) }
80
- value = { filePath || "" }
82
+ value = { url || "" }
81
83
onChange = { ( e ) => setFilePath ( e . target . value ) }
82
84
spellCheck = { false }
83
85
/>
84
86
< button
87
+ type = "button"
85
88
className = { clsx (
86
89
`px-4 py-2 mt-1 rounded-r-md flex items-center justify-center bg-gray-200 text-gray-900 focus:outline-none cursor-pointer`
87
90
) }
@@ -96,14 +99,14 @@ export const FileSelector: React.VFC<{
96
99
if ( ! path ) {
97
100
return
98
101
}
99
- setFilePath ( path )
102
+ setFilePath ( "file://" + path )
100
103
} }
101
104
>
102
105
< File className = "pointer-events-none" size = "1.75rem" />
103
106
</ button >
104
107
</ div >
105
108
</ label >
106
- < div className = { clsx ( "flex" , "space-x-2" ) } >
109
+ < div className = { clsx ( "flex" , "space-x-2" , "W-full" ) } >
107
110
< label className = "block mt-2" >
108
111
< span > 開始時間</ span >
109
112
< input
@@ -127,10 +130,10 @@ export const FileSelector: React.VFC<{
127
130
setDuration ( p )
128
131
} }
129
132
/>
130
- { startAt ? (
133
+ { startAt && dayjs ( startAt ) . isValid ( ) ? (
131
134
< span > { dayjs ( startAt ) . add ( duration , "minutes" ) . format ( ) } </ span >
132
135
) : (
133
- < span > 未選択 </ span >
136
+ < span > 無効な日付 </ span >
134
137
) }
135
138
</ label >
136
139
</ div >
@@ -151,7 +154,7 @@ export const FileSelector: React.VFC<{
151
154
</ option >
152
155
{ services . map ( ( service ) => {
153
156
return (
154
- < option key = { service . serviceId } value = { service . serviceId } >
157
+ < option key = { service . id } value = { service . serviceId } >
155
158
{ service . name }
156
159
</ option >
157
160
)
0 commit comments