feature/IO-3255-simplified-parts-management -Checkpoint

This commit is contained in:
Dave Richer
2025-07-22 12:20:59 -04:00
parent 0ac9bbd97c
commit 6b5ad3dafa
6 changed files with 35 additions and 13 deletions

View File

@@ -7,13 +7,13 @@ import { connect } from "react-redux";
import { Route, Routes, useNavigate } from "react-router-dom";
import { createStructuredSelector } from "reselect";
import DocumentEditorContainer from "../components/document-editor/document-editor.container";
import ErrorBoundary from "../components/error-boundary/error-boundary.component"; // Component Imports
import ErrorBoundary from "../components/error-boundary/error-boundary.component";
import LoadingSpinner from "../components/loading-spinner/loading-spinner.component";
import DisclaimerPage from "../pages/disclaimer/disclaimer.page";
import LandingPage from "../pages/landing/landing.page";
import TechPageContainer from "../pages/tech/tech.page.container";
import SimplifiedPartsPageContainer from "../pages/simplified-parts/simplified-parts.page.container.jsx";
import { setOnline } from "../redux/application/application.actions";
import { setIsPartsEntry, setOnline } from "../redux/application/application.actions";
import { selectOnline } from "../redux/application/application.selectors";
import { checkUserSession } from "../redux/user/user.actions";
import { selectBodyshop, selectCurrentEula, selectCurrentUser } from "../redux/user/user.selectors";
@@ -39,10 +39,11 @@ const mapStateToProps = createStructuredSelector({
const mapDispatchToProps = (dispatch) => ({
checkUserSession: () => dispatch(checkUserSession()),
setOnline: (isOnline) => dispatch(setOnline(isOnline))
setOnline: (isOnline) => dispatch(setOnline(isOnline)),
setIsPartsEntry: (isParts) => dispatch(setIsPartsEntry(isParts))
});
export function App({ bodyshop, checkUserSession, currentUser, online, setOnline, currentEula }) {
export function App({ bodyshop, checkUserSession, currentUser, online, setOnline, setIsPartsEntry, currentEula }) {
const client = useSplitClient().client;
const [listenersAdded, setListenersAdded] = useState(false);
const { t } = useTranslation();
@@ -56,6 +57,12 @@ export function App({ bodyshop, checkUserSession, currentUser, online, setOnline
checkUserSession();
}, [checkUserSession, setOnline]);
useEffect(() => {
const pathname = window.location.pathname;
const isParts = pathname.startsWith("/parts/");
setIsPartsEntry(isParts);
}, [setIsPartsEntry]);
//const b = Grid.useBreakpoint();
// console.log("Breakpoints:", b);

View File

@@ -10,6 +10,7 @@ import RomeLogo from "../../assets/RomeOnlineBlue.png";
import ImEXOnlineLogo from "../../assets/logo192.png";
import { emailSignInStart, sendPasswordReset } from "../../redux/user/user.actions";
import { selectCurrentUser, selectLoginLoading, selectSignInError } from "../../redux/user/user.selectors";
import { selectIsPartsEntry } from "../../redux/application/application.selectors";
import InstanceRenderManager from "../../utils/instanceRenderMgr";
import AlertComponent from "../alert/alert.component";
import "./sign-in-form.styles.scss";
@@ -17,7 +18,8 @@ import "./sign-in-form.styles.scss";
const mapStateToProps = createStructuredSelector({
currentUser: selectCurrentUser,
signInError: selectSignInError,
loginLoading: selectLoginLoading
loginLoading: selectLoginLoading,
isPartsEntry: selectIsPartsEntry
});
const mapDispatchToProps = (dispatch) => ({
@@ -25,7 +27,7 @@ const mapDispatchToProps = (dispatch) => ({
sendPasswordReset: (email) => dispatch(sendPasswordReset(email))
});
export function SignInComponent({ emailSignInStart, currentUser, signInError, sendPasswordReset, loginLoading }) {
export function SignInComponent({ emailSignInStart, currentUser, signInError, loginLoading, isPartsEntry }) {
const { redirect } = queryString.parse(useLocation().search);
const navigate = useNavigate();
@@ -38,15 +40,16 @@ export function SignInComponent({ emailSignInStart, currentUser, signInError, se
useEffect(() => {
if (currentUser.authorized === true) {
navigate(redirect || "/manage/");
navigate(redirect || (isPartsEntry ? "/parts/" : "/manage/"));
}
}, [currentUser, redirect, navigate]);
}, [currentUser, redirect, navigate, isPartsEntry]);
useEffect(() => {
const handleSeamlessLogin = (event) => {
console.log("Received message event:", event); // Log the received message event
if (event.data?.type !== "seamlessLoginRequest") return; // Filter to only handle relevant messages
console.log("Received seamless login request:", event.data);
const { email, password } = event.data || {}; // Use event.data instead of event.detail
const requestOrigin = event.origin; // Use event.origin automatically
@@ -62,7 +65,7 @@ export function SignInComponent({ emailSignInStart, currentUser, signInError, se
// Check if the user is already logged in
if (currentUser.authorized === true) {
console.log("User is already logged in, redirecting...");
navigate(redirect || "/manage/");
navigate(redirect || (isPartsEntry ? "/parts/" : "/manage/"));
window.parent.postMessage({ type: "seamlessLoginResponse", status: "already_logged_in" }, requestOrigin || "*");
return;
}
@@ -72,12 +75,12 @@ export function SignInComponent({ emailSignInStart, currentUser, signInError, se
window.parent.postMessage({ type: "seamlessLoginResponse", status: "login_attempted" }, requestOrigin || "*");
};
window.addEventListener("message", handleSeamlessLogin); // Listen for "message"
window.addEventListener("message", handleSeamlessLogin);
return () => {
window.removeEventListener("message", handleSeamlessLogin);
};
}, [emailSignInStart, currentUser, navigate, redirect]);
}, [emailSignInStart, currentUser, navigate, redirect, isPartsEntry]);
return (
<div className="login-container">

View File

@@ -77,3 +77,8 @@ export const setWssStatus = (status) => ({
type: ApplicationActionTypes.SET_WSS_STATUS,
payload: status
});
export const setIsPartsEntry = (isParts) => ({
type: ApplicationActionTypes.PARTS_ENTRY,
payload: isParts
});

View File

@@ -104,6 +104,11 @@ const applicationReducer = (state = INITIAL_STATE, action) => {
alerts: newAlertsMap
};
}
case ApplicationActionTypes.PARTS_ENTRY:
return {
...state,
isPartsEntry: action.payload
};
default:
return state;
}

View File

@@ -24,3 +24,4 @@ export const selectProblemJobs = createSelector([selectApplication], (applicatio
export const selectUpdateAvailable = createSelector([selectApplication], (application) => application.updateAvailable);
export const selectWssStatus = createSelector([selectApplication], (application) => application.wssStatus);
export const selectAlerts = createSelector([selectApplication], (application) => application.alerts);
export const selectIsPartsEntry = createSelector([selectApplication], (application) => application.isPartsEntry);

View File

@@ -14,6 +14,7 @@ const ApplicationActionTypes = {
SET_PROBLEM_JOBS: "SET_PROBLEM_JOBS",
SET_UPDATE_AVAILABLE: "SET_UPDATE_AVAILABLE",
SET_WSS_STATUS: "SET_WSS_STATUS",
ADD_ALERTS: "ADD_ALERTS"
ADD_ALERTS: "ADD_ALERTS",
PARTS_ENTRY: "PARTS_ENTRY"
};
export default ApplicationActionTypes;