update roles ⚠️
This commit is contained in:
@@ -31,6 +31,7 @@ const HeaderMain = ({
|
||||
icon,
|
||||
logOutHandler,
|
||||
slideDirecttion,
|
||||
data
|
||||
}) => {
|
||||
const navigate = useNavigate()
|
||||
const { colorMode, toggleColorMode } = useContext(GlobalStateContext);
|
||||
@@ -100,10 +101,10 @@ const HeaderMain = ({
|
||||
className=" overflow-hidden ms-3 flex-column "
|
||||
>
|
||||
<Text as={"span"} className="web-text-small">
|
||||
Hello, Tanami admin
|
||||
Hello, {data?.data?.firstName} {data?.data?.lastName}
|
||||
</Text>
|
||||
<Text as={"span"} className="web-text-xsmall">
|
||||
admin@tanami.com
|
||||
{data?.data?.emailAddress}
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
@@ -52,6 +52,7 @@ import {
|
||||
Breadcrumb,
|
||||
Divider,
|
||||
Tooltip,
|
||||
useRadio,
|
||||
} from "@chakra-ui/react";
|
||||
import GlobalStateContext from "../Contexts/GlobalStateContext";
|
||||
import Cookies from "js-cookie"; // Import the Cookies library
|
||||
@@ -79,8 +80,13 @@ import CreateRequest from "../Pages/Fawateer/CreateRequest";
|
||||
import ApproveRequest from "../Pages/FawateerChecker/ApproveRequest/ApproveRequest";
|
||||
import ApproveHistoryMaker from "../Pages/FawateerChecker/ApproveHistory/ApproveHistoryMaker";
|
||||
import ApproveHistory from "../Pages/FawateerChecker/ApproveHistory/ApproveHistoryChecker";
|
||||
import { useProfileQuery } from "../Services/io.service";
|
||||
|
||||
|
||||
|
||||
const DashboardLayout = ({ isOnline }) => {
|
||||
|
||||
const userRole = localStorage.getItem("role");
|
||||
const navigate = useNavigate();
|
||||
const dispach = useDispatch();
|
||||
const location = useLocation();
|
||||
@@ -97,6 +103,13 @@ const DashboardLayout = ({ isOnline }) => {
|
||||
const [isSplashVisible, setSplashVisible] = useState(true);
|
||||
const [openIndex, setOpenIndex] = useState(null);
|
||||
|
||||
|
||||
const {
|
||||
data,
|
||||
refetch
|
||||
} = useProfileQuery()
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
!localStorage.getItem("accessToken") &&
|
||||
@@ -125,11 +138,14 @@ const DashboardLayout = ({ isOnline }) => {
|
||||
const timer = setTimeout(() => {
|
||||
setSplashVisible(false);
|
||||
}, 1000); // 3000ms = 3 seconds
|
||||
|
||||
refetch()
|
||||
// Cleanup the timer
|
||||
return () => clearTimeout(timer);
|
||||
}, []);
|
||||
|
||||
|
||||
|
||||
|
||||
const openDrawerOnClick = () => {
|
||||
setOpenDrawerClick(!openDrawerClick);
|
||||
};
|
||||
@@ -610,7 +626,7 @@ const DashboardLayout = ({ isOnline }) => {
|
||||
alignItems="center"
|
||||
overflow="hidden"
|
||||
>
|
||||
{subMenuTitle}
|
||||
{subMenuTitle === "Aprover Request"? data?.data?.role === "Maker"?"Create Request" : "Aprover Request":subMenuTitle}
|
||||
</Text>
|
||||
</NavLink>
|
||||
</Box>
|
||||
@@ -710,6 +726,7 @@ const DashboardLayout = ({ isOnline }) => {
|
||||
</header> */}
|
||||
|
||||
<HeaderMain
|
||||
data={data}
|
||||
slideDirecttion={slideFromRight}
|
||||
logOutHandler={logOutHandler}
|
||||
icon
|
||||
@@ -718,7 +735,7 @@ const DashboardLayout = ({ isOnline }) => {
|
||||
|
||||
{/* <CustomBreadcrumb /> */}
|
||||
|
||||
<AppContent />
|
||||
<AppContent data={data} />
|
||||
</main>
|
||||
</Box>
|
||||
);
|
||||
@@ -726,8 +743,8 @@ const DashboardLayout = ({ isOnline }) => {
|
||||
|
||||
export default DashboardLayout;
|
||||
|
||||
const AppContent = () => {
|
||||
const userRole = localStorage.getItem("role");
|
||||
const AppContent = ({data}) => {
|
||||
|
||||
return (
|
||||
<Routes>
|
||||
{RouteLink.map(({ path, Component }, index) => (
|
||||
@@ -737,24 +754,20 @@ const AppContent = () => {
|
||||
<Route
|
||||
path="/fawateer"
|
||||
element={
|
||||
userRole === "Maker" ? (
|
||||
data?.data?.role === "Maker" ? (
|
||||
<CreateRequest />
|
||||
) : userRole === "Checker" ? (
|
||||
<ApproveRequest />
|
||||
) : (
|
||||
<NotFound />
|
||||
<ApproveRequest />
|
||||
)
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="/fawateer-history"
|
||||
element={
|
||||
userRole === "Maker" ? (
|
||||
data?.data?.role === "Maker" ? (
|
||||
<ApproveHistoryMaker />
|
||||
) : userRole === "Checker" ? (
|
||||
) : (
|
||||
<ApproveHistory />
|
||||
) : (
|
||||
<NotFound />
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
Select,
|
||||
HStack,
|
||||
Input,
|
||||
useToast,
|
||||
} from '@chakra-ui/react'
|
||||
import NormalTable from '../../Components/DataTable/NormalTable'
|
||||
import { generateSerialNumber } from '../../Constants/Constants';
|
||||
@@ -22,11 +23,10 @@ import { TABLE_PAGINATION } from '../../Constants/Paginations';
|
||||
import Pagination from '../../Components/Pagination';
|
||||
import { AddIcon } from '@chakra-ui/icons';
|
||||
import { useGetFawateerInvestorsQuery } from '../../Services/fawateer.request.service';
|
||||
import ToastBox from '../../Components/ToastBox';
|
||||
|
||||
const SelectInvestorModal = ({ isOpen, setValue, onClose, setId}) => {
|
||||
|
||||
|
||||
|
||||
const toast = useToast()
|
||||
// =========================== [Use State] =============================
|
||||
const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size);
|
||||
const [currentPage, setCurrentPage] = useState(TABLE_PAGINATION?.page);
|
||||
@@ -61,10 +61,10 @@ const [ selectedRadio, setSelectedRadio] = useState([])
|
||||
const [ selectedInvestor, setSelectorInvestor] = useState(null)
|
||||
|
||||
const handleCheckboxChange = (id) => {
|
||||
|
||||
setSelectedRadio([id]);
|
||||
const investor = investorDetails?.data?.rows?.find((item)=> item?.id === id)
|
||||
setSelectorInvestor(investor)
|
||||
console.log(investor);
|
||||
setId(investor?.principal_xid)
|
||||
// setValue("investorName",`${selectedInvestor?.firstName} ${selectedInvestor?.lastName}`)
|
||||
// setValue("clientId",selectedInvestor?.clientReference_id)
|
||||
@@ -72,7 +72,14 @@ console.log(investor);
|
||||
};
|
||||
|
||||
const handleAdd = () => {
|
||||
console.log(selectedInvestor);
|
||||
if(selectedRadio?.length === 0){
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={'info'} message={"Please Select Investor"} />
|
||||
),
|
||||
});
|
||||
return
|
||||
}
|
||||
setValue("investorName",`${selectedInvestor?.firstName} ${selectedInvestor?.lastName}`)
|
||||
setValue("clientId",selectedInvestor?.clientReference_id)
|
||||
return onClose()
|
||||
@@ -92,7 +99,7 @@ console.log(investor);
|
||||
"E-mail ID",
|
||||
// "Type",
|
||||
// "KYC Status",
|
||||
"Approval Status",
|
||||
// "Approval Status",
|
||||
];
|
||||
|
||||
|
||||
@@ -178,7 +185,7 @@ console.log(investor);
|
||||
>
|
||||
<ModalOverlay />
|
||||
<ModalContent maxW={1200}>
|
||||
<ModalHeader fontSize={'md'}>Select Investor</ModalHeader>
|
||||
<ModalHeader fontSize={'md'}>View Investor's</ModalHeader>
|
||||
<ModalCloseButton />
|
||||
<ModalBody>
|
||||
{/* <Lorem count={2} /> */}
|
||||
@@ -203,7 +210,7 @@ console.log(investor);
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
<Button leftIcon={<AddIcon/>} fontSize={'xs'} colorScheme='forestGreen' size={'sm'} rounded={'sm'} onClick={handleAdd}>
|
||||
Add Invvestor
|
||||
Select Investor
|
||||
</Button>
|
||||
|
||||
</HStack>
|
||||
|
||||
@@ -107,7 +107,7 @@ export const nav = [
|
||||
title: "Fawateer Deposit",
|
||||
submenu: [
|
||||
{
|
||||
title: localStorage.getItem("role") === "Maker"? "Create Request":"Aprover Request",
|
||||
title: "Aprover Request",
|
||||
path: "/fawateer",
|
||||
icon: RiMoneyDollarBoxLine,
|
||||
},
|
||||
@@ -119,7 +119,7 @@ export const nav = [
|
||||
],
|
||||
type: "accordion",
|
||||
Icon: HiOutlineBanknotes,
|
||||
}
|
||||
}
|
||||
,
|
||||
|
||||
{
|
||||
|
||||
@@ -426,7 +426,9 @@ export const ioService = createApi({
|
||||
|
||||
|
||||
|
||||
|
||||
profile: builder.query({
|
||||
query: (id) => `/auth/admin/profile`,
|
||||
}),
|
||||
|
||||
|
||||
|
||||
@@ -507,5 +509,6 @@ export const {
|
||||
useCreateInvestmentTypeMutation,
|
||||
useUpdateInvestmentTypeMutation,
|
||||
useDeleteInvestmentTypeMutation,
|
||||
useProfileQuery
|
||||
|
||||
} = ioService;
|
||||
|
||||
@@ -124,6 +124,7 @@ export const apiSlice = createApi({
|
||||
|
||||
|
||||
|
||||
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user