@@ -5,16 +5,21 @@ import Label from "../../../components/Label";
5
5
import { useForm } from "react-hook-form" ;
6
6
import Button from "../../../components/Button" ;
7
7
import modsResource from "../../../../api/resources/mods" ;
8
+ import modResource from "../../../../api/resources/mods" ;
9
+ import FactorioLogin from "./AddMod/components/FactorioLogin" ;
8
10
9
11
const LoadMods = ( { refreshMods} ) => {
10
12
11
13
const [ saves , setSaves ] = useState ( [ ] ) ;
12
14
const { register, reset, handleSubmit} = useForm ( ) ;
13
15
const [ isLoading , setIsLoading ] = useState ( false ) ;
14
16
const [ isDisabled , setIsDisabled ] = useState ( true ) ;
17
+ const [ isFactorioAuthenticated , setIsFactorioAuthenticated ] = useState ( false ) ;
15
18
16
19
useEffect ( ( ) => {
17
20
( async ( ) => {
21
+ setIsFactorioAuthenticated ( await modResource . portal . status ( ) )
22
+
18
23
const s = await savesResource . list ( )
19
24
setSaves ( s ) ;
20
25
if ( s . length > 0 ) {
@@ -39,8 +44,8 @@ const LoadMods = ({refreshMods}) => {
39
44
. catch ( ( ) => setIsLoading ( false ) )
40
45
}
41
46
42
- return (
43
- < form onSubmit = { handleSubmit ( loadMods ) } >
47
+ return isFactorioAuthenticated
48
+ ? < form onSubmit = { handleSubmit ( loadMods ) } >
44
49
< Label text = "Save" htmlFor = "save" />
45
50
< Select
46
51
register = { register ( 'save' ) }
@@ -53,7 +58,7 @@ const LoadMods = ({refreshMods}) => {
53
58
/>
54
59
< Button isSubmit = { true } isDisabled = { isDisabled } isLoading = { isLoading } > Load</ Button >
55
60
</ form >
56
- )
61
+ : < FactorioLogin setIsFactorioAuthenticated = { setIsFactorioAuthenticated } />
57
62
}
58
63
59
64
export default LoadMods ;
0 commit comments