working chenge password
This commit is contained in:
@@ -5,6 +5,8 @@ import {
|
||||
FormErrorMessage,
|
||||
FormLabel,
|
||||
Input,
|
||||
InputGroup,
|
||||
InputRightElement,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalCloseButton,
|
||||
@@ -49,10 +51,9 @@ const ChangePassword = ({
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [alert, setAlert] = useState(false);
|
||||
const toast = useToast();
|
||||
|
||||
const [showPassword, setShowPassword] = useState(false);
|
||||
const [subject, setSubject] = useState("");
|
||||
const togglePasswordVisibility = () => setShowPassword(!showPassword);
|
||||
const [showCurrentPassword, setShowCurrentPassword] = useState(false);
|
||||
const [showNewPassword, setShowNewPassword] = useState(false);
|
||||
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
|
||||
// ======================[ Cotext Api ]
|
||||
const { IODetails } = useContext(GlobalStateContext);
|
||||
const found = data?.find((item) => item?.id === actionId);
|
||||
@@ -72,29 +73,29 @@ const ChangePassword = ({
|
||||
resolver: yupResolver(ioNav),
|
||||
});
|
||||
|
||||
// const onSubmit = async (data) => {
|
||||
// setIsLoading(true);
|
||||
// const onSubmit = async (data) => {
|
||||
// setIsLoading(true);
|
||||
|
||||
// try {
|
||||
// const res = await addNavDetails({ data, id });
|
||||
// if (res?.data?.statusCode === 201) {
|
||||
// setIsLoading(false);
|
||||
// toast({
|
||||
// render: () => <ToastBox message={res?.data?.message} />,
|
||||
// });
|
||||
// handleClose();
|
||||
// } else if (res?.error?.status === 400) {
|
||||
// toast({
|
||||
// render: () => (
|
||||
// <ToastBox message={res?.error?.data?.message} status={"error"} />
|
||||
// ),
|
||||
// });
|
||||
// handleClose();
|
||||
// }
|
||||
// } catch (error) {
|
||||
// console.log(error);
|
||||
// }
|
||||
// };
|
||||
// try {
|
||||
// const res = await addNavDetails({ data, id });
|
||||
// if (res?.data?.statusCode === 201) {
|
||||
// setIsLoading(false);
|
||||
// toast({
|
||||
// render: () => <ToastBox message={res?.data?.message} />,
|
||||
// });
|
||||
// handleClose();
|
||||
// } else if (res?.error?.status === 400) {
|
||||
// toast({
|
||||
// render: () => (
|
||||
// <ToastBox message={res?.error?.data?.message} status={"error"} />
|
||||
// ),
|
||||
// });
|
||||
// handleClose();
|
||||
// }
|
||||
// } catch (error) {
|
||||
// console.log(error);
|
||||
// }
|
||||
// };
|
||||
|
||||
const handleSave = () => {
|
||||
handleSubmit(onSubmit)();
|
||||
@@ -105,7 +106,6 @@ const ChangePassword = ({
|
||||
setAlert(false);
|
||||
onClose();
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -122,40 +122,93 @@ const ChangePassword = ({
|
||||
<ModalBody pb={6}>
|
||||
<Stack spacing={4}>
|
||||
<FormControl isInvalid={errors.ChangePassword} isRequired>
|
||||
<FormLabel fontSize={"sm"} mb={1} fontWeight={500}>Current Password</FormLabel>
|
||||
<Input
|
||||
size={"sm"}
|
||||
<FormLabel fontSize={"sm"} mb={1} fontWeight={500}>
|
||||
Current Password
|
||||
</FormLabel>
|
||||
<InputGroup size="sm">
|
||||
<Input
|
||||
size={"md"}
|
||||
fontSize={"sm"}
|
||||
onChange={(e) => setSubject(e.target.value)}
|
||||
focusBorderColor="forestGreen.300"
|
||||
rounded={4}
|
||||
type={showPassword ? "text" : "password"}
|
||||
/>
|
||||
type={showCurrentPassword ? "text" : "password"} // Toggles between "text" and "password" based on the `show` state
|
||||
/>
|
||||
<InputRightElement width="4.5rem">
|
||||
<Button
|
||||
mt={2}
|
||||
h="1.5rem"
|
||||
size="xs"
|
||||
fontSize={"xs"}
|
||||
color={"green.800"}
|
||||
onClick={() => setShowCurrentPassword((prev) => !prev)}
|
||||
>
|
||||
{showCurrentPassword ? "Hide" : "Show"}
|
||||
</Button>
|
||||
</InputRightElement>
|
||||
</InputGroup>
|
||||
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
||||
{errors.ChangePassword?.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
|
||||
<FormControl isInvalid={errors.newPassword} isRequired>
|
||||
<FormLabel fontSize={"sm"} mb={1}>New Password</FormLabel>
|
||||
<Input
|
||||
size={"sm"}
|
||||
<FormLabel fontSize={"sm"} mb={1}>
|
||||
New Password
|
||||
</FormLabel>
|
||||
<InputGroup size="sm">
|
||||
<Input
|
||||
fontSize={"sm"}
|
||||
size={"md"}
|
||||
onChange={(e) => setSubject(e.target.value)}
|
||||
focusBorderColor="forestGreen.300"
|
||||
rounded={4}
|
||||
type="text"
|
||||
/>
|
||||
type={showNewPassword ? "text" : "password"} // Toggles between "text" and "password" based on the `show` state
|
||||
/>
|
||||
<InputRightElement width="4.5rem">
|
||||
<Button
|
||||
mt={2}
|
||||
h="1.5rem"
|
||||
size="xs"
|
||||
fontSize={"xs"}
|
||||
color={"green.800"}
|
||||
onClick={() => setShowNewPassword((prev) => !prev)}
|
||||
>
|
||||
{showNewPassword ? "Hide" : "Show"}
|
||||
</Button>
|
||||
</InputRightElement>
|
||||
</InputGroup>
|
||||
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
||||
{errors.newPassword?.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
|
||||
<FormControl isInvalid={errors.conformPassword} isRequired>
|
||||
<FormLabel fontSize={"sm"} mb={1}>Re-Type New Password</FormLabel>
|
||||
<Input
|
||||
size={"sm"}
|
||||
<FormLabel fontSize={"sm"} mb={1}>
|
||||
Re-Type New Password
|
||||
</FormLabel>
|
||||
<InputGroup size="sm">
|
||||
<Input
|
||||
fontSize={"sm"}
|
||||
size={"md"}
|
||||
onChange={(e) => setSubject(e.target.value)}
|
||||
focusBorderColor="forestGreen.300"
|
||||
rounded={4}
|
||||
type="text"
|
||||
/>
|
||||
type={showConfirmPassword ? "text" : "password"} // Toggles between "text" and "password" based on the `show` state
|
||||
/>
|
||||
<InputRightElement width="4.5rem">
|
||||
<Button
|
||||
mt={2}
|
||||
h="1.5rem"
|
||||
size="xs"
|
||||
fontSize={"xs"}
|
||||
color={"green.800"}
|
||||
onClick={() => setShowConfirmPassword((prev) => !prev)}
|
||||
>
|
||||
{showConfirmPassword ? "Hide" : "Show"}
|
||||
</Button>
|
||||
</InputRightElement>
|
||||
</InputGroup>
|
||||
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
||||
{errors.conformPassword?.message}
|
||||
</FormErrorMessage>
|
||||
@@ -165,7 +218,7 @@ const ChangePassword = ({
|
||||
|
||||
<DrawerFooter mb={5}>
|
||||
<Button
|
||||
// variant="outline"
|
||||
// variant="outline"
|
||||
bg={"#e0ebeb"}
|
||||
rounded={"sm"}
|
||||
size={"sm"}
|
||||
|
||||
@@ -105,7 +105,7 @@ const IOCashDetails = () => {
|
||||
</Tab>
|
||||
</TabList>
|
||||
{IODetails?.isInvestedAmount
|
||||
? localStorage?.getItem("role") === "Maker" && (
|
||||
? localStorage?.getItem("role") === import.meta.env.VITE_VITE_MAKER && (
|
||||
<Button
|
||||
onClick={handleAdd}
|
||||
leftIcon={<AddIcon />}
|
||||
|
||||
@@ -104,7 +104,7 @@ const Pending = () => {
|
||||
"Comments",
|
||||
"Update By",
|
||||
"Update On",
|
||||
...(localStorage?.getItem('role')!=="Maker" ? ["Actions"] : []),
|
||||
...(localStorage?.getItem('role')!==import.meta.env.VITE_VITE_MAKER ? ["Actions"] : []),
|
||||
|
||||
];
|
||||
|
||||
@@ -166,7 +166,7 @@ const Pending = () => {
|
||||
),
|
||||
Actions: (
|
||||
<Box display={"flex"} justifyContent={"center"}>
|
||||
{localStorage?.getItem("role") !== "Maker" ? <Box>
|
||||
{localStorage?.getItem("role") !== import.meta.env.VITE_VITE_MAKER ? <Box>
|
||||
{index===0&&<Box display={"flex"} justifyContent={"center"} gap={2}>
|
||||
<Tooltip
|
||||
rounded={"sm"}
|
||||
|
||||
@@ -152,7 +152,7 @@ const IONAVDetails = () => {
|
||||
</Tab>
|
||||
</TabList>
|
||||
{IODetails?.isInvestedAmount
|
||||
? localStorage?.getItem("role") === "Maker" && (
|
||||
? localStorage?.getItem("role") === import.meta.env.VITE_VITE_MAKER && (
|
||||
<Button
|
||||
onClick={handleAdd}
|
||||
leftIcon={<AddIcon />}
|
||||
|
||||
@@ -90,7 +90,7 @@ const Pending = () => {
|
||||
"Investment Closed",
|
||||
"Comments",
|
||||
"Updated By",
|
||||
...(localStorage?.getItem("role") !== "Maker" ? ["Status"] : []),
|
||||
...(localStorage?.getItem("role") !== import.meta.env.VITE_VITE_MAKER ? ["Status"] : []),
|
||||
];
|
||||
|
||||
const extractedArray = filteredData?.map((item, index) => ({
|
||||
|
||||
@@ -195,7 +195,7 @@ const Pending = () => {
|
||||
}
|
||||
}}
|
||||
>
|
||||
{localStorage?.getItem("role") === "Maker" ? <ViewIcon me={"4px"} /> : null} {localStorage?.getItem("role") === "Maker" ? "View" : "Approve / Reject"}
|
||||
{localStorage?.getItem("role") === import.meta.env.VITE_VITE_MAKER ? <ViewIcon me={"4px"} /> : null} {localStorage?.getItem("role") === import.meta.env.VITE_VITE_MAKER ? "View" : "Approve / Reject"}
|
||||
</Button>
|
||||
</Box>
|
||||
),
|
||||
|
||||
@@ -236,7 +236,7 @@ const ViewAmountInvested = ({ isOpen, onClose, id: investorId }) => {
|
||||
/>
|
||||
</FormControl>
|
||||
|
||||
{localStorage?.getItem("role") !== "Maker" && <ModalFooter>
|
||||
{localStorage?.getItem("role") !== import.meta.env.VITE_VITE_MAKER && <ModalFooter>
|
||||
<Box display={"flex"} justifyContent={"center"} gap={2}>
|
||||
<Button
|
||||
rounded={"sm"}
|
||||
|
||||
@@ -311,7 +311,7 @@ import RequestRejectModal from "./RequestRejectModal";
|
||||
data={extractedArray}
|
||||
/>
|
||||
</ModalBody>
|
||||
{localStorage?.getItem("role") !== "Maker" && <ModalFooter pt={0}>
|
||||
{localStorage?.getItem("role") !== import.meta.env.VITE_VITE_MAKER && <ModalFooter pt={0}>
|
||||
<Box display={"flex"} justifyContent={"center"} gap={2}>
|
||||
<Button
|
||||
rounded={"sm"}
|
||||
|
||||
@@ -218,7 +218,7 @@ const ViewDistributionInvestor = ({ isOpen, onClose,id:exitId }) => {
|
||||
/>
|
||||
</ModalBody>
|
||||
{/* ...(localStorage?.getItem("role") !== "Maker" ? ["Status"] : []), */}
|
||||
{localStorage?.getItem("role") !== "Maker" &&<ModalFooter pt={0}>
|
||||
{localStorage?.getItem("role") !== import.meta.env.VITE_VITE_MAKER &&<ModalFooter pt={0}>
|
||||
<Box display={"flex"} justifyContent={"center"} gap={2}>
|
||||
<Button
|
||||
rounded={"sm"}
|
||||
|
||||
@@ -273,7 +273,7 @@ import RequestRejectModal from "./RequestRejectModal";
|
||||
/>
|
||||
{/* ) } */}
|
||||
</ModalBody>
|
||||
{localStorage?.getItem("role") !== "Maker" && <ModalFooter pt={0}>
|
||||
{localStorage?.getItem("role") !== import.meta.env.VITE_VITE_MAKER && <ModalFooter pt={0}>
|
||||
<Box display={"flex"} justifyContent={"center"} gap={2}>
|
||||
<Button
|
||||
rounded={"sm"}
|
||||
|
||||
@@ -532,7 +532,7 @@ const ViewIOdataHeader = ({ data, isLoading }) => {
|
||||
alignItems={"start"}
|
||||
height={"95px"}
|
||||
>
|
||||
{localStorage?.getItem("role") === "Maker" && <Menu>
|
||||
{localStorage?.getItem("role") === import.meta.env.VITE_VITE_MAKER && <Menu>
|
||||
<MenuButton
|
||||
className="link p-1 rounded-1 "
|
||||
bg={"#fff"}
|
||||
|
||||
@@ -93,10 +93,11 @@ const SubAdmin = () => {
|
||||
const handleToggleStatus = async (isMaker, id) => {
|
||||
console.log("hit");
|
||||
const data = {
|
||||
role_xid: isMaker ? 1 : 2,
|
||||
role_xid: isMaker ? "2" : "1",
|
||||
};
|
||||
console.log("=======================",data)
|
||||
try {
|
||||
const res = await toggleStatus(id, data).unwrap();
|
||||
const res = await toggleStatus({id, data});
|
||||
if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
@@ -179,24 +180,25 @@ const SubAdmin = () => {
|
||||
</Box>
|
||||
),
|
||||
Role: (
|
||||
<Box minW={24} isTruncated={true}>
|
||||
<Box isTruncated={true} >
|
||||
<Badge
|
||||
py={"2px"}
|
||||
px={"5px"}
|
||||
me={2}
|
||||
bg={item?.role[0]?.role === "Maker" ? "#00ffcc" : "#b3ff99"}
|
||||
fontWeight={600}
|
||||
bg={item?.role[0]?.role === import.meta.env.VITE_VITE_MAKER ? "#00ffcc" : "#b3ff99"}
|
||||
px={item?.role[0]?.role === import.meta.env.VITE_VITE_MAKER ? "12px" : "5px"}
|
||||
>
|
||||
{item?.role[0]?.role}
|
||||
</Badge>
|
||||
<Switch
|
||||
onChange={() =>
|
||||
handleToggleStatus(item?.role[0]?.role === "Maker", item?.id)
|
||||
handleToggleStatus(item?.role[0]?.role === import.meta.env.VITE_VITE_MAKER, item?.id)
|
||||
}
|
||||
isChecked={item?.role[0]?.role === "Maker"}
|
||||
isChecked={item?.role[0]?.role === import.meta.env.VITE_VITE_MAKER}
|
||||
// colorScheme={item?.role[0]?.role === "Maker" ? "green" : "teal"}
|
||||
sx={{
|
||||
".chakra-switch__track": {
|
||||
bg: item?.role[0]?.role === "Maker" ? "#00ffcc" : "#b3ff99", // "Off" state color
|
||||
bg: item?.role[0]?.role === import.meta.env.VITE_VITE_MAKER ? "#00ffcc" : "#b3ff99", // "Off" state color
|
||||
},
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -94,7 +94,7 @@ const SubAdminUpdateCreate = () => {
|
||||
lastName: subAdminByIdData?.data?.lastName,
|
||||
emailAddress: subAdminByIdData?.data?.emailAddress,
|
||||
});
|
||||
setIsSwitchOn(subAdminByIdData?.data?.role[0]?.role==="Maker");
|
||||
setIsSwitchOn(subAdminByIdData?.data?.role[0]?.role===import.meta.env.VITE_VITE_MAKER);
|
||||
console.log(subAdminByIdData?.data?.role);
|
||||
}
|
||||
}, [subAdminByIdData, reset]);
|
||||
@@ -206,8 +206,6 @@ const SubAdminUpdateCreate = () => {
|
||||
type: "text",
|
||||
isRequired: true,
|
||||
section: "",
|
||||
arabic: true,
|
||||
right: true,
|
||||
maxLength: 55,
|
||||
helperText: `Maximum length should be 55 characters. You have entered ${
|
||||
watch()?.lastName?.length || 0
|
||||
@@ -245,7 +243,6 @@ const SubAdminUpdateCreate = () => {
|
||||
type: "text",
|
||||
isRequired: true,
|
||||
section: "",
|
||||
arabic: true,
|
||||
maxLength: 55,
|
||||
helperText: `Maximum length should be 55 characters. You have entered ${
|
||||
watch()?.lastName?.length || 0
|
||||
|
||||
@@ -50,7 +50,7 @@ export const sabAdminMaster = createApi({
|
||||
// // ========[Toggle Status]========
|
||||
|
||||
toggleStatus: builder.mutation({
|
||||
query: (id, data) => ({
|
||||
query: ({id, data}) => ({
|
||||
url: `/subadmin/admin/toggle-role/${id}`,
|
||||
method: "PATCH",
|
||||
body: data,
|
||||
|
||||
Reference in New Issue
Block a user