Skip to content

Commit

Permalink
fix: moved the loader into the submit-button
Browse files Browse the repository at this point in the history
  • Loading branch information
malmen237 committed Apr 8, 2024
1 parent 4e22e1c commit e8c3008
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/components/landing-page/create-production.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,18 @@ export const CreateProduction = () => {
}
}, [createdProductionId, dispatch, reset]);

if (loading) {
return <Loader />;
}
useEffect(() => {
if (createdProductionId) {
reset({
productionName: "",
defaultLine: "",
lines: [],
});
dispatch({
type: "PRODUCTION_CREATED",
});
}
}, [createdProductionId, dispatch, reset]);

return (
<FormContainer>
Expand Down Expand Up @@ -149,8 +158,13 @@ export const CreateProduction = () => {
Add Line
</ActionButton>

<ActionButton type="submit" onClick={handleSubmit(onSubmit)}>
<ActionButton
type="submit"
className={loading ? "submit" : ""}
onClick={handleSubmit(onSubmit)}
>
Create Production
{loading && <Loader />}
</ActionButton>
{createdProductionId !== null && (
<ProductionConfirmation>
Expand Down
5 changes: 5 additions & 0 deletions src/components/landing-page/form-elements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ export const ActionButton = styled.button`
&:hover {
cursor: pointer;
}
&.submit {
position: relative;
color: rgba(255, 255, 255, 0);
}
`;

export const StyledWarningMessage = styled.div`
Expand Down

0 comments on commit e8c3008

Please sign in to comment.