Skip to content

Commit

Permalink
feat: added loader-to manage-production fetch, updated loader-names
Browse files Browse the repository at this point in the history
  • Loading branch information
malmen237 committed Apr 23, 2024
1 parent c88db6e commit ee5fb77
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/components/manage-productions/manage-productions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
FormLabel,
StyledWarningMessage,
} from "../landing-page/form-elements";
import { Spinner } from "../loader/loader";
import { LoaderDots, Spinner } from "../loader/loader";
import { useFetchProduction } from "../landing-page/use-fetch-production";
import { darkText, errorColour } from "../../css-helpers/defaults";
import { useDeleteProduction } from "./use-delete-production";
Expand Down Expand Up @@ -77,12 +77,14 @@ export const ManageProductions = () => {
min: 1,
});

const { error: productionFetchError, production } = useFetchProduction(
parseInt(productionId, 10)
);
const {
error: productionFetchError,
production,
loading: fetchLoader,
} = useFetchProduction(parseInt(productionId, 10));

const {
loading,
loading: deleteLoader,
error: productionDeleteError,
successfullDelete,
} = useDeleteProduction(removeId);
Expand All @@ -104,7 +106,7 @@ export const ManageProductions = () => {
}, [successfullDelete]);

const onSubmit: SubmitHandler<FormValue> = (value) => {
if (loading) return;
if (deleteLoader) return;

setRemoveId(parseInt(value.productionId, 10));
};
Expand Down Expand Up @@ -154,11 +156,11 @@ export const ManageProductions = () => {
{!verifyRemove && (
<ActionButton
type="submit"
className={loading ? "submit" : ""}
className={deleteLoader ? "submit" : ""}
onClick={() => setVerifyRemove(true)}
>
Remove
{loading && <Spinner className="create-production" />}
{deleteLoader && <Spinner className="create-production" />}
</ActionButton>
)}
{verifyRemove && (
Expand All @@ -167,16 +169,16 @@ export const ManageProductions = () => {
<VerifyButtons>
<Button
type="submit"
className={loading ? "submit" : ""}
disabled={loading}
className={deleteLoader ? "submit" : ""}
disabled={deleteLoader}
onClick={handleSubmit(onSubmit)}
>
Yes
{loading && <Spinner className="create-production" />}
{deleteLoader && <Spinner className="create-production" />}
</Button>
<Button
type="submit"
className={loading ? "submit" : ""}
className={deleteLoader ? "submit" : ""}
onClick={() => {
setVerifyRemove(false);
reset({
Expand All @@ -185,7 +187,7 @@ export const ManageProductions = () => {
}}
>
Go back
{loading && <Spinner className="create-production" />}
{deleteLoader && <Spinner className="create-production" />}
</Button>
</VerifyButtons>
</VerifyBtnWrapper>
Expand All @@ -194,6 +196,7 @@ export const ManageProductions = () => {
) : (
<StyledWarningMessage>
Please enter a production id
{fetchLoader && <LoaderDots className="in-active" text="" />}
</StyledWarningMessage>
)}
{showDeleteDoneMessage && (
Expand Down

0 comments on commit ee5fb77

Please sign in to comment.