MCPcopy
hub / github.com/chartbrew/chartbrew / Main

Function Main

client/src/containers/Main.jsx:85–330  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

83 The main component where the entire app routing resides
84*/
85function 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)

Callers

nothing calls this directly

Calls 11

useThemeFunction · 0.90
cleanErrorsFunction · 0.90
relogFunction · 0.90
getTeamsFunction · 0.90
areThereAnyUsersFunction · 0.90
saveActiveTeamFunction · 0.90
getTeamConnectionsFunction · 0.90
canAccessFunction · 0.85
authenticatePageFunction · 0.70
dispatchFunction · 0.50
removeMethod · 0.45

Tested by

no test coverage detected