import { Add, Star } from '@mui/icons-material'; import { Button, Divider, IconButton, SwipeableDrawer, Tooltip, useMediaQuery, useTheme } from '@mui/material'; import { Section as SectionRecord } from '@reactive-resume/schema'; import get from 'lodash/get'; import Link from 'next/link'; import { useTranslation } from 'next-i18next'; import { useMemo } from 'react'; import { validate } from 'uuid'; import Logo from '@/components/shared/Logo'; import { getCustomSections, left } from '@/config/sections'; import { setSidebarState } from '@/store/build/buildSlice'; import { useAppDispatch, useAppSelector } from '@/store/hooks'; import { addSection } from '@/store/resume/resumeSlice'; import styles from './LeftSidebar.module.scss'; import Section from './sections/Section'; const LeftSidebar = () => { const theme = useTheme(); const { t } = useTranslation(); const dispatch = useAppDispatch(); const isDesktop = useMediaQuery(theme.breakpoints.up('lg')); const sections = useAppSelector((state) => state.resume.sections); const { open } = useAppSelector((state) => state.build.sidebar.left); const customSections = useMemo(() => getCustomSections(sections), [sections]); const handleOpen = () => dispatch(setSidebarState({ sidebar: 'left', state: { open: true } })); const handleClose = () => dispatch(setSidebarState({ sidebar: 'left', state: { open: false } })); const handleClick = (id: string) => { const elementId = validate(id) ? `#section-${id}` : `#${id}`; const section = document.querySelector(elementId); if (section) { section.scrollIntoView({ behavior: 'smooth', block: 'start' }); } }; const handleAddSection = () => { const newSection: SectionRecord = { name: 'Custom Section', type: 'custom', visible: true, columns: 2, items: [], }; dispatch(addSection({ value: newSection })); }; return (
{left.map(({ id, component }) => (
{component}
))} {customSections.map(({ id }) => (
))}
); }; export default LeftSidebar;