(props)
| 83 | The main component where the entire app routing resides |
| 84 | */ |
| 85 | function Main(props) { |
| 86 | const { cleanErrors } = props; |
| 87 | |
| 88 | const user = useSelector(selectUser); |
| 89 | const team = useSelector(selectTeam); |
| 90 | const teams = useSelector(selectTeams); |
| 91 | const feedbackModal = useSelector(selectFeedbackModalOpen); |
| 92 | const aiModalOpen = useSelector(selectAiModalOpen); |
| 93 | const teamsRef = useRef(null); |
| 94 | |
| 95 | const { isDark } = useTheme(); |
| 96 | const location = useLocation(); |
| 97 | const navigate = useNavigate(); |
| 98 | const dispatch = useDispatch(); |
| 99 | const { pathname } = useLocation(); |
| 100 | |
| 101 | useEffect(() => { |
| 102 | if (isDark) { |
| 103 | document.body.classList.add("dark"); |
| 104 | document.body.classList.remove("light"); |
| 105 | } else { |
| 106 | document.body.classList.add("light"); |
| 107 | document.body.classList.remove("dark"); |
| 108 | } |
| 109 | }, [isDark]); |
| 110 | |
| 111 | useEffect(() => { |
| 112 | cleanErrors(); |
| 113 | if (!location.pathname.match(/\/chart\/\d+\/embedded/g)) { |
| 114 | dispatch(relog()) |
| 115 | .then((data) => { |
| 116 | if (data.payload?.id) { |
| 117 | return dispatch(getTeams()); |
| 118 | } |
| 119 | |
| 120 | if (authenticatePage()) { |
| 121 | window.location.pathname = "/login"; |
| 122 | } |
| 123 | |
| 124 | return null; |
| 125 | }) |
| 126 | .then(() => { |
| 127 | // return dispatch(getProjects({ team_id: data.payload?.[0]?.id })); |
| 128 | }); |
| 129 | |
| 130 | dispatch(areThereAnyUsers()) |
| 131 | .then((anyUsers) => { |
| 132 | if (!anyUsers?.payload?.areThereAnyUsers && (pathname === "/login" || pathname === "/")) { |
| 133 | navigate("/signup"); |
| 134 | } |
| 135 | }); |
| 136 | } |
| 137 | |
| 138 | // Keyboard shortcut for AI modal (Cmd+K on Mac, Ctrl+K on Windows) |
| 139 | const handleKeyDown = (event) => { |
| 140 | // Check for Cmd+K (Mac) or Ctrl+K (Windows/Linux) |
| 141 | if ((event.metaKey || event.ctrlKey) && event.key === "k") { |
| 142 | // Prevent default browser behavior (usually search) |
nothing calls this directly
no test coverage detected