diff --git a/src/components/IFrameWidget/editor.tsx b/src/components/IFrameWidget/editor.tsx index c7ff3620..8a7a6e71 100644 --- a/src/components/IFrameWidget/editor.tsx +++ b/src/components/IFrameWidget/editor.tsx @@ -54,7 +54,7 @@ class IFrameWidgetEditor extends Component { return (
<> - + IFrameWidget : {this.props.id} diff --git a/src/components/TextWidget/editor.tsx b/src/components/TextWidget/editor.tsx index 73336161..c44f3f44 100644 --- a/src/components/TextWidget/editor.tsx +++ b/src/components/TextWidget/editor.tsx @@ -113,7 +113,7 @@ class TextWidgetEditor extends Component { return (
<> - + TextWidget : {this.props.id} diff --git a/src/components/TimeWidget/editor.tsx b/src/components/TimeWidget/editor.tsx index 977930a0..9d9ac422 100644 --- a/src/components/TimeWidget/editor.tsx +++ b/src/components/TimeWidget/editor.tsx @@ -58,7 +58,7 @@ class TimeWidgetEditor extends Component { return (
<> - + TimeWidget : {this.props.id} diff --git a/src/components/admin/LeftSideNav/index.tsx b/src/components/admin/LeftSideNav/index.tsx new file mode 100644 index 00000000..d518ae74 --- /dev/null +++ b/src/components/admin/LeftSideNav/index.tsx @@ -0,0 +1,59 @@ +import { useState, useEffect, MouseEvent } from 'react'; +import { + Drawer, + Toolbar, + List, + ListItem, + ListItemText, + Divider, +} from '@mui/material'; +import { ref, onValue, DataSnapshot } from '@firebase/database'; +import { db } from '@/lib/firebase'; + +type LeftSideBarProps = { + profile: string; +} + +const LeftSideBar = ({ profile }: LeftSideBarProps) => { + const [widgets, setWidgets] = useState([]); + + useEffect(() => { + const widgetsRef = ref(db, `/profiles/${profile}/widgets`); + onValue(widgetsRef, (snap: DataSnapshot) => { + if (snap?.val()) { + setWidgets(Object.keys(snap.val())); + } + }); + }, [profile]); + + const drawerWidth = 160; + + return ( + + + + + {widgets.map((widget) => ( + + + {widget} + + + ))} + + + ); +}; + +export { LeftSideBar }; diff --git a/src/pages/admin/[id]/index.tsx b/src/pages/admin/[id]/index.tsx index 10c3542f..883b94b9 100644 --- a/src/pages/admin/[id]/index.tsx +++ b/src/pages/admin/[id]/index.tsx @@ -4,6 +4,7 @@ import { useRouter } from 'next/router'; import { CssBaseline, Container, + Toolbar, Box, } from '@mui/material'; import { User } from '@firebase/auth'; @@ -11,6 +12,7 @@ import { AuthProvider } from '@/lib/AuthProvider'; import { auth } from '@/lib/firebase'; import { Signin } from '@/components/admin/signin'; import { Navbar } from '@/components/admin/Navbar'; +import { LeftSideBar } from '@/components/admin/LeftSideNav'; import { Editors } from '@/components/admin/Editors'; const AdminIndexPage = () => { @@ -34,19 +36,29 @@ const AdminIndexPage = () => { currentUser !== null ? ( - + - - - + + + + + + - + ) : (