2026-06-09 14:06:01 -07:00
|
|
|
import Widget from "./Widget.jsx";
|
2026-06-05 11:13:10 -07:00
|
|
|
import { Fieldset, NativeSelect, For, Box, Field, Input, Button, Text, Flex } from "@chakra-ui/react";
|
2025-08-05 17:12:59 -07:00
|
|
|
import { useForm } from "react-hook-form";
|
2025-08-06 16:27:08 -07:00
|
|
|
import { useState } from "react";
|
2026-06-04 15:30:01 -07:00
|
|
|
import { Asterisk } from 'lucide-react';
|
2025-08-04 12:04:33 -07:00
|
|
|
|
|
|
|
|
export default function AlertLevel({id, isEditable, isDelete, DeleteWidget}) {
|
2025-08-11 12:59:38 -07:00
|
|
|
const { register, handleSubmit, reset, formState: {errors} } = useForm();
|
2026-06-05 11:13:10 -07:00
|
|
|
const [isSubmit, setIsSubmit] = useState(false);
|
|
|
|
|
|
2025-08-06 16:27:08 -07:00
|
|
|
const onSubmit = (data) => {
|
|
|
|
|
setIsSubmit(true);
|
2025-08-11 12:59:38 -07:00
|
|
|
reset();
|
2025-08-06 16:27:08 -07:00
|
|
|
}
|
2025-08-05 17:12:59 -07:00
|
|
|
|
2025-08-06 16:27:08 -07:00
|
|
|
// Prop Forwarding
|
|
|
|
|
const widgetProps = { id, isEditable, isDelete, DeleteWidget, isSubmit, setIsSubmit }
|
2026-06-05 11:13:10 -07:00
|
|
|
|
2025-08-04 12:04:33 -07:00
|
|
|
return (
|
2026-06-05 11:13:10 -07:00
|
|
|
<Widget title="Alert Level" {...widgetProps} >
|
2025-08-06 16:27:08 -07:00
|
|
|
{!isSubmit ? (
|
2025-08-11 12:59:38 -07:00
|
|
|
// DISPLAYING INPUT FIElDS AND LABELS
|
2025-08-06 16:27:08 -07:00
|
|
|
<Box
|
|
|
|
|
as="form"
|
|
|
|
|
onSubmit={handleSubmit(onSubmit)}
|
|
|
|
|
width="100%"
|
2026-06-05 11:13:10 -07:00
|
|
|
p={3}
|
2025-08-06 16:27:08 -07:00
|
|
|
display="flex"
|
|
|
|
|
flexDir="column"
|
|
|
|
|
>
|
2026-06-05 11:13:10 -07:00
|
|
|
<Fieldset.Root size="md" maxW="md">
|
|
|
|
|
<Fieldset.Content>
|
|
|
|
|
<Field.Root>
|
|
|
|
|
<Field.Label fontWeight="semibold">Volcano</Field.Label>
|
|
|
|
|
<Input name="volcanoname" />
|
|
|
|
|
</Field.Root>
|
|
|
|
|
|
|
|
|
|
<Field.Root>
|
|
|
|
|
<Field.Label fontWeight="semibold">Country</Field.Label>
|
|
|
|
|
<NativeSelect.Root>
|
|
|
|
|
<NativeSelect.Field name="country">
|
|
|
|
|
<For each={["United Kingdom", "Canada", "United States"]}>
|
|
|
|
|
{(item) => (
|
|
|
|
|
<option key={item} value={item}>
|
|
|
|
|
{item}
|
|
|
|
|
</option>
|
|
|
|
|
)}
|
|
|
|
|
</For>
|
|
|
|
|
</NativeSelect.Field>
|
|
|
|
|
<NativeSelect.Indicator />
|
|
|
|
|
</NativeSelect.Root>
|
|
|
|
|
</Field.Root>
|
|
|
|
|
</Fieldset.Content>
|
|
|
|
|
|
|
|
|
|
<Button type="submit" size="sm">Submit</Button>
|
|
|
|
|
</Fieldset.Root>
|
2025-08-06 16:27:08 -07:00
|
|
|
</Box>
|
|
|
|
|
):(
|
2025-08-11 12:59:38 -07:00
|
|
|
// DISPLAYING ALERT LEVEL DATA
|
2025-08-06 16:27:08 -07:00
|
|
|
<Box p={1} mt={1} ml="auto" mr="auto" width="200px">
|
|
|
|
|
<Box
|
|
|
|
|
bg="bg"
|
|
|
|
|
shadow="md"
|
|
|
|
|
borderRadius="md"
|
|
|
|
|
p={8}
|
|
|
|
|
width="200px"
|
|
|
|
|
height="10px"
|
|
|
|
|
textAlign="center"
|
|
|
|
|
display="flex"
|
|
|
|
|
alignItems="center"
|
|
|
|
|
justifyContent="center"
|
|
|
|
|
>
|
|
|
|
|
<Text fontsize="2xl" fontWeight="bold" color="gray.700">Alert Level Data Coming Soon.</Text>
|
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
)}
|
2025-08-04 12:04:33 -07:00
|
|
|
</Widget>
|
|
|
|
|
);
|
|
|
|
|
}
|