feat: globally set robot state
This commit is contained in:
@@ -7,6 +7,7 @@ import { modalStyle } from "../recorder/AddWhereCondModal";
|
|||||||
import { useGlobalInfoStore } from '../../context/globalInfo';
|
import { useGlobalInfoStore } from '../../context/globalInfo';
|
||||||
import { getStoredRecording, updateRecording } from '../../api/storage';
|
import { getStoredRecording, updateRecording } from '../../api/storage';
|
||||||
import { WhereWhatPair } from 'maxun-core';
|
import { WhereWhatPair } from 'maxun-core';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
interface RobotMeta {
|
interface RobotMeta {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -75,9 +76,8 @@ interface GroupedCredentials {
|
|||||||
|
|
||||||
export const RobotEditModal = ({ isOpen, handleStart, handleClose, initialSettings }: RobotSettingsProps) => {
|
export const RobotEditModal = ({ isOpen, handleStart, handleClose, initialSettings }: RobotSettingsProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [robot, setRobot] = useState<RobotSettings | null>(null);
|
|
||||||
const [credentials, setCredentials] = useState<Credentials>({});
|
const [credentials, setCredentials] = useState<Credentials>({});
|
||||||
const { recordingId, notify } = useGlobalInfoStore();
|
const { recordingId, notify, robot, setRobot } = useGlobalInfoStore();
|
||||||
const [credentialGroups, setCredentialGroups] = useState<GroupedCredentials>({
|
const [credentialGroups, setCredentialGroups] = useState<GroupedCredentials>({
|
||||||
passwords: [],
|
passwords: [],
|
||||||
emails: [],
|
emails: [],
|
||||||
@@ -85,6 +85,7 @@ export const RobotEditModal = ({ isOpen, handleStart, handleClose, initialSettin
|
|||||||
others: []
|
others: []
|
||||||
});
|
});
|
||||||
const [showPasswords, setShowPasswords] = useState<CredentialVisibility>({});
|
const [showPasswords, setShowPasswords] = useState<CredentialVisibility>({});
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const isEmailPattern = (value: string): boolean => {
|
const isEmailPattern = (value: string): boolean => {
|
||||||
return value.includes('@');
|
return value.includes('@');
|
||||||
@@ -370,9 +371,7 @@ export const RobotEditModal = ({ isOpen, handleStart, handleClose, initialSettin
|
|||||||
handleStart(robot);
|
handleStart(robot);
|
||||||
handleClose();
|
handleClose();
|
||||||
|
|
||||||
setTimeout(() => {
|
navigate('/robots');
|
||||||
window.location.reload();
|
|
||||||
}, 1000);
|
|
||||||
} else {
|
} else {
|
||||||
notify('error', t('robot_edit.notifications.update_failed'));
|
notify('error', t('robot_edit.notifications.update_failed'));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user