Commit c3a60610 by Arjun Jhukal

fixed the admin and superadmin redirection

parent 687cbc93
......@@ -6,10 +6,10 @@ import AdminDashboardRoot from '../../(admin)/AdminDashboard';
export default function DashboardProvider({ children }: { children: React.ReactNode }) {
const user = useAppSelector(state => state?.auth.user);
if (user?.role && user.role.toUpperCase() === "ADMIN") {
return <AdminDashboardRoot />
if (user?.role && user.role.toUpperCase() === "USER") {
return (
<div>{children}</div>
)
}
return (
<div>{children}</div>
)
return <AdminDashboardRoot />
}
......@@ -40,10 +40,16 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
return (
<Box sx={{ display: 'flex' }}>
<Header open={open} handleDrawerOpen={handleDrawerOpen} handleMobileMenuToggle={handleMobileMenuToggle} />
<Sidebar open={open} handleDrawerOpen={handleDrawerOpen} handleMobileMenuToggle={handleMobileMenuToggle} mobileMenuOpen={openMobile
} />
<Header
open={open}
handleDrawerOpen={handleDrawerOpen}
handleMobileMenuToggle={handleMobileMenuToggle} />
<Sidebar open={open}
handleDrawerOpen={handleDrawerOpen}
handleMobileMenuToggle={handleMobileMenuToggle}
mobileMenuOpen={openMobile
} />
<div className="root_container w-full overflow-hidden">
<DrawerHeader sx={{
mb: { xs: '16px', lg: 0 }
......
......@@ -179,6 +179,7 @@ export default function PaymentModal({
data.type === 'payment:success' ||
data.type === `payment:${successMessage}` ||
data.result === 'success' ||
data.verification_status === 'verification.accepted' ||
data.result === successMessage ||
(typeof data === 'string' && (
data === successMessage ||
......
......@@ -106,10 +106,10 @@ export default function Header({ open, handleDrawerOpen, handleMobileMenuToggle
<HambergerMenu className='!text-para-light' />
</IconButton>}
{
user?.role && user.role.toUpperCase() === 'ADMIN' ? (
<AdminHeader />
) : (
user?.role && user.role.toUpperCase() === 'USER' ? (
<UserHeader />
) : (
<AdminHeader />
)
}
</Toolbar>
......
......@@ -125,7 +125,7 @@ export default function Sidebar({ open, handleMobileMenuToggle, mobileMenuOpen }
if (downLG) {
return <div className={`mobile__menu__wrapper fixed left-0 top-0 bottom-0 max-h-screen backdrop-blur-2xl bg-[#290139CF] w-full z-[9999] transition-all duration-300 ${mobileMenuOpen ? "opacity-100 visible" : "opacity-0 invisible"}`} >
<div className={`mobile__primary__menu max-w-[600px] w-full h-screen transition-all duration-300 ${mobileMenuOpen ? "opacity-100 visible translate-x-0" : "opacity-0 invisible translate-x-[-100%]"} ${user?.role && user.role.toUpperCase() === 'ADMIN' ? "bg-white" : "bg-[#11011E]"}`} ref={ref}>
<div className={`mobile__primary__menu max-w-[600px] w-full h-screen transition-all duration-300 ${mobileMenuOpen ? "opacity-100 visible translate-x-0" : "opacity-0 invisible translate-x-[-100%]"} ${user?.role && user.role.toUpperCase() === 'USER' ? "bg-[#11011E]" : "bg-white"}`} ref={ref}>
<div className="flex justify-between items-center p-4 ">
{data?.data?.logo && <Link href="/">
<Image src={data?.data?.logo} alt="Logo" width={102} height={56} />
......@@ -147,10 +147,10 @@ export default function Sidebar({ open, handleMobileMenuToggle, mobileMenuOpen }
</div>
<Box className={`mt-8 menu__wrapper `} >
{
user?.role && user.role.toUpperCase() === 'ADMIN' ? (
<AdminMenu open={open} />
) : (
user?.role && user.role.toUpperCase() === 'USER' ? (
<UserMenu open={open} />
) : (
<AdminMenu open={open} />
)
}
</Box>
......@@ -168,10 +168,10 @@ export default function Sidebar({ open, handleMobileMenuToggle, mobileMenuOpen }
<Box className={`mt-8 menu__wrapper`} >
{
user?.role && user.role.toUpperCase() === 'ADMIN' ? (
<AdminMenu open={open} />
) : (
user?.role && user.role.toUpperCase() === 'USER' ? (
<UserMenu open={open} />
) : (
<AdminMenu open={open} />
)
}
</Box>
......
......@@ -77,8 +77,8 @@ export default function LoginPage() {
secure: process.env.NODE_ENV === 'production',
sameSite: 'Strict',
});
console.log("Login Response:", response?.data?.user?.role.toLowerCase() === "admin");
router.replace(response?.data?.user?.role?.toLowerCase() === "admin" ? "/" : "/credentials");
console.log("Login Response:", response?.data?.user?.role.toLowerCase() === "user");
router.replace(response?.data?.user?.role?.toLowerCase() === "user" ? "/credentials" : "/");
}
catch (e: any) {
dispatch(
......
// 'use client';
// import { useAppDispatch, useAppSelector } from '@/hooks/hook';
// import { useDepositMutation } from '@/services/transaction';
// import { showToast, ToastVariant } from '@/slice/toastSlice';
// import { DepositProps } from '@/types/transaction';
// import { Button, InputLabel, OutlinedInput } from '@mui/material';
// import { useRouter } from 'next/navigation';
// import Script from 'next/script';
// import { PaymentModeProps } from '.';
// declare global {
// interface Window {
// CollectJS: {
// configure: (config: {
// paymentType: string;
// callback: (response: any) => void;
// }) => void;
// };
// }
// }
// export default function PaymentForm({ id, amount, type }: DepositProps & { type: PaymentModeProps }) {
// const dispatch = useAppDispatch();
// const router = useRouter();
// const user = useAppSelector((state) => state.auth.user);
// const [payViaFortPay, { isLoading }] = useDepositMutation();
// const handleCollectJSLoad = () => {
// if (typeof window !== 'undefined' && window.CollectJS) {
// window.CollectJS.configure({
// paymentType: 'cc',
// callback: async (response) => {
// try {
// await payViaFortPay({
// id: id,
// amount: amount,
// type: type as PaymentModeProps,
// payment_token: response.token
// }).unwrap();
// router.push(`/buy-coins/${id}/success`)
// }
// catch (e: any) {
// dispatch(showToast({
// message: e?.data?.message || "Unable to deposit",
// variant: ToastVariant.ERROR
// }))
// }
// }
// });
// }
// };
// return (
// <>
// <Script
// src="https://secure.fppgateway.com/token/Collect.js"
// data-tokenization-key="NAhDuk-7V4u2u-tUAsT5-dCqbH5"
// strategy="afterInteractive"
// onReady={handleCollectJSLoad}
// />
// <form className="theForm">
// <div className="formInner flex flex-col gap-3 md:grid md:grid-cols-2">
// <div className="form-group">
// <InputLabel htmlFor="fname">First Name </InputLabel>
// <OutlinedInput type="text" className="form-control" placeholder="First Name" name="fname" defaultValue={user?.first_name} />
// </div>
// <div className="form-group">
// <InputLabel htmlFor="lname">Last Name </InputLabel>
// <OutlinedInput type="text" className="form-control" placeholder="Last Name" name="lname" defaultValue={user?.last_name} />
// </div>
// <div className="form-group">
// <InputLabel htmlFor="address1">Address </InputLabel>
// <OutlinedInput type="text" className="form-control" placeholder="Street Address" name="address1" defaultValue={user?.address} />
// </div>
// <div className="form-group">
// <InputLabel htmlFor="city">City </InputLabel>
// <OutlinedInput type="text" className="form-control" placeholder="City" name="city" defaultValue={user?.city} />
// </div>
// <div className="form-group">
// <InputLabel htmlFor="state">State </InputLabel>
// <OutlinedInput type="text" className="form-control" placeholder="State" name="state" defaultValue={user?.state} />
// </div>
// <div className="form-group">
// <InputLabel htmlFor="zip">Zip Code </InputLabel>
// <OutlinedInput type="text" className="form-control" placeholder="Zip code" name="zip" defaultValue={""} />
// </div>
// </div>
// {/* <OutlinedInput type="submit" id="payButton" value="Pay $5" className="btn btn-primary btn-block" /> */}
// <Button type="submit" id="payButton" variant='contained' color='primary' className='mt-4!'>{isLoading ? "Proceeding Payment" : "Proceed Payment"}</Button>
// </form>
// <div id="paymentTokenInfo"></div>
// </>
// );
// }
'use client';
import { useAppDispatch, useAppSelector } from '@/hooks/hook';
......
......@@ -69,7 +69,7 @@ export const transactionApi = createApi({
method: "GET"
}),
providesTags: ['Deposit', 'Withdrawl']
}),
deposit: builder.mutation<DepositResponseProps, DepositProps>({
query: ({ id, amount, type, payment_token, number, hash, exp, bin }) => ({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment