updated the component and device api's to have as be a parameter for the function

This commit is contained in:
csawatzky 2025-04-22 14:33:19 -06:00
parent c617ebf868
commit b62c7dbe5c
39 changed files with 346 additions and 651 deletions

View file

@ -2,6 +2,7 @@ import { Dialog, DialogActions, DialogContent, DialogTitle, Grid2, TextField } f
import CancelSubmit from "common/CancelSubmit";
import { useComponentAPI, useSnackbar } from "hooks";
import { pond } from "protobuf-ts/pond";
import { useGlobalState } from "providers";
import { useState } from "react";
import { or } from "utils";
@ -13,12 +14,13 @@ interface Props {
export default function AddComponentManualDialog (props: Props) {
const { open, onClose, device } = props;
const [{as}] = useGlobalState();
const componentAPI = useComponentAPI();
const snackbar = useSnackbar();
const [component, setComponent] = useState<pond.ComponentSettings>(pond.ComponentSettings.create())
const onSubmit = () => {
componentAPI.add(device, component).then(() => {
componentAPI.add(device, component, as).then(() => {
snackbar.success("Component added")
})
}