Skip to content

Commit 955e907

Browse files
committed
last endpoints
1 parent 76880e8 commit 955e907

7 files changed

Lines changed: 11 additions & 66 deletions

File tree

src/backend/src/services/users.services.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import {
1111
UserScheduleSettings,
1212
AuthenticatedUser,
1313
AvailabilityCreateArgs,
14-
ProjectGantt,
15-
UserWithScheduleSettings
14+
UserWithScheduleSettings,
15+
ProjectOverview
1616
} from 'shared';
1717
import prisma from '../prisma/prisma';
1818
import { AccessDeniedException, HttpException, NotFoundException } from '../utils/errors.utils';
1919
import { generateAccessToken } from '../utils/auth.utils';
20-
import { projectGanttTransformer } from '../transformers/projects.transformer';
21-
import { getProjectGanttQueryArgs } from '../prisma-query-args/projects.query-args';
20+
import { projectOverviewTransformer } from '../transformers/projects.transformer';
21+
import { getProjectOverviewQueryArgs } from '../prisma-query-args/projects.query-args';
2222
import userSecureSettingsTransformer from '../transformers/user-secure-settings.transformer';
2323
import userScheduleSettingsTransformer from '../transformers/user-schedule-settings.transformer';
2424
import { userTransformer, userWithScheduleSettingsTransformer } from '../transformers/user.transformer';
@@ -147,7 +147,7 @@ export default class UsersService {
147147
* @param organizationId the id of the organization the user is in
148148
* @returns the user's favorite projects
149149
*/
150-
static async getUsersFavoriteProjects(userId: string, organization: Organization): Promise<ProjectGantt[]> {
150+
static async getUsersFavoriteProjects(userId: string, organization: Organization): Promise<ProjectOverview[]> {
151151
const requestedUser = await prisma.user.findUnique({ where: { userId } });
152152
if (!requestedUser) throw new NotFoundException('User', userId);
153153

@@ -162,10 +162,10 @@ export default class UsersService {
162162
organizationId: organization.organizationId
163163
}
164164
},
165-
...getProjectGanttQueryArgs(organization.organizationId)
165+
...getProjectOverviewQueryArgs(organization.organizationId)
166166
});
167167

168-
return projects.map(projectGanttTransformer);
168+
return projects.map(projectOverviewTransformer);
169169
}
170170

171171
/**

src/frontend/src/hooks/users.hooks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ import {
3333
UserScheduleSettings,
3434
SetUserScheduleSettingsPayload,
3535
Task,
36-
ProjectOverview,
3736
UserWithRole,
38-
UserWithScheduleSettings
37+
UserWithScheduleSettings,
38+
ProjectOverview
3939
} from 'shared';
4040
import { useAuth } from './auth.hooks';
4141
import { useContext } from 'react';

src/frontend/src/pages/HomePage/AdminHomePage.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
*/
55

66
import { Typography, Grid, Box } from '@mui/material';
7-
import { useSingleUserSettings } from '../../hooks/users.hooks';
8-
import LoadingIndicator from '../../components/LoadingIndicator';
9-
import ErrorPage from '../ErrorPage';
107
import PageLayout, { PAGE_GRID_HEIGHT } from '../../components/PageLayout';
118
import { AuthenticatedUser } from 'shared';
129
import WorkPackagesSelectionView from './components/WorkPackagesSelectionView';
@@ -18,11 +15,6 @@ interface AdminHomePageProps {
1815
}
1916

