Skip to content

Commit 40878bf

Browse files
authored
desktop switch teams (#155)
This PR enhances the desktop switch teams functionality by ensuring the '/switch-teams' route is properly recognized as a home route and improves code organization through refactoring. Added '/switch-teams' to the list of home routes in the useHome utility Reorganized SwitchTeams component export for better code structure Refactored inline onClick handler to a named function for better maintainability
1 parent 6c29377 commit 40878bf

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

src/renderer/src/routes/ProjectsScreen.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ const ProjectsScreenInner: React.FC = () => {
165165
setAddOpen(false);
166166
};
167167

168+
const handleSwitchTeams = () => {
169+
localStorage.removeItem(LocalKey.plan);
170+
navigate('/switch-teams');
171+
};
172+
168173
React.useEffect(() => {
169174
startClear();
170175
setHome(true);
@@ -271,10 +276,7 @@ const ProjectsScreenInner: React.FC = () => {
271276
<Button
272277
id="ProjectActSwitch"
273278
variant="outlined"
274-
onClick={() => {
275-
localStorage.removeItem(LocalKey.plan);
276-
navigate('/switch-teams');
277-
}}
279+
onClick={handleSwitchTeams}
278280
sx={(theme) => ({
279281
minWidth: 120,
280282
bgcolor: theme.palette.common.white,

src/renderer/src/routes/SwitchTeams.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -429,21 +429,6 @@ const useSettingsHandlers = () => {
429429
return ctx;
430430
};
431431

432-
export const SwitchTeams: React.FC = () => {
433-
return (
434-
<Box sx={{ width: '100%' }}>
435-
<TeamProvider>
436-
<>
437-
<AppHead />
438-
<SettingsProvider>
439-
<MainTeamsLayout />
440-
</SettingsProvider>
441-
</>
442-
</TeamProvider>
443-
</Box>
444-
);
445-
};
446-
447432
const MainTeamsLayout: React.FC = () => {
448433
const { openSettingsForTeam, openSettingsForPersonal } =
449434
useSettingsHandlers();
@@ -470,4 +455,19 @@ const MainTeamsLayout: React.FC = () => {
470455
);
471456
};
472457

458+
export const SwitchTeams: React.FC = () => {
459+
return (
460+
<Box sx={{ width: '100%' }}>
461+
<TeamProvider>
462+
<>
463+
<AppHead />
464+
<SettingsProvider>
465+
<MainTeamsLayout />
466+
</SettingsProvider>
467+
</>
468+
</TeamProvider>
469+
</Box>
470+
);
471+
};
472+
473473
export default SwitchTeams;

src/renderer/src/utils/useHome.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export const useHome = (): HomeResult => {
3434
if (getGlobal('home')) setHome(false);
3535
};
3636
const checkHome = (to: To): void => {
37-
const gohome = !to || to === '/' || to === '/team';
37+
const gohome =
38+
!to || to === '/' || to === '/team' || to === '/switch-teams';
3839
if (getGlobal('home') !== gohome) setHome(gohome);
3940
};
4041

0 commit comments

Comments
 (0)