Fix customer dashboard

This commit is contained in:
Anthony Janin 2025-08-11 17:28:22 +02:00
parent 337db2f078
commit 941fff9ac7

View File

@ -22,6 +22,7 @@ import UserStore from "@Front/Stores/UserStore";
import AuthModal from "src/sdk/AuthModal";
import CustomerService from "src/common/Api/LeCoffreApi/sdk/CustomerService";
import MessageBus from "src/sdk/MessageBus";
import { resolve } from "path";
export enum LoginStep {
EMAIL,
@ -274,33 +275,38 @@ export default function Login() {
MessageBus.getInstance().initMessageListener();
MessageBus.getInstance().isReady().then(async () => {
try {
// Find the customer
const customer: any = (await CustomerService.getCustomers())
.map((process: any) => process.processData)
.find((customer: any) => customer.contact.email === email);
// Get the pairing ID
const pairingId = await MessageBus.getInstance().getPairingId();
console.log('[Login] Got pairing ID:', pairingId);
// Get all processes
const processes = await MessageBus.getInstance().getProcesses();
console.log('[Login] Got processes:', Object.keys(processes));
const targetProcess = processes[pairingId];
if (targetProcess) {
console.log('[Login] Found target process:', targetProcess);
// Connect the user with the process data
UserStore.instance.connect(targetProcess);
UserStore.instance.connect(customer /*targetProcess*/);
router.push(Module.getInstance().get().modules.pages.Folder.pages.Select.props.path);
} else {
console.error('[Login] No process found for pairing ID:', pairingId);
// Handle the case where no process is found
}
MessageBus.getInstance().destroyMessageListener();
} catch (error) {
console.error('[Login] Error getting process:', error);
MessageBus.getInstance().destroyMessageListener();
}
});
setIsAuthModalOpen(false);
}}
/>}