CustomSidebar.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { type JSX, 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(
  9. () =>
  10. import('./CustomSidebarSubstance').then(
  11. (mod) => mod.CustomSidebarSubstance,
  12. ),
  13. { ssr: false },
  14. );
  15. export const CustomSidebar = (): JSX.Element => {
  16. const { t } = useTranslation();
  17. const { mutate, isLoading } = useSWRxPageByPath('/Sidebar');
  18. return (
  19. <div className="pt-4 pb-3 px-3">
  20. <div className="grw-sidebar-content-header d-flex">
  21. <h3 className="fs-6 fw-bold mb-0">
  22. {t('Custom Sidebar')}
  23. {!isLoading && (
  24. <Link href="/Sidebar#edit" className="h6 ms-2">
  25. <span className="material-symbols-outlined">edit</span>
  26. </Link>
  27. )}
  28. </h3>
  29. {!isLoading && <SidebarHeaderReloadButton onClick={() => mutate()} />}
  30. </div>
  31. <Suspense fallback={<DefaultContentSkeleton />}>
  32. <CustomSidebarContent />
  33. </Suspense>
  34. </div>
  35. );
  36. };