import React, { FC, useState } from "react";
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { MockPage } from "components/Page";
import { useHAEntities } from "services/haService/HAEntities";
const Test: FC<{ onRender: () => void }> = ({ onRender }) => {
const [searchTerm, setSearch] = useState("");
const conn = useHAEntities();
onRender && onRender();
return (
<>
setSearch(e.target.value.toLowerCase())}
/>
{Object.entries(conn.collection ?? {})
.filter(([key, _]) => key.toLowerCase().includes(searchTerm))
.map(([key, value]) => {
return (
-
{key}
Context: {JSON.stringify(value.context)}
Attributes: {JSON.stringify(value.attributes)}
State: {JSON.stringify(value.state)}
Updated at: {JSON.stringify(value.last_updated)}
Changed at: {JSON.stringify(value.last_changed)}
);
})}
>
);
};
export default {
title: "Services/HA Entities",
component: Test,
parameters: { actions: { argTypesRegex: "^on.*" } },
args: {},
} as ComponentMeta;
export const Base: ComponentStory = (props) => {
return (
);
};