Maintenance.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import type { JSX } from 'react';
  2. import { useTranslation } from 'next-i18next';
  3. import { apiv3Post } from '~/client/util/apiv3-client';
  4. import { toastError } from '~/client/util/toastr';
  5. import { useCurrentUser } from '~/states/global';
  6. export const Maintenance = (): JSX.Element => {
  7. const { t } = useTranslation();
  8. const currentUser = useCurrentUser();
  9. const logoutHandler = async () => {
  10. try {
  11. await apiv3Post('/logout');
  12. window.location.reload();
  13. } catch (err) {
  14. toastError(err);
  15. }
  16. };
  17. return (
  18. <div className="text-center">
  19. <h1>
  20. <span className="material-symbols-outlined large">error</span>
  21. </h1>
  22. <h1 className="text-center">{t('maintenance_mode.maintenance_mode')}</h1>
  23. <h3>{t('maintenance_mode.growi_is_under_maintenance')}</h3>
  24. <hr />
  25. <div className="text-start">
  26. {currentUser?.admin && (
  27. <p>
  28. <span className="material-symbols-outlined">
  29. arrow_circle_right
  30. </span>
  31. <a className="btn btn-link" href="/admin">
  32. {t('maintenance_mode.admin_page')}
  33. </a>
  34. </p>
  35. )}
  36. {currentUser != null ? (
  37. <p>
  38. <span className="material-symbols-outlined">
  39. arrow_circle_right
  40. </span>
  41. <button
  42. type="button"
  43. className="btn btn-link"
  44. onClick={logoutHandler}
  45. id="maintanounse-mode-logout"
  46. >
  47. {t('maintenance_mode.logout')}
  48. </button>
  49. </p>
  50. ) : (
  51. <p>
  52. <span className="material-symbols-outlined">
  53. arrow_circle_right
  54. </span>
  55. <a className="btn btn-link" href="/login">
  56. {t('maintenance_mode.login')}
  57. </a>
  58. </p>
  59. )}
  60. </div>
  61. </div>
  62. );
  63. };