prettier write

This commit is contained in:
Iliya Brook 2024-03-06 23:31:03 +02:00
parent 8fe79d2eb9
commit eae2d5b752
3 changed files with 18 additions and 11 deletions

View File

@ -220,13 +220,19 @@ class ActionPreview<S, A extends Action<string>> extends Component<
}, },
color: theme.PIN_COLOR, color: theme.PIN_COLOR,
})} })}
onClick={event => { onClick={(event) => {
event.stopPropagation(); event.stopPropagation();
let objectForCopying; let objectForCopying;
if (this.props.tabName === 'Action') { if (this.props.tabName === 'Action') {
objectForCopying = getValueByPath(this.props.action, reversedPath); objectForCopying = getValueByPath(
this.props.action,
reversedPath,
);
} else if (this.props.tabName === 'State') { } else if (this.props.tabName === 'State') {
objectForCopying = getValueByPath(this.props.nextState, reversedPath); objectForCopying = getValueByPath(
this.props.nextState,
reversedPath,
);
} }
if (objectForCopying !== undefined) { if (objectForCopying !== undefined) {
copyToClipboard(objectForCopying); copyToClipboard(objectForCopying);

View File

@ -2,7 +2,8 @@ export function getValueByPath(obj: any, path: (string | number)[]){
let current: any = obj; let current: any = obj;
for (let i = 0; i < path.length; i++) { for (let i = 0; i < path.length; i++) {
const key = path[i]; const key = path[i];
const adjustedKey = typeof key === 'string' && !isNaN(Number(key)) ? parseInt(key, 10) : key; const adjustedKey =
typeof key === 'string' && !isNaN(Number(key)) ? parseInt(key, 10) : key;
if (current[adjustedKey] === undefined) { if (current[adjustedKey] === undefined) {
return undefined; return undefined;
} }