Skip to content

Commit

Permalink
Fixes deleting user linked accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
Chakravarthy7102 committed Mar 8, 2024
1 parent 1bd5959 commit 9183773
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/ui/components/userDetail/loginMethods/LoginMethods.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ export const LoginMethods: React.FC<LoginMethodProps> = ({ refetchAllData, refet
getUserDeleteConfirmationProps({
loginMethod: loginMethod,
user: userDetail.details,
onDeleteCallback: (user) => onDeleteCallback(user.id),
onDeleteCallback: (userId) => onDeleteCallback(userId),
all: false,
})
),
Expand Down
3 changes: 1 addition & 2 deletions src/ui/components/userDetail/userDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { getTenantsObjectsForIds } from "../../../utils/user";
import { PopupContentContext } from "../../contexts/PopupContentContext";
import { User, UserRecipeType } from "../../pages/usersList/types";
import { getMissingTenantIdModalProps } from "../common/modals/TenantIdModals";
import { OnSelectUserFunction } from "../usersListTable/UsersListTable";
import { UserDetailContextProvider } from "./context/UserDetailContext";
import { LoginMethods } from "./loginMethods/LoginMethods";
import "./tenantList/UserTenantsList.scss";
Expand All @@ -38,7 +37,7 @@ import UserRolesList from "./userRoles/UserRolesList";
export type UserDetailProps = {
user: string;
onBackButtonClicked: () => void;
onDeleteCallback: OnSelectUserFunction;
onDeleteCallback: (userId: string) => void;
onSendEmailVerificationCallback: (user: User) => Promise<boolean>;
onUpdateEmailVerificationStatusCallback: (
userId: string,
Expand Down
9 changes: 6 additions & 3 deletions src/ui/components/userDetail/userDetailForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { getMissingTenantIdModalProps } from "../common/modals/TenantIdModals";
import InputField from "../inputField/InputField";
import { LayoutModalProps } from "../layout/layoutModal";
import { ToastNotificationProps } from "../toast/toastNotification";
import { OnSelectUserFunction } from "../usersListTable/UsersListTable";
import "./userDetailForm.scss";

type PasswordChangeCallback = (password?: string) => Promise<void>;
Expand Down Expand Up @@ -61,7 +60,7 @@ type UserDeleteConfirmationProps = UserProps & {
type UserUnlinkConfirmationProps = { onConfirmed: (isConfirmed: boolean) => void; loginMethod: LoginMethod };

type UserDeleteConfirmationTriggerProps = UserProps & {
onDeleteCallback: OnSelectUserFunction;
onDeleteCallback: (userId: string) => void;
loginMethod?: LoginMethod;
all: boolean;
};
Expand Down Expand Up @@ -549,7 +548,11 @@ export const getUserDeleteConfirmationProps = (props: UserDeleteConfirmationTrig

const onConfirmedDelete = (isConfirmed: boolean) => {
if (isConfirmed) {
onDeleteCallback(user);
if (loginMethod) {
onDeleteCallback(loginMethod.recipeUserId);
} else {
onDeleteCallback(user.id);
}
}
closeConfirmDeleteRef.current?.();
};
Expand Down
4 changes: 2 additions & 2 deletions src/ui/pages/usersList/UsersList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ export const UserListPage = () => {
}}
user={selectedUser}
onBackButtonClicked={backToList}
onDeleteCallback={({ id }) => onUserDelete(id)}
onDeleteCallback={(userId) => onUserDelete(userId)}
onSendEmailVerificationCallback={({ id, tenantIds }) => {
return sendUserEmailVerification(id, tenantIds.length > 0 ? tenantIds[0] : undefined);
}}
Expand All @@ -500,7 +500,7 @@ export const UserListPage = () => {
css={isSelectedUserNotEmpty ? { display: "none" } : undefined}
reloadRef={reloadListRef}
onChangePasswordCallback={changePassword}
onDeleteCallback={({ id }) => onUserDelete(id)}
onDeleteCallback={(userId) => onUserDelete(userId)}
/>
</AppEnvContextProvider>
);
Expand Down

0 comments on commit 9183773

Please sign in to comment.