feature/IO-3255-simplified-parts-management -Checkpoint
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { LockOutlined, UserOutlined } from "@ant-design/icons";
|
||||
import { Button, Form, Input, Typography } from "antd";
|
||||
import queryString from "query-string";
|
||||
import React, { useEffect } from "react";
|
||||
import { useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { Link, useLocation, useNavigate } from "react-router-dom";
|
||||
@@ -42,6 +42,42 @@ export function SignInComponent({ emailSignInStart, currentUser, signInError, se
|
||||
}
|
||||
}, [currentUser, redirect, navigate]);
|
||||
|
||||
// Add event listener for seamless login
|
||||
useEffect(() => {
|
||||
const handleSeamlessLogin = (event) => {
|
||||
const { email, password, origin: requestOrigin } = event.detail || {};
|
||||
|
||||
// Validate input
|
||||
if (!email || !password) {
|
||||
window.parent.postMessage(
|
||||
{ type: "seamlessLoginResponse", status: "error", message: "Email and password are required" },
|
||||
requestOrigin || "*" // Use specific origin for security if known
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the user is already logged in
|
||||
if (currentUser.authorized === true) {
|
||||
console.log("User is already logged in, redirecting...");
|
||||
navigate(redirect || "/manage/");
|
||||
window.parent.postMessage({ type: "seamlessLoginResponse", status: "already_logged_in" }, requestOrigin || "*");
|
||||
return;
|
||||
}
|
||||
|
||||
// Proceed with sign-in if not logged in
|
||||
emailSignInStart(email, password);
|
||||
window.parent.postMessage({ type: "seamlessLoginResponse", status: "login_attempted" }, requestOrigin || "*");
|
||||
};
|
||||
|
||||
// Add event listener for custom seamless login event
|
||||
window.addEventListener("seamlessLoginRequest", handleSeamlessLogin);
|
||||
|
||||
// Cleanup to remove the event listener on unmount
|
||||
return () => {
|
||||
window.removeEventListener("seamlessLoginRequest", handleSeamlessLogin);
|
||||
};
|
||||
}, [emailSignInStart, currentUser, navigate, redirect]);
|
||||
|
||||
return (
|
||||
<div className="login-container">
|
||||
<div className="login-logo-container">
|
||||
|
||||
@@ -18,7 +18,6 @@ import GlobalFooter from "../../components/global-footer/global-footer.component
|
||||
import HeaderContainer from "../../components/header/header.container";
|
||||
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
|
||||
import PartnerPingComponent from "../../components/partner-ping/partner-ping.component";
|
||||
import PrintCenterModalContainer from "../../components/print-center-modal/print-center-modal.container";
|
||||
import ShopSubStatusComponent from "../../components/shop-sub-status/shop-sub-status.component";
|
||||
import UpdateAlert from "../../components/update-alert/update-alert.component";
|
||||
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
|
||||
@@ -27,6 +26,10 @@ import { selectAlerts } from "../../redux/application/application.selectors.js";
|
||||
import { selectBodyshop, selectInstanceConflict } from "../../redux/user/user.selectors";
|
||||
import InstanceRenderManager from "../../utils/instanceRenderMgr.js";
|
||||
|
||||
const PrintCenterModalContainer = lazy(
|
||||
() => import("../../components/print-center-modal/print-center-modal.container")
|
||||
);
|
||||
|
||||
const JobsPage = lazy(() => import("../jobs/jobs.page"));
|
||||
|
||||
const CardPaymentModalContainer = lazy(
|
||||
|
||||
@@ -10,7 +10,6 @@ import ConflictComponent from "../../components/conflict/conflict.component.jsx"
|
||||
import ErrorBoundary from "../../components/error-boundary/error-boundary.component.jsx";
|
||||
import GlobalFooter from "../../components/global-footer/global-footer.component.jsx";
|
||||
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component.jsx";
|
||||
import PrintCenterModalContainer from "../../components/print-center-modal/print-center-modal.container.jsx";
|
||||
import ShopSubStatusComponent from "../../components/shop-sub-status/shop-sub-status.component.jsx";
|
||||
import UpdateAlert from "../../components/update-alert/update-alert.component.jsx";
|
||||
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
|
||||
@@ -29,7 +28,9 @@ const EmailOverlayContainer = lazy(() => import("../../components/email-overlay/
|
||||
const FeatureRequestPage = lazy(() => import("../feature-request/feature-request.page.jsx"));
|
||||
const ReportCenterModal = lazy(() => import("../../components/report-center-modal/report-center-modal.container.jsx"));
|
||||
const Help = lazy(() => import("../help/help.page.jsx"));
|
||||
|
||||
const PrintCenterModalContainer = lazy(
|
||||
() => import("../../components/print-center-modal/print-center-modal.container")
|
||||
);
|
||||
const { Content } = Layout;
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Card, FloatButton, Layout } from "antd";
|
||||
import React, { lazy, Suspense, useEffect } from "react";
|
||||
import { lazy, Suspense, useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { Route, Routes, useNavigate } from "react-router-dom";
|
||||
@@ -40,7 +40,7 @@ const { Content } = Layout;
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
technician: selectTechnician
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
const mapDispatchToProps = () => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user