Skip to content

Commit

Permalink
Disable create button if user got created
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruv-vendo committed Jan 25, 2024
1 parent cd42be4 commit db454ec
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/pages/AccessManagement/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const Users: FC = () => {

const { getRolesData } = useRole();

let rows =
const rows =
getUserIsSuccess && getUserData?.data ? (
getUserData?.data.map((user: any) => {
return (
Expand Down Expand Up @@ -88,7 +88,7 @@ const Users: FC = () => {
};

const handleCreateUser = () => {
let userRole: any = [];
const userRole: any = [];
if (SelectedRole !== '') {
userRole.push(SelectedRole);
}
Expand All @@ -99,7 +99,6 @@ const Users: FC = () => {
if (getUserData?.data?.includes(createUserInput) || createUserInput.length < 3) {
return true;
}

if (SelectedRole !== '') {
if (getRolesData?.data?.includes(SelectedRole)) {
return false;
Expand Down Expand Up @@ -201,7 +200,7 @@ const Users: FC = () => {
color="gray"
className={classes.modalActionBtn}
onClick={handleCreateUser}
disabled={createVaildtion()}>
disabled={createVaildtion() || !!createUserData?.data}>
Create
</Button>
<Button onClick={handleClose} variant="outline" color="gray" className={classes.modalCancelBtn}>
Expand Down

0 comments on commit db454ec

Please sign in to comment.