2017
const AdminHomePage = ({ user }: AdminHomePageProps) => {
21-
const { isLoading, isError, error, data: userSettingsData } = useSingleUserSettings(user.userId);
22-
23-
if (isLoading || !userSettingsData) return <LoadingIndicator />;
24-
if (isError) return <ErrorPage error={error} message={error.message} />;
25-
2618
return (
2719
<PageLayout title="Home" hidePageTitle>
2820
<Typography variant="h3" marginLeft="auto" sx={{ marginTop: 2, textAlign: 'center', pt: 3, padding: 0 }}>

src/frontend/src/pages/HomePage/GuestHomePage.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
*/
55

66
import { Box, Grid, Stack, Typography } from '@mui/material';
7-
import { useSingleUserSettings } from '../../hooks/users.hooks';
8-
import LoadingIndicator from '../../components/LoadingIndicator';
9-
import ErrorPage from '../ErrorPage';
107
import PageLayout, { PAGE_GRID_HEIGHT } from '../../components/PageLayout';
118
import { AuthenticatedUser } from 'shared';
129
import MemberEncouragement from './components/MemberEncouragement';
@@ -21,7 +18,6 @@ interface GuestHomePageProps {
2118
}
2219

2320
const GuestHomePage = ({ user }: GuestHomePageProps) => {
24-
const { isLoading, isError, error, data: userSettingsData } = useSingleUserSettings(user.userId);
2521
const [showModal, setShowModal] = useState(false);
2622

2723
// shows modal only once per session
@@ -33,9 +29,6 @@ const GuestHomePage = ({ user }: GuestHomePageProps) => {
3329
}
3430
}, []);
3531

36-
if (isLoading || !userSettingsData) return <LoadingIndicator />;
37-
if (isError) return <ErrorPage error={error} message={error.message} />;
38-
3932
return (
4033
<PageLayout title="Home" hidePageTitle>
4134
<Typography variant="h3" marginLeft="auto" sx={{ marginTop: 2, textAlign: 'center', pt: 3, padding: 0 }}>

src/frontend/src/pages/HomePage/LeadHomePage.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
*/
55

66
import { Box, Grid, Typography } from '@mui/material';
7-
import { useSingleUserSettings } from '../../hooks/users.hooks';
8-
import LoadingIndicator from '../../components/LoadingIndicator';
9-
import ErrorPage from '../ErrorPage';
107
import PageLayout, { PAGE_GRID_HEIGHT } from '../../components/PageLayout';
118
import { AuthenticatedUser } from 'shared';
129
import ChangeRequestsToReview from './components/ChangeRequestsToReview';
@@ -19,11 +16,6 @@ interface LeadHomePageProps {
1916
}
2017

2118
const LeadHomePage = ({ user }: LeadHomePageProps) => {
22-
const { isLoading, isError, error, data: userSettingsData } = useSingleUserSettings(user.userId);
23-
24-
if (isLoading || !userSettingsData) return <LoadingIndicator />;
25-
if (isError) return <ErrorPage error={error} message={error.message} />;
26-
2719
return (
2820
<PageLayout title="Home" hidePageTitle>
2921
<Typography variant="h3" marginLeft="auto" sx={{ marginTop: 2, textAlign: 'center', pt: 3, padding: 0 }}>

src/frontend/src/pages/HomePage/MemberHomePage.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
*/
55

66
import { Box, Grid, Typography } from '@mui/material';
7-
import { useSingleUserSettings } from '../../hooks/users.hooks';
8-
import LoadingIndicator from '../../components/LoadingIndicator';
9-
import ErrorPage from '../ErrorPage';
107
import PageLayout, { PAGE_GRID_HEIGHT } from '../../components/PageLayout';
118
import { AuthenticatedUser } from 'shared';
129
import MyTasks from './components/MyTasks';
@@ -18,11 +15,6 @@ interface MemberHomePageProps {
1815
}
1916

2017
const MemberHomePage = ({ user }: MemberHomePageProps) => {
21-
const { isLoading, isError, error, data: userSettingsData } = useSingleUserSettings(user.userId);
22-
23-
if (isLoading || !userSettingsData) return <LoadingIndicator />;
24-
if (isError) return <ErrorPage error={error} message={error.message} />;
25-
2618
return (
2719
<PageLayout title="Home" hidePageTitle>
2820
<Typography variant="h3" marginLeft="auto" sx={{ marginTop: 2, textAlign: 'center', pt: 3, padding: 0 }}>

src/frontend/src/pages/SettingsPage/SettingsDetails.tsx

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useAuth } from '../../hooks/auth.hooks';
22
import { Box, Grid, Typography } from '@mui/material';
33
import DetailDisplay from '../../components/DetailDisplay';
44
import LoadingIndicator from '../../components/LoadingIndicator';
5-
import { useCurrentUser, useCurrentUserSecureSettings, useSingleUserSettings } from '../../hooks/users.hooks';
5+
import { useCurrentUser } from '../../hooks/users.hooks';
66
import ErrorPage from '../ErrorPage';
77
import { useAllTeams } from '../../hooks/teams.hooks';
88
import { displayEnum } from '../../utils/pipes';
@@ -11,34 +11,10 @@ import { isUserOnTeam } from '../../utils/teams.utils';
1111
const SettingsDetails: React.FC = () => {
1212
const auth = useAuth();
1313
const user = useCurrentUser();
14-
const {
15-
isLoading: settingsIsLoading,
16-
isError: settingsIsError,
17-
error: settingsError,
18-
data: userSettingsData
19-
} = useSingleUserSettings(user.userId);
20-
const {
21-
isLoading: secureSettingsIsLoading,
22-
isError: secureSettingsIsError,
23-
error: secureSettingsError,
24-
data: userSecureSettings
25-
} = useCurrentUserSecureSettings();
2614
const { isLoading: allTeamsIsLoading, isError: allTeamsIsError, data: teams, error: allTeamsError } = useAllTeams();
2715

28-
if (secureSettingsIsError) return <ErrorPage error={secureSettingsError} message={secureSettingsError.message} />;
29-
if (settingsIsError) return <ErrorPage error={settingsError} message={settingsError.message} />;
3016
if (allTeamsIsError) return <ErrorPage error={allTeamsError} message={allTeamsError.message} />;
31-
if (
32-
auth.isLoading ||
33-
!auth.user ||
34-
settingsIsLoading ||
35-
!userSettingsData ||
36-
secureSettingsIsLoading ||
37-
!userSecureSettings ||
38-
allTeamsIsLoading ||
39-
!teams
40-
)
41-
return <LoadingIndicator />;
17+
if (auth.isLoading || !auth.user || allTeamsIsLoading || !teams) return <LoadingIndicator />;
4218

4319
const userTeams = teams.filter((team) => isUserOnTeam(team, user));
4420

0 commit comments

Comments
 (0)