Skip to content

Commit

Permalink
Disable delete when only 1 login method is available
Browse files Browse the repository at this point in the history
  • Loading branch information
ohansFavour committed Dec 3, 2024
1 parent 6dd60ec commit 3d33c62
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/ui/components/userDetail/loginMethods/LoginMethods.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ type MethodProps = {
updateContext: (val: LoginMethod, ind: number) => void;
index: number;
showUnlink: boolean;
showDelete: boolean;
};

const Methods: React.FC<MethodProps> = ({
Expand All @@ -146,6 +147,7 @@ const Methods: React.FC<MethodProps> = ({
updateContext,
index,
showUnlink,
showDelete,
}) => {
const { sendUserEmailVerification: sendUserEmailVerificationApi } = useVerifyUserTokenService();
const { showModal, showToast } = useContext(PopupContentContext);
Expand Down Expand Up @@ -252,6 +254,7 @@ const Methods: React.FC<MethodProps> = ({
onDelete={onDeleteCallback}
onUnlink={onUnlinkCallback}
showUnlink={showUnlink}
showDelete={showDelete}
/>
)}
{isEditing && (
Expand Down Expand Up @@ -462,6 +465,7 @@ export const LoginMethods: React.FC<LoginMethodProps> = ({ refetchAllData, refet
showUnlink={
methods.length > 1 || (userDetail.details.isPrimaryUser === true && methods.length === 1)
}
showDelete={methods.length > 1}
/>
))}
</LayoutPanel>
Expand Down
19 changes: 11 additions & 8 deletions src/ui/components/userDetail/loginMethods/components/dropDown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ type DropDOwnProps = {
onUnlink: () => void | null;
onDelete: () => void | null;
showUnlink: boolean;
showDelete: boolean;
};

export const DropDown = ({ onEdit, onUnlink, onDelete, showUnlink }: DropDOwnProps) => {
export const DropDown = ({ onEdit, onUnlink, onDelete, showUnlink, showDelete }: DropDOwnProps) => {
const [open, setOpen] = useState(false);
const [hover, setHover] = useState(false);
const ref = useRef(null);
Expand Down Expand Up @@ -47,13 +48,15 @@ export const DropDown = ({ onEdit, onUnlink, onDelete, showUnlink }: DropDOwnPro
Unlink
</div>
)}
<div onClick={() => close(onDelete)}>
<img
src={getImageUrl("delete-login-method.png")}
alt=""
/>{" "}
Delete
</div>
{showDelete && (
<div onClick={() => close(onDelete)}>
<img
src={getImageUrl("delete-login-method.png")}
alt=""
/>{" "}
Delete
</div>
)}
</div>
</div>
);
Expand Down

0 comments on commit 3d33c62

Please sign in to comment.