diff --git a/src/components/PopupSettings/NPEDCategoryPopup.tsx b/src/components/PopupSettings/NPEDCategoryPopup.tsx new file mode 100644 index 0000000..0fa7129 --- /dev/null +++ b/src/components/PopupSettings/NPEDCategoryPopup.tsx @@ -0,0 +1,67 @@ +import Card from "../UI/Card"; +import CardHeader from "../UI/CardHeader"; +import NPEDCatToggle from "../SettingForms/NPED/NPEDCatToggle"; +import FormGroup from "../SettingForms/components/FormGroup"; +import { Form, Formik } from "formik"; +import { useIntegrationsContext } from "../../context/IntegrationsContext"; +import { useCameraBlackboard } from "../../hooks/useCameraBlackboard"; +import type { CategoryPopups } from "../../types/types"; +import { toast } from "sonner"; + +const NPEDCategoryPopup = () => { + const { state, dispatch } = useIntegrationsContext(); + const { mutation } = useCameraBlackboard(); + + const isCatAEnabled = state?.iscatEnabled?.catA; + const isCatBEnabled = state?.iscatEnabled?.catB; + const isCatCEnabled = state?.iscatEnabled?.catC; + const isCatDEnabled = state?.iscatEnabled?.catD; + + const initialValues = { + catA: isCatAEnabled ?? true, + catB: isCatBEnabled ?? true, + catC: isCatCEnabled ?? true, + catD: isCatDEnabled ?? false, + }; + + const handleSubmit = async (values: CategoryPopups) => { + const result = await mutation.mutateAsync({ + operation: "INSERT", + value: values, + path: "CategoryPopup", + }); + if (result?.reason === "OK") toast.success("Pop up settings saved"); + dispatch({ type: "NPEDCATENABLED", payload: values }); + }; + + return ( + + +

Allows alerts to pop up to user.

+ +
+ + + + + + + + + + + + + +
+
+
+ ); +}; + +export default NPEDCategoryPopup; diff --git a/src/components/SettingForms/Channel1-JSON/ChannelFields.tsx b/src/components/SettingForms/Channel1-JSON/ChannelFields.tsx index 36b505f..e837821 100644 --- a/src/components/SettingForms/Channel1-JSON/ChannelFields.tsx +++ b/src/components/SettingForms/Channel1-JSON/ChannelFields.tsx @@ -234,7 +234,7 @@ const ChannelFields = ({ touched, isSubmitting, format }: ChannelFieldsProps) => diff --git a/src/components/SettingForms/NPED/NPEDCard.tsx b/src/components/SettingForms/NPED/NPEDCard.tsx index a8b2474..34a00a1 100644 --- a/src/components/SettingForms/NPED/NPEDCard.tsx +++ b/src/components/SettingForms/NPED/NPEDCard.tsx @@ -6,7 +6,7 @@ import NPEDIcon from "/NPED.svg"; const NPEDCard = () => { return ( - + ); diff --git a/src/components/SettingForms/NPED/NPEDCatToggle.tsx b/src/components/SettingForms/NPED/NPEDCatToggle.tsx new file mode 100644 index 0000000..d8a627b --- /dev/null +++ b/src/components/SettingForms/NPED/NPEDCatToggle.tsx @@ -0,0 +1,22 @@ +import { Field } from "formik"; + +type NPEDToggleProps = { + name: string; + label: string; +}; + +const NPEDCatToggle = ({ name, label }: NPEDToggleProps) => { + return ( +