Files
tanami-admin-panel/src/Components/FormInputView.jsx

54 lines
1.4 KiB
React
Raw Normal View History

2024-07-03 12:13:09 +05:30
import { Box, Button, Divider, FormLabel, Heading } from "@chakra-ui/react";
import React from "react";
2024-07-05 15:33:08 +05:30
const FormInputView = ({
groupedFields,
name,
groupedFieldsTwo,
errors,
onSubmit,
children,
}) => {
2024-07-03 12:13:09 +05:30
console.log(groupedFields);
return (
<form>
2024-07-05 15:33:08 +05:30
{Object?.entries(groupedFields, groupedFieldsTwo).map(
([section, fields], index) => (
<Box key={section}>
2024-07-05 20:02:10 +05:30
{console.log(fields)}
2024-07-05 15:33:08 +05:30
<Heading as="h6" size="xs" mt={index === 0 ? 3 : 4}>
{section}
</Heading>
<Box display={"flex"} gap={0}>
<Box
width={"100%"}
p={5}
display={"flex"}
flexWrap={"wrap"}
gap={4}
>
2024-07-05 20:02:10 +05:30
{fields.map(({ value, label, id, width, btn }, key) => (
2024-07-05 15:33:08 +05:30
<Box w={!width ? "49%" : width}>
<FormLabel key={id} color={"gray.500"} fontSize={"xs"}>
{label}
</FormLabel>
<FormLabel>{value}</FormLabel>
</Box>
))}
</Box>
2024-07-03 12:13:09 +05:30
</Box>
2024-07-05 15:33:08 +05:30
{index <
Object.entries(groupedFields, groupedFieldsTwo).length - 1 && (
<Divider />
)}
2024-07-03 12:13:09 +05:30
</Box>
2024-07-05 15:33:08 +05:30
)
)}
2024-07-03 12:13:09 +05:30
{children}
</form>
);
};
export default FormInputView;