import { useEffect, useState } from "react";
import { Button, Icon, Steps, Typography } from "tiny-ui";
import { useLocalStorage } from "lib/state";
const { Step } = Steps;
const { Paragraph } = Typography;
const Automation = ({
clients,
names,
presets,
automation,
onAutomation,
onPower,
busy,
...props
}) => {
const [current, setCurrent] = useLocalStorage("preset", -1, 3600);
const [total, setTotal] = useState();
const [help, setHelp] = useState(false);
const getTitle = (indx) => presets?.[indx]?.name || indx;
const getName = (v) => {
let indx = clients?.findIndex((o) => o === v);
return indx > -1 ? names?.[indx] : v;
};
const getDescription = (indx) => {
return (
(automation?.[indx] &&
Object.keys(automation?.[indx])
?.map((o) => getName(o))
?.join(", ")) ||
null
);
};
useEffect(() => {
setTotal((automation && Object.keys(automation)?.length) || 0);
}, [automation]);
useEffect(() => {
if (current > -1 && current < total) {
onAutomation(current + 1);
}
}, [current, total]);
let steps = Object.keys(automation).map((o, i) => {
return (