From 560f7e8b817a4ba13075da64c7e552a133e6ab6f Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 28 Oct 2024 21:09:42 +0530 Subject: [PATCH] feat: show user email for created by user --- src/components/molecules/RobotSettings.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/molecules/RobotSettings.tsx b/src/components/molecules/RobotSettings.tsx index aadc4047..98638120 100644 --- a/src/components/molecules/RobotSettings.tsx +++ b/src/components/molecules/RobotSettings.tsx @@ -5,6 +5,7 @@ import { modalStyle } from "./AddWhereCondModal"; import { useGlobalInfoStore } from '../../context/globalInfo'; import { getStoredRecording } from '../../api/storage'; import { WhereWhatPair } from 'maxun-core'; +import { getUserById } from "../../api/auth"; interface RobotMeta { name: string; @@ -54,6 +55,7 @@ interface RobotSettingsProps { export const RobotSettingsModal = ({ isOpen, handleStart, handleClose, initialSettings }: RobotSettingsProps) => { const [robot, setRobot] = useState(null); + const [userEmail, setUserEmail] = useState(null); const { recordingId, notify } = useGlobalInfoStore(); useEffect(() => { @@ -76,6 +78,18 @@ export const RobotSettingsModal = ({ isOpen, handleStart, handleClose, initialSe // Find the `goto` action in `what` and retrieve its arguments const targetUrl = lastPair?.what.find(action => action.action === "goto")?.args?.[0]; + useEffect(() => { + const fetchUserEmail = async () => { + if (robot && robot.userId) { + const userData = await getUserById(robot.userId.toString()); + if (userData && userData.user) { + setUserEmail(userData.user.email); + } + } + }; + fetchUserEmail(); + }, [robot?.userId]); + return (