-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add loading states to save, update and confirm delete button
- Loading branch information
1 parent
8e332df
commit c0be27c
Showing
6 changed files
with
129 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Box, Button, CircularProgress } from "@mui/material"; | ||
|
||
type DeleteButtonProps = { | ||
onClick: () => void; | ||
pendingRequest: boolean; | ||
}; | ||
|
||
export default function ConfirmDeleteButton({ | ||
onClick, | ||
pendingRequest, | ||
}: Readonly<DeleteButtonProps>) { | ||
return ( | ||
<Box sx={{ position: "relative" }}> | ||
<Button | ||
onClick={onClick} | ||
color={"error"} | ||
variant="contained" | ||
size={"small"} | ||
disabled={pendingRequest} | ||
sx={{ | ||
fontWeight: "bold", | ||
}} | ||
> | ||
Delete | ||
</Button> | ||
{pendingRequest && ( | ||
<CircularProgress | ||
size={24} | ||
sx={{ | ||
position: "absolute", | ||
top: "50%", | ||
left: "50%", | ||
marginTop: "-12px", | ||
marginLeft: "-12px", | ||
}} | ||
/> | ||
)} | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,37 @@ | ||
import { Button } from "@mui/material"; | ||
import { Box, Button, CircularProgress } from "@mui/material"; | ||
|
||
type SaveButtonProps = { | ||
onClick: () => void; | ||
pendingRequest: boolean; | ||
}; | ||
|
||
export default function SaveButton({ onClick }: Readonly<SaveButtonProps>) { | ||
export default function SaveButton({ | ||
onClick, | ||
pendingRequest, | ||
}: Readonly<SaveButtonProps>) { | ||
return ( | ||
<Button | ||
onClick={onClick} | ||
variant="contained" | ||
size={"small"} | ||
sx={{ fontWeight: "bold" }} | ||
> | ||
Save | ||
</Button> | ||
<Box sx={{ position: "relative" }}> | ||
<Button | ||
onClick={onClick} | ||
variant="contained" | ||
size={"small"} | ||
disabled={pendingRequest} | ||
sx={{ fontWeight: "bold" }} | ||
> | ||
Save | ||
</Button> | ||
{pendingRequest && ( | ||
<CircularProgress | ||
size={24} | ||
sx={{ | ||
position: "absolute", | ||
top: "50%", | ||
left: "50%", | ||
marginTop: "-12px", | ||
marginLeft: "-12px", | ||
}} | ||
/> | ||
)} | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,39 @@ | ||
import { Button } from "@mui/material"; | ||
import { Box, Button, CircularProgress } from "@mui/material"; | ||
|
||
type UpdateButtonProps = { | ||
onClick: () => void; | ||
pendingRequest: boolean; | ||
}; | ||
|
||
export default function UpdateButton({ onClick }: Readonly<UpdateButtonProps>) { | ||
export default function UpdateButton({ | ||
onClick, | ||
pendingRequest, | ||
}: Readonly<UpdateButtonProps>) { | ||
return ( | ||
<Button | ||
onClick={onClick} | ||
variant="contained" | ||
size={"small"} | ||
sx={{ | ||
fontWeight: "bold", | ||
}} | ||
> | ||
Update | ||
</Button> | ||
<Box sx={{ position: "relative" }}> | ||
<Button | ||
onClick={onClick} | ||
variant="contained" | ||
size={"small"} | ||
disabled={pendingRequest} | ||
sx={{ | ||
fontWeight: "bold", | ||
}} | ||
> | ||
Update | ||
</Button> | ||
{pendingRequest && ( | ||
<CircularProgress | ||
size={24} | ||
sx={{ | ||
position: "absolute", | ||
top: "50%", | ||
left: "50%", | ||
marginTop: "-12px", | ||
marginLeft: "-12px", | ||
}} | ||
/> | ||
)} | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters