import { AlignHorizontalCenter, AlignVerticalCenter, Download, FilterCenterFocus, InsertPageBreak, Link, ViewSidebar, ZoomIn, ZoomOut, } from '@mui/icons-material'; import { ButtonBase, Divider, Tooltip, useMediaQuery, useTheme } from '@mui/material'; import clsx from 'clsx'; import { get } from 'lodash'; import { useTranslation } from 'next-i18next'; import toast from 'react-hot-toast'; import { useMutation } from 'react-query'; import { ReactZoomPanPinchRef } from 'react-zoom-pan-pinch'; import { ServerError } from '@/services/axios'; import { printResumeAsPdf, PrintResumeAsPdfParams } from '@/services/printer'; import { togglePageBreakLine, togglePageOrientation, toggleSidebar } from '@/store/build/buildSlice'; import { useAppDispatch, useAppSelector } from '@/store/hooks'; import getResumeUrl from '@/utils/getResumeUrl'; import styles from './ArtboardController.module.scss'; const ArtboardController: React.FC = ({ zoomIn, zoomOut, centerView }) => { const { t } = useTranslation(); const theme = useTheme(); const dispatch = useAppDispatch(); const resume = useAppSelector((state) => state.resume); const isDesktop = useMediaQuery(theme.breakpoints.up('sm')); const { left, right } = useAppSelector((state) => state.build.sidebar); const orientation = useAppSelector((state) => state.build.page.orientation); const { mutateAsync, isLoading } = useMutation(printResumeAsPdf); const handleTogglePageBreakLine = () => dispatch(togglePageBreakLine()); const handleTogglePageOrientation = () => dispatch(togglePageOrientation()); const handleToggleSidebar = () => { dispatch(toggleSidebar({ sidebar: 'left' })); dispatch(toggleSidebar({ sidebar: 'right' })); }; const handleCopyLink = async () => { const url = getResumeUrl(resume, { withHost: true }); await navigator.clipboard.writeText(url); toast.success(t('common.toast.success.resume-link-copied')); }; const handleExportPDF = async () => { const download = (await import('downloadjs')).default; const slug = get(resume, 'slug'); const username = get(resume, 'user.username'); const url = await mutateAsync({ username, slug }); download(url); }; return (
('builder.controller.tooltip.zoom-in')}> zoomIn(0.25)}> ('builder.controller.tooltip.zoom-out')}> zoomOut(0.25)}> ('builder.controller.tooltip.center-artboard')}> centerView(0.95)}> {isDesktop && ( <> ('builder.controller.tooltip.toggle-orientation')}> {orientation === 'vertical' ? ( ) : ( )} ('builder.controller.tooltip.toggle-page-break-line')}> ('builder.controller.tooltip.toggle-sidebars')}> )} ('builder.controller.tooltip.copy-link')}> ('builder.controller.tooltip.export-pdf')}>
); }; export default ArtboardController;