import { Box, HStack, Image, Input, Span, Text } from "@chakra-ui/react";
import MainFrame from "../../../components/MainFrame";
import AlertDailog from "../../../components/AlertDailog";
import { RiDeleteBin5Line } from "react-icons/ri";
import DataTable from "../../../components/DataTable";
import { Switch } from "../../../components/ui/switch";
import { InputGroup } from "../../../components/ui/input-group";
import { LuSearch } from "react-icons/lu";
import ViewRegisterUsers from "./ViewRegisterUsers";
import EditRegisterUsers from "./EditRegisterUsers";
import AddRegisterUsers from "./AddRegisterUsers";
import Delete from "../../../components/ActionIcons/Delete";

const tableHeadRow = [
  "Sr. No",
  "First Name",
  "Mobile Number",
  "Gender",
  "DOB",
  "Type Of User",
  "Language",
  "Activate/Deactivate",
  "Action",
];

const registerUser: any[] = [
  ...Array.from({ length: 12 }, (_, i) => ({
    "Sr. No": i + 1,
    "First Name": "Ritesh",
    "Mobile Number": "akanksha@gmail.com",
    "Gender": "9876543210",
    "DOB": "Female",
    "Type Of User": "15-01-1990",
    "Language": "Mumbai",
    "Activate/Deactivate": (
      <Box>
        <Switch size={'sm'} colorPalette={'teal'} />
      </Box>
    ),
    "Action": (
      <HStack justifyContent="center">
        <ViewRegisterUsers />
        <EditRegisterUsers />
        {/* <RiDeleteBin5Line style={{ cursor: "pointer" }} /> */}
        <AlertDailog
          AltertTiggerIcon={() =><Delete /> } // Pass as function
          alertText="Delete Users"
          alertIcon={<Image src={"DeleteIcon"} h={"39px"} />}
          alertCaption="Are You Sure You Want To Delete This User ?"
          onConfirm={() => {
            console.log("User deleted:", i + 1);
          }}
        />
      </HStack>
    ),
  })),
];

const RegisterUsers = () => {
  return (
    <MainFrame>
      <Box>
        <HStack
          w={"100%"}
          justifyContent={"space-between"}
          mb={4}
          py={0}
          px={3}
        >
          <Text as={"span"} fontSize={"sm"} fontWeight={500} color={"#000"}>
            Register Users
          </Text>

          <HStack> 
            <InputGroup
              startElement={
                <LuSearch fontSize={"xs"} style={{ position: 'relative', left: '10px' }} />
              }
              color={"#000"}
            >
              <Input
                p={3}
                w={300}
                bg={"#fff"}
                colorPalette={"blue"}
                _focus={{ border: "1px solid #02A0A0" }}
                rounded={"md"}
                size={"xs"}
                fontSize={"sm"}
                placeholder="Search..."
                bgColor={'#EEEEEE'}
                ps={8}
              />
            </InputGroup>
            <AddRegisterUsers />
          </HStack>
        </HStack>
        <DataTable
          sortableColumns={["Name", "Registration Date "]}
          tableHeadRow={tableHeadRow}
          data={registerUser}
        />
      </Box>
    </MainFrame>
  );
};

export default RegisterUsers;
