CustomSidebar.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { Suspense } from 'react';
  2. import dynamic from 'next/dynamic';
  3. import Link from 'next/link';
  4. import { useTranslation } from 'react-i18next';
  5. import { useSWRxPageByPath } from '~/stores/page';
  6. import { SidebarHeaderReloadButton } from '../SidebarHeaderReloadButton';
  7. import DefaultContentSkeleton from '../Skeleton/DefaultContentSkeleton';
  8. const CustomSidebarContent = dynamic(() => import('./CustomSidebarSubstance').then(mod => mod.CustomSidebarSubstance), { ssr: false });
  9. export const CustomSidebar = (): JSX.Element => {
  10. const { t } = useTranslation();
  11. const { mutate, isLoading } = useSWRxPageByPath('/Sidebar');
  12. return (
  13. <div className="pt-4 pb-3 px-3">
  14. <div className="grw-sidebar-content-header d-flex">
  15. <h4 className="mb-0">
  16. {t('CustomSidebar')}
  17. { !isLoading && <Link href="/Sidebar#edit" className="h6 ms-2"><span className="material-symbols-outlined">edit</span></Link> }
  18. </h4>
  19. { !isLoading && <SidebarHeaderReloadButton onClick={() => mutate()} /> }
  20. </div>
  21. <Suspense fallback={<DefaultContentSkeleton />}>
  22. <CustomSidebarContent />
  23. </Suspense>
  24. </div>
  25. );
  26. };