Skip to content

Commit

Permalink
fixed dashboard bug
Browse files Browse the repository at this point in the history
  • Loading branch information
subru-37 committed Jul 2, 2024
1 parent 34d68cc commit da91f7c
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 95 deletions.
8 changes: 0 additions & 8 deletions apps/core-admin/.env.example

This file was deleted.

4 changes: 0 additions & 4 deletions apps/core-auth0-actions/.env.example

This file was deleted.

15 changes: 0 additions & 15 deletions apps/web-admin/.env.example

This file was deleted.

134 changes: 70 additions & 64 deletions apps/web-admin/src/layouts/DashboardLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { IoMdArrowRoundBack } from 'react-icons/io';
import { RxHamburgerMenu } from 'react-icons/rx';

import Sidebar from '@/components/Sidebar';
import { useAuth0 } from '@auth0/auth0-react';

export default function DashboardLayout({
previousPage,
Expand All @@ -18,83 +19,88 @@ export default function DashboardLayout({

const [isMobile] = useMediaQuery('(max-width: 768px)');
const [isSidebarOpen, setSidebarOpen] = useState(isMobile);

return (
<Flex height="100vh" flexDirection="column">
<Flex height="100%" overflow="hidden" flexDirection={isMobile ? 'column' : 'row'}>
{isMobile && (
<Flex
height={24}
p={4}
flexDirection="row"
justifyContent="space-between"
alignItems="center"
>
<Text fontSize="4xl" fontWeight="bold">
{pageTitle}
</Text>
const { user, isAuthenticated, isLoading } = useAuth0();
// console.log(user, isLoading, isAuthenticated)
if (isAuthenticated) {
return (
<Flex height="100vh" flexDirection="column">
<Flex height="100%" overflow="hidden" flexDirection={isMobile ? 'column' : 'row'}>
{isMobile && (
<Flex
height={10}
width={10}
justifyContent="center"
height={24}
p={4}
flexDirection="row"
justifyContent="space-between"
alignItems="center"
onClick={() => {
setSidebarOpen(true);
}}
>
<RxHamburgerMenu fontSize={30} color="black" />
<Text fontSize="4xl" fontWeight="bold">
{pageTitle}
</Text>
<Flex
height={10}
width={10}
justifyContent="center"
alignItems="center"
onClick={() => {
setSidebarOpen(true);
}}
>
<RxHamburgerMenu fontSize={30} color="black" />
</Flex>
</Flex>
</Flex>
)}
<Sidebar isOpen={isSidebarOpen} onClose={() => setSidebarOpen(false)} />
<Flex
height="100%"
width="100%"
overflowY="hidden"
flexDirection="column"
transition="margin 0.3s ease"
>
)}
<Sidebar isOpen={isSidebarOpen} onClose={() => setSidebarOpen(false)} />
<Flex
height={isMobile ? 'auto' : 40}
height="100%"
width="100%"
p={4}
flexDirection="row"
justifyContent="space-between"
alignItems="center"
overflowY="hidden"
flexDirection="column"
transition="margin 0.3s ease"
>
{!isMobile && (
<Flex width="100%" alignItems="center" gap={10}>
<IoMdArrowRoundBack
size={30}
onClick={() => {
router.push(previousPage);
}}
/>
<Text fontSize="4xl" fontWeight="bold">
{pageTitle}
</Text>
</Flex>
)}
<Flex
height="100%"
height={isMobile ? 'auto' : 40}
width="100%"
justifyContent={isMobile ? 'space-evenly' : 'flex-end'}
p={4}
flexDirection="row"
justifyContent="space-between"
alignItems="center"
gap={4}
>
{headerButton}
{!isMobile && (
<Flex width="100%" alignItems="center" gap={10}>
<IoMdArrowRoundBack
size={30}
onClick={() => {
router.push(previousPage);
}}
/>
<Text fontSize="4xl" fontWeight="bold">
{pageTitle}
</Text>
</Flex>
)}
<Flex
height="100%"
width="100%"
justifyContent={isMobile ? 'space-evenly' : 'flex-end'}
alignItems="center"
gap={4}
>
{headerButton}
</Flex>
</Flex>
<Box height="100%" overflowY="hidden" p={4}>
{children}
</Box>
</Flex>
<Box height="100%" overflowY="hidden" p={4}>
{children}
</Box>
</Flex>
{!isMobile && (
<Box fontSize="xs" maxHeight={4} overflow="hidden">
{JSON.stringify(debugInfo)}
</Box>
)}
</Flex>
{!isMobile && (
<Box fontSize="xs" maxHeight={4} overflow="hidden">
{JSON.stringify(debugInfo)}
</Box>
)}
</Flex>
);
);
} else {
return <div></div>;
}
}
7 changes: 7 additions & 0 deletions apps/web-admin/src/pages/landing/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';
import { Box } from '@chakra-ui/react';
const Landing = () => {
return <Box>unleash your creativity here</Box>;
};

export default Landing;
8 changes: 4 additions & 4 deletions apps/web-admin/src/pages/settings/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function Settings() {
useEffect(() => {
const fetchAccountDetails = async () => {
const { data, status } = await get('/core/users/me');
setAccountDetails(data.accountDetails || []);
setAccountDetails(data.accountDetails || {});
};
fetchAccountDetails();
}, []);
Expand All @@ -32,7 +32,7 @@ export default function Settings() {
description: 'Account details updated successfully.',
status: 'success',
});
setAccountDetails(data.accountDetails || []);
setAccountDetails(data.accountDetails || {});
} else {
showAlert({
title: 'Error',
Expand Down Expand Up @@ -64,7 +64,7 @@ export default function Settings() {
<Input
type="text"
name="firstName"
value={accountDetails.firstName}
value={accountDetails.firstName || ''}
onChange={(e) => {
setAccountDetails({ ...accountDetails, firstName: e.target.value });
}}
Expand All @@ -85,7 +85,7 @@ export default function Settings() {
<Input
type="text"
name="lastName"
value={accountDetails.lastName}
value={accountDetails.lastName || ''}
onChange={(e) => {
setAccountDetails({ ...accountDetails, lastName: e.target.value });
}}
Expand Down

0 comments on commit da91f7c

Please sign in to comment.