Skip to content

Commit

Permalink
removed default
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahendar0701 committed Dec 23, 2024
1 parent 8ef8b19 commit 6810996
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/components/Common/AuthorizedButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@ import AuthorizedChild from "@/CAREUI/misc/AuthorizedChild";

import { Button, ButtonProps } from "@/components/ui/button";

import { AuthorizedElementProps } from "@/Utils/AuthorizeFor";
import { AuthorizedElementProps, AuthorizedForCB } from "@/Utils/AuthorizeFor";

const AuthorizedButton: React.FC<AuthorizedElementProps & ButtonProps> = ({
authorizeFor,
...props
}) => {
if (!authorizeFor) {
throw new Error(
"The 'authorizeFor' prop is required for AuthorizedButton.",
);
}
type AuthorizedButtonProps = Omit<AuthorizedElementProps, "authorizeFor"> & {
authorizeFor: AuthorizedForCB;
} & ButtonProps;

const AuthorizedButton: React.FC<AuthorizedButtonProps> = (props) => {
return (
<AuthorizedChild authorizeFor={authorizeFor}>
<AuthorizedChild authorizeFor={props.authorizeFor}>
{({ isAuthorized }) => (
<Button {...props} disabled={props.disabled || !isAuthorized}>
{props.children}
Expand Down

0 comments on commit 6810996

Please sign in to comment.