diff --git a/client/src/assets/themes/_basic.scss b/client/src/assets/themes/_basic.scss
index 7c6ea35..f6bf1fd 100644
--- a/client/src/assets/themes/_basic.scss
+++ b/client/src/assets/themes/_basic.scss
@@ -1,6 +1,6 @@
:root {
--main-font: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
- --border-radius: 0.25rem;
+ --border-radius: 0.15rem;
--main-bg-color: #eee;
--main-fg-color: #000;
--button-bg-color: #3988ff;
diff --git a/client/src/pages/dashboard/components/BoxSettings/BoxSettings.tsx b/client/src/pages/dashboard/components/BoxSettings/BoxSettings.tsx
index d2b5b3e..3af8b35 100644
--- a/client/src/pages/dashboard/components/BoxSettings/BoxSettings.tsx
+++ b/client/src/pages/dashboard/components/BoxSettings/BoxSettings.tsx
@@ -24,13 +24,9 @@ export const BoxSettings = ({ value, onSave, onClose, onRemove }: Props) => {
const [data, setData] = useState(() => value.data)
- const {
- value: formState,
- handleChange,
- handleSubmit,
- } = useForm({
+ const { register, watch, handleSubmit } = useForm({
defaultValue: () => ({
- title: value.title,
+ title: value.title ?? '',
type: value.data?.type ?? '',
}),
onSubmit: async (v) => {
@@ -44,6 +40,8 @@ export const BoxSettings = ({ value, onSave, onClose, onRemove }: Props) => {
},
})
+ const type = watch('type')
+
const deleteConfirm = useConfirmModal({
content: 'Are you sure you want to delete the box?',
onConfirm: () => {
@@ -58,26 +56,17 @@ export const BoxSettings = ({ value, onSave, onClose, onRemove }: Props) => {
<>
-
+
-
- {formState.type === 'graph' && (
+ {type === 'graph' && (
{
/>
)}
- {formState.type === 'dial' && (
+ {type === 'dial' && (
{
- const { value: formState, handleChange } = useForm({
+ const { register } = useForm({
defaultValue: () => ({
...(value && omit(value, ['type'])),
}),
+ onChange: (v) => onChange({ ...v, type: 'dial' }),
})
- useEffect(() => {
- onChange({ ...formState, type: 'dial' })
- }, [formState])
-
return (
<>
-
+
{sensors.map((s) => (
-
+
-
+
-
+
>
)
diff --git a/client/src/pages/dashboard/components/BoxSettings/components/GraphSettings.tsx b/client/src/pages/dashboard/components/BoxSettings/components/GraphSettings.tsx
index c0415e3..9b0fa2d 100644
--- a/client/src/pages/dashboard/components/BoxSettings/components/GraphSettings.tsx
+++ b/client/src/pages/dashboard/components/BoxSettings/components/GraphSettings.tsx
@@ -2,7 +2,6 @@ import { SensorInfo } from '@/api/sensors'
import { DashboardGraphData } from '@/utils/dashboard/parseDashboard'
import { useForm } from '@/utils/hooks/useForm'
import { omit } from '@/utils/omit'
-import { useEffect } from 'preact/hooks'
type Props = {
sensors: SensorInfo[]
@@ -11,26 +10,20 @@ type Props = {
}
export const GraphSettings = ({ value, onChange, sensors }: Props) => {
- const { value: formState, handleChange } = useForm({
+ const { register, watch } = useForm({
defaultValue: () => ({
...(value && omit(value, ['type'])),
}),
+ onChange: (v) => onChange({ ...v, type: 'graph' }),
})
- useEffect(() => {
- onChange({ ...formState, type: 'graph' })
- }, [formState])
+ const colorMode = watch('colorMode')
return (
<>
-
+
{sensors.map((s) => (