Skip to content

Commit

Permalink
Load Mods from Save requires factorio mod portal login
Browse files Browse the repository at this point in the history
  • Loading branch information
knoxfighter committed Jul 13, 2024
1 parent 299b33e commit 35fadb7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ui/App/views/Mods/components/LoadMods.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@ import Label from "../../../components/Label";
import {useForm} from "react-hook-form";
import Button from "../../../components/Button";
import modsResource from "../../../../api/resources/mods";
import modResource from "../../../../api/resources/mods";
import FactorioLogin from "./AddMod/components/FactorioLogin";

const LoadMods = ({refreshMods}) => {

const [saves, setSaves] = useState([]);
const {register, reset, handleSubmit} = useForm();
const [isLoading, setIsLoading] = useState(false);
const [isDisabled, setIsDisabled] = useState(true);
const [isFactorioAuthenticated, setIsFactorioAuthenticated] = useState(false);

useEffect(() => {
(async () => {
setIsFactorioAuthenticated(await modResource.portal.status())

const s = await savesResource.list()
setSaves(s);
if (s.length > 0) {
Expand All @@ -39,8 +44,8 @@ const LoadMods = ({refreshMods}) => {
.catch(() => setIsLoading(false))
}

return (
<form onSubmit={handleSubmit(loadMods)}>
return isFactorioAuthenticated
? <form onSubmit={handleSubmit(loadMods)}>
<Label text="Save" htmlFor="save"/>
<Select
register={register('save')}
Expand All @@ -53,7 +58,7 @@ const LoadMods = ({refreshMods}) => {
/>
<Button isSubmit={true} isDisabled={isDisabled} isLoading={isLoading}>Load</Button>
</form>
)
: <FactorioLogin setIsFactorioAuthenticated={setIsFactorioAuthenticated}/>
}

export default LoadMods;

0 comments on commit 35fadb7

Please sign in to comment.