From 58956a5d20a3487a787224f0116c95d1825e2dfd Mon Sep 17 00:00:00 2001 From: Stephane Richin Date: Fri, 12 Jan 2024 17:19:29 +0100 Subject: [PATCH] feat(devices): add type for display device type icon --- src/components/ButtonAddOrEditDevice.tsx | 27 ++++++++++++++++-- src/components/ButtonDevicesAvailable.tsx | 5 ++-- src/components/DeviceList.tsx | 34 ++++++++++++++++++++--- src/translations/en.json | 1 + src/translations/fr.json | 1 + src/types/interfaces/Settings.ts | 3 ++ 6 files changed, 62 insertions(+), 9 deletions(-) diff --git a/src/components/ButtonAddOrEditDevice.tsx b/src/components/ButtonAddOrEditDevice.tsx index e89d3aa..6d0fdf3 100644 --- a/src/components/ButtonAddOrEditDevice.tsx +++ b/src/components/ButtonAddOrEditDevice.tsx @@ -1,4 +1,11 @@ -import { ActionIcon, Button, Flex, Space, TextInput } from "@mantine/core"; +import { + ActionIcon, + Button, + Flex, + Select, + Space, + TextInput, +} from "@mantine/core"; import { useForm } from "@mantine/form"; import { notifications } from "@mantine/notifications"; import { IconEdit, IconPlus } from "@tabler/icons-react"; @@ -7,7 +14,11 @@ import { useTranslation } from "react-i18next"; import { db } from "../database"; import { useSetSettings, useSettings } from "../providers/Settings"; -import type { RemoteDevice, Settings } from "../types/interfaces/Settings"; +import type { + RemoteDevice, + RemoteDeviceType, + Settings, +} from "../types/interfaces/Settings"; import { Form } from "./Form"; import { Modal } from "./Modal"; @@ -15,19 +26,24 @@ interface ButtonAddOrEditDeviceProps { initialValues?: { id: string; name: string; + type: RemoteDeviceType; }; } interface FormData { id: string; name: string; + type: RemoteDeviceType; } const INITIAL_VALUES = { id: "", name: "", + type: "desktop", } as FormData; +const REMOTE_DEVICES_ICONS_LABEL = ["desktop", "tablet", "mobile"]; + export const ButtonAddOrEditDevice: FC = memo( ({ initialValues }) => { const [opened, setOpened] = useState(false); @@ -79,7 +95,6 @@ export const ButtonAddOrEditDevice: FC = memo( color: "green", }); - form.reset(); setOpened(false); }; @@ -133,6 +148,12 @@ export const ButtonAddOrEditDevice: FC = memo( label={t("modal.device.add.input.name.label")} {...form.getInputProps("name")} /> + +