Files
SSA-Admin-Panel/src/Pages/ManageUsers/RegisterUsers/AddRegisterUsers.tsx

193 lines
5.9 KiB
TypeScript
Raw Normal View History

2025-09-11 20:16:37 +05:30
import { Box, Field, Input, Stack } from "@chakra-ui/react";
2025-02-06 15:07:42 +05:30
import {
DialogActionTrigger,
DialogBody,
DialogCloseTrigger,
DialogContent,
DialogFooter,
DialogHeader,
DialogRoot,
DialogTitle,
DialogTrigger,
} from "../../../components/ui/dialog";
import { Button } from "../../../components/ui/button";
import { IoMdAdd } from "react-icons/io";
2025-09-11 20:16:37 +05:30
import { useState } from "react";
2025-09-09 17:30:26 +05:30
// import { useCreateUserMutation } from "../../../Redux/Service/manage.user";
// import { useState } from "react";
2025-02-06 15:07:42 +05:30
function AddRegisterUsers() {
2025-09-09 17:30:26 +05:30
// const [createUser] = useCreateUserMutation();
2025-09-11 20:16:37 +05:30
const [userType, setUserType] = useState<number | "">("");
2025-09-09 17:30:26 +05:30
2025-09-11 20:16:37 +05:30
const [user, setUser] = useState<{
principal_type_xid: number;
principal_source_xid: number | "";
first_name: string;
last_name: string;
gender: string;
date_of_birth: string;
language_name: string[];
}>({
principal_type_xid: 1,
principal_source_xid: userType,
first_name: '',
last_name: '',
gender: '',
date_of_birth: '',
language_name: [],
});
2025-09-09 17:30:26 +05:30
2025-02-06 15:07:42 +05:30
return (
<DialogRoot placement="center">
<DialogTrigger asChild>
2025-02-07 16:38:38 +05:30
<Button px={4} size={"xs"} bg={"#02A0A0"}>
2025-02-06 15:07:42 +05:30
<IoMdAdd /> Add
</Button>
</DialogTrigger>
<DialogContent
2025-09-11 20:16:37 +05:30
bg={"#fff"}
w={{ base: '90%', md: '400px' }}
height={'80vh'}
overflow={'scroll'}
overflowX="hidden"
p={3} // Reduced padding
bgSize={'md'}
2025-02-06 15:07:42 +05:30
>
2025-02-07 16:38:38 +05:30
<DialogHeader bg="white" >
<DialogTitle alignSelf="center" color="black" fontSize="14px">
2025-02-06 15:07:42 +05:30
Add User Accounts
</DialogTitle>
</DialogHeader>
<DialogBody bg="white">
2025-02-07 16:38:38 +05:30
<Stack py={3}>
2025-02-06 15:07:42 +05:30
<Field.Root>
2025-02-07 16:38:38 +05:30
<Field.Label color="black" pt={1} fontSize="12px">
2025-02-06 15:07:42 +05:30
First Name
</Field.Label>
<Input
2025-09-11 20:16:37 +05:30
bgColor="#EEEEEE"
color="black"
border="none"
pl={1}
fontSize="12px"
height="30px"
value={user.first_name}
onChange={(e) => setUser({ ...user, first_name: e.target.value })}
2025-02-06 15:07:42 +05:30
/>
2025-02-07 16:38:38 +05:30
<Field.Label color="black" pt={1} fontSize="12px">
2025-02-06 15:07:42 +05:30
Last Name
</Field.Label>
<Input
2025-09-11 20:16:37 +05:30
bgColor="#EEEEEE"
color="black"
border="none"
pl={1}
fontSize="12px"
height="30px"
value={user.last_name}
onChange={(e) => setUser({ ...user, last_name: e.target.value })}
2025-02-06 15:07:42 +05:30
/>
2025-02-07 16:38:38 +05:30
<Field.Label color="black" pt={1} fontSize="12px">
2025-02-06 15:07:42 +05:30
Gender
</Field.Label>
<Input
2025-09-11 20:16:37 +05:30
bgColor="#EEEEEE"
color="black"
border="none"
pl={1}
fontSize="12px"
height="30px"
value={user.gender}
onChange={(e) => setUser({ ...user, gender: e.target.value })}
2025-02-06 15:07:42 +05:30
/>
2025-02-07 16:38:38 +05:30
<Field.Label color="black" pt={1} fontSize="12px">
2025-02-06 15:07:42 +05:30
DOB
</Field.Label>
<Input
2025-09-11 20:16:37 +05:30
bgColor="#EEEEEE"
color="black"
border="none"
pl={1}
fontSize="12px"
height="30px"
type="date"
value={user.date_of_birth}
onChange={(e) => setUser({ ...user, date_of_birth: e.target.value })}
2025-02-06 15:07:42 +05:30
/>
2025-09-11 20:16:37 +05:30
<Field.Root>
<Field.Label color="black" pt={1} fontSize="12px">Select User Type</Field.Label>
<Box bgColor="#EEEEEE" borderRadius="md" p={1}>
<select
style={{
width: "100%",
background: "transparent",
color: "black",
border: "none",
fontSize: "12px",
height: "30px",
outline: "none",
}}
value={userType}
onChange={(e) => setUserType(Number(e.target.value))}
>
<option value="">Select User Type</option>
<option value="2">Recruiter</option>
<option value="3">Jobseeker</option>
</select>
</Box>
</Field.Root>
{/* <Field.Label color="black" pt={1} fontSize="12px">
2025-02-06 15:07:42 +05:30
OTP Verified
</Field.Label>
<Input
2025-02-07 16:38:38 +05:30
bgColor="#EEEEEE" color="black" border="none" pl={1} fontSize="12px" height="30px"
2025-09-11 20:16:37 +05:30
/> */}
2025-02-06 15:07:42 +05:30
2025-02-07 16:38:38 +05:30
<Field.Label color="black" pt={1} fontSize="12px">
2025-02-06 15:07:42 +05:30
Language
</Field.Label>
<Input
2025-09-11 20:16:37 +05:30
bgColor="#EEEEEE"
color="black"
border="none"
pl={1}
fontSize="12px"
height="30px"
value={user.language_name.join(", ")} // display as comma-separated string
onChange={(e) =>
setUser({
...user,
language_name: e.target.value
.split(",")
.map(lang => lang.trim())
.filter(Boolean), // remove empty strings
})
}
2025-02-06 15:07:42 +05:30
/>
</Field.Root>
</Stack>
</DialogBody>
2025-02-07 16:38:38 +05:30
<DialogFooter mt={2}>
2025-02-06 15:07:42 +05:30
<DialogActionTrigger asChild>
2025-02-07 16:38:38 +05:30
<Button w="100%" bg="#02A0A0" color={"#fff"}>
2025-02-06 15:07:42 +05:30
Save
</Button>
</DialogActionTrigger>
</DialogFooter>
<DialogCloseTrigger color="black" />
</DialogContent>
</DialogRoot>
);
}
export default AddRegisterUsers;