Client: Confirm: added support EmpInvite

This commit is contained in:
Viktor Fomin 2023-06-27 13:50:26 +03:00
parent 794196e3a8
commit 5aa73dd4a5
3 changed files with 37 additions and 20 deletions

View File

@ -27,6 +27,11 @@ const Confirm = () => {
const path = "/confirm";
return (
<Switch>
<ConfirmRoute
forUnauthorized
path={`${path}/EmpInvite`}
component={CreateUserForm}
/>
<ConfirmRoute
forUnauthorized
path={`${path}/LinkInvite`}

View File

@ -111,11 +111,14 @@ const CreateUserForm = (props) => {
}
const fetchData = async () => {
const uid = linkData.uid;
const confirmKey = linkData.confirmHeader;
const user = await getUserFromConfirm(uid, confirmKey);
setUser(user);
if (linkData.type === "LinkInvite") {
const uid = linkData.uid;
const confirmKey = linkData.confirmHeader;
const user = await getUserFromConfirm(uid, confirmKey);
setUser(user);
} else {
setUser(null);
}
window.authCallback = authCallback;
setSsoLabel(capabilities?.ssoLabel);
@ -229,9 +232,10 @@ const CreateUserForm = (props) => {
const createConfirmUser = async (registerData, loginData, key) => {
const { login } = props;
const fromInviteLink = linkData.type === "LinkInvite" ? true : false;
const data = Object.assign(
{ fromInviteLink: true },
{ fromInviteLink: fromInviteLink },
registerData,
loginData
);
@ -395,7 +399,7 @@ const CreateUserForm = (props) => {
setIsPasswordErrorShow(true);
};
const userAvatar = user.hasAvatar ? user.avatar : DefaultUserPhoto;
const userAvatar = user && user.hasAvatar ? user.avatar : DefaultUserPhoto;
return (
<StyledPage>
@ -414,17 +418,23 @@ const CreateUserForm = (props) => {
{showGreeting && (
<>
<div className="greeting-block">
<Avatar className="avatar" role="user" source={userAvatar} />
<div className="user-info">
<Text fontSize="15px" fontWeight={600}>
{user.firstName} {user.lastName}
</Text>
<Text fontSize="12px" fontWeight={600} color="#A3A9AE">
{user.department}
</Text>
{user && (
<div className="greeting-block">
<Avatar
className="avatar"
role="user"
source={userAvatar}
/>
<div className="user-info">
<Text fontSize="15px" fontWeight={600}>
{user.firstName} {user.lastName}
</Text>
<Text fontSize="12px" fontWeight={600} color="#A3A9AE">
{user.department}
</Text>
</div>
</div>
</div>
)}
<div className="tooltip">
<span className="tooltiptext">{t("WelcomeUser")}</span>

View File

@ -28,7 +28,8 @@ export default function withLoader(WrappedComponent) {
if (
(type === "PasswordChange" ||
type === "LinkInvite" ||
type === "Activation") &&
type === "Activation" ||
type === "EmpInvite") &&
!passwordSettings
) {
axios
@ -57,7 +58,7 @@ export default function withLoader(WrappedComponent) {
}, [passwordSettings]);
useEffect(() => {
if (type === "LinkInvite") {
if (type === "LinkInvite" || type === "EmpInvite") {
axios.all([getAuthProviders(), getCapabilities()]).catch((error) => {
let errorMessage = "";
if (typeof error === "object") {
@ -85,7 +86,8 @@ export default function withLoader(WrappedComponent) {
? props.isLoaded
: type === "PasswordChange" ||
type === "LinkInvite" ||
type === "Activation"
type === "Activation" ||
type === "EmpInvite"
? !!passwordSettings
: true;