CustomSidebar.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. // TODO : #140878 Match the space specification method to others
  14. // ref. https://redmine.weseek.co.jp/issues/140878
  15. <div className="px-3">
  16. <div className="grw-sidebar-content-header py-3 d-flex">
  17. <h3 className="mb-0">
  18. {t('CustomSidebar')}
  19. { !isLoading && <Link href="/Sidebar#edit" className="h6 ms-2"><span className="material-symbols-outlined">edit</span></Link> }
  20. </h3>
  21. { !isLoading && <SidebarHeaderReloadButton onClick={() => mutate()} /> }
  22. </div>
  23. <Suspense fallback={<DefaultContentSkeleton />}>
  24. <CustomSidebarContent />
  25. </Suspense>
  26. </div>
  27. );
  28. };