import { type PropsWithChildren } from 'react';

import Maintenance from 'src/pages/error/Maintenance';
import { isOnMaintenance } from 'src/utils/maintenance';

export type MaintenanceGuardProps = PropsWithChildren;

export const MaintenanceGuard = ({ children }: MaintenanceGuardProps) => {
  if (isOnMaintenance()) return <Maintenance />;
  return <>{children}</>;
};

export default MaintenanceGuard;
