Skip to content

Commit

Permalink
Don't show submit button if server has no name
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoJF committed Oct 10, 2020
1 parent 2c7518a commit 89206dd
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Loader from "../ui/Loader";
import Error from "../ui/Error";
import tailwind from "../tailwind";
import useCost from "../hooks/useCost";
import useValidForm from "../hooks/useValidForm";

const OrderButton = tailwind.div(() => `
trans px-5 py-3 bg-green-500
Expand All @@ -18,10 +19,7 @@ const Center = tailwind.div(() => `

export default function SummarySubmitButton({onSubmit, text}) {
const servers = useServers();
const cost = useCost();

const _cost = cost.value / 100;
const valid = !isNaN(_cost) && cost.value > 0;
const validForm = useValidForm();

async function handleOnClick() {
await onSubmit();
Expand All @@ -43,7 +41,7 @@ export default function SummarySubmitButton({onSubmit, text}) {
</div>
}
{
!servers.loading && valid &&
!servers.loading && validForm &&
<OrderButton onClick={handleOnClick}>
{text}
</OrderButton>
Expand Down

0 comments on commit 89206dd

Please sign in to comment.