RestartingState.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { useParams } from 'common'
  2. import { Loader2 } from 'lucide-react'
  3. import { useProjectDetailQuery } from '@/data/projects/project-detail-query'
  4. import { PROJECT_STATUS } from '@/lib/constants'
  5. const RestartingState = () => {
  6. const { ref } = useParams()
  7. useProjectDetailQuery(
  8. { ref },
  9. {
  10. // setting a refetch interval here will cause the `useSelectedProject()` in `ProjectLayout.tsx` to
  11. // rerender every 4 seconds while the project is restarting. Once restarting is complete, it will
  12. // no longer show this state.
  13. refetchInterval: (query) => {
  14. const data = query.state.data
  15. return data?.status !== PROJECT_STATUS.ACTIVE_HEALTHY ? 4000 : false
  16. },
  17. }
  18. )
  19. return (
  20. <div className="flex items-center justify-center h-full">
  21. <div className="bg-surface-100 border border-overlay rounded-md w-3/4 lg:w-1/2">
  22. <div className="space-y-6 py-6">
  23. <div className="flex px-8 space-x-8">
  24. <div className="mt-1">
  25. <Loader2 className="animate-spin" size={18} />
  26. </div>
  27. <div className="space-y-1">
  28. <p>Restarting...</p>
  29. <p className="text-sm text-foreground-light">
  30. Restarting can take a few minutes. Your project will be offline while it restarts.
  31. </p>
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. </div>
  37. )
  38. }
  39. export default RestartingState