Fix customer dashboard
This commit is contained in:
parent
337db2f078
commit
941fff9ac7
@ -22,6 +22,7 @@ import UserStore from "@Front/Stores/UserStore";
|
|||||||
import AuthModal from "src/sdk/AuthModal";
|
import AuthModal from "src/sdk/AuthModal";
|
||||||
import CustomerService from "src/common/Api/LeCoffreApi/sdk/CustomerService";
|
import CustomerService from "src/common/Api/LeCoffreApi/sdk/CustomerService";
|
||||||
import MessageBus from "src/sdk/MessageBus";
|
import MessageBus from "src/sdk/MessageBus";
|
||||||
|
import { resolve } from "path";
|
||||||
|
|
||||||
export enum LoginStep {
|
export enum LoginStep {
|
||||||
EMAIL,
|
EMAIL,
|
||||||
@ -274,33 +275,38 @@ export default function Login() {
|
|||||||
MessageBus.getInstance().initMessageListener();
|
MessageBus.getInstance().initMessageListener();
|
||||||
MessageBus.getInstance().isReady().then(async () => {
|
MessageBus.getInstance().isReady().then(async () => {
|
||||||
try {
|
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
|
// Get the pairing ID
|
||||||
const pairingId = await MessageBus.getInstance().getPairingId();
|
const pairingId = await MessageBus.getInstance().getPairingId();
|
||||||
console.log('[Login] Got pairing ID:', pairingId);
|
console.log('[Login] Got pairing ID:', pairingId);
|
||||||
|
|
||||||
// Get all processes
|
// Get all processes
|
||||||
const processes = await MessageBus.getInstance().getProcesses();
|
const processes = await MessageBus.getInstance().getProcesses();
|
||||||
console.log('[Login] Got processes:', Object.keys(processes));
|
console.log('[Login] Got processes:', Object.keys(processes));
|
||||||
|
|
||||||
const targetProcess = processes[pairingId];
|
const targetProcess = processes[pairingId];
|
||||||
|
|
||||||
if (targetProcess) {
|
if (targetProcess) {
|
||||||
console.log('[Login] Found target process:', targetProcess);
|
console.log('[Login] Found target process:', targetProcess);
|
||||||
// Connect the user with the process data
|
// 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);
|
router.push(Module.getInstance().get().modules.pages.Folder.pages.Select.props.path);
|
||||||
} else {
|
} else {
|
||||||
console.error('[Login] No process found for pairing ID:', pairingId);
|
console.error('[Login] No process found for pairing ID:', pairingId);
|
||||||
// Handle the case where no process is found
|
// Handle the case where no process is found
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageBus.getInstance().destroyMessageListener();
|
MessageBus.getInstance().destroyMessageListener();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('[Login] Error getting process:', error);
|
console.error('[Login] Error getting process:', error);
|
||||||
MessageBus.getInstance().destroyMessageListener();
|
MessageBus.getInstance().destroyMessageListener();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
setIsAuthModalOpen(false);
|
setIsAuthModalOpen(false);
|
||||||
}}
|
}}
|
||||||
/>}
|
/>}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user