Skip to content

Commit 922effb

Browse files
#1487: separated interfaces and adjusted ModalContainer values
1 parent a765eb8 commit 922effb

4 files changed

Lines changed: 25 additions & 39 deletions

File tree

src/frontend/src/hooks/change-requests.hooks.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,25 @@ export const useCreateStandardChangeRequest = () => {
111111
);
112112
};
113113

114-
export interface ChangeRequestPayload {
114+
export interface CreateActivationChangeRequestPayload {
115115
submitterId: number;
116116
wbsNum: WbsNumber;
117117
projectLeadId: number;
118118
projectManagerId: number;
119119
startDate: string;
120120
confirmDetails: boolean;
121+
type: string;
122+
}
123+
124+
export interface CreateStageGateChangeRequestPayload {
125+
submitterId: number;
126+
wbsNum: WbsNumber;
121127
confirmDone: boolean;
128+
type: string;
129+
}
130+
131+
export interface CreateProposeSolutionPayload {
132+
submitterId: number;
122133
crId: number;
123134
description: string;
124135
scopeImpact: string;
@@ -131,9 +142,9 @@ export interface ChangeRequestPayload {
131142
* Custom React Hook to create an activation change request.
132143
*/
133144
export const useCreateActivationChangeRequest = () => {
134-
return useMutation<{ message: string }, Error, ChangeRequestPayload>(
145+
return useMutation<{ message: string }, Error, CreateActivationChangeRequestPayload>(
135146
['change requests', 'create', 'activation'],
136-
async (payload: ChangeRequestPayload) => {
147+
async (payload: CreateActivationChangeRequestPayload) => {
137148
const { data } = await createActivationChangeRequest(
138149
payload.submitterId,
139150
payload.wbsNum,
@@ -151,9 +162,9 @@ export const useCreateActivationChangeRequest = () => {
151162
* Custom React Hook to create a stage gate change request.
152163
*/
153164
export const useCreateStageGateChangeRequest = () => {
154-
return useMutation<{ message: string }, Error, ChangeRequestPayload>(
165+
return useMutation<{ message: string }, Error, CreateStageGateChangeRequestPayload>(
155166
['change requests', 'create', 'stage gate'],
156-
async (payload: ChangeRequestPayload) => {
167+
async (payload: CreateStageGateChangeRequestPayload) => {
157168
const { data } = await createStageGateChangeRequest(payload.submitterId, payload.wbsNum, payload.confirmDone);
158169
return data;
159170
}
@@ -165,9 +176,9 @@ export const useCreateStageGateChangeRequest = () => {
165176
*/
166177
export const useCreateProposeSolution = () => {
167178
const queryClient = useQueryClient();
168-
return useMutation<{ message: string }, Error, ChangeRequestPayload>(
179+
return useMutation<{ message: string }, Error, CreateProposeSolutionPayload>(
169180
['change requests', 'create', 'propose solution'],
170-
async (payload: ChangeRequestPayload) => {
181+
async (payload: CreateProposeSolutionPayload) => {
171182
const { data } = await addProposedSolution(
172183
payload.submitterId,
173184
payload.crId,

src/frontend/src/pages/ChangeRequestDetailPage/ProposedSolutionsList.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,6 @@ const ProposedSolutionsList: React.FC<ProposedSolutionsListProps> = ({ proposedS
4848
scopeImpact,
4949
timelineImpact,
5050
budgetImpact,
51-
wbsNum: {
52-
carNumber: 0,
53-
projectNumber: 0,
54-
workPackageNumber: 0
55-
},
56-
projectLeadId: 0,
57-
projectManagerId: 0,
58-
startDate: '',
59-
confirmDetails: false,
60-
confirmDone: false,
6151
type: ''
6252
});
6353
} catch (e) {

src/frontend/src/pages/WorkPackageDetailPage/ActivateWorkPackageModalContainer/ActivateWorkPackageModalContainer.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { useHistory } from 'react-router-dom';
77
import { ChangeRequestType, isGuest, WbsNumber } from 'shared';
88
import { useAuth } from '../../../hooks/auth.hooks';
9-
import { ChangeRequestPayload, useCreateActivationChangeRequest } from '../../../hooks/change-requests.hooks';
9+
import { useCreateActivationChangeRequest } from '../../../hooks/change-requests.hooks';
1010
import { useAllUsers } from '../../../hooks/users.hooks';
1111
import { routes } from '../../../utils/routes';
1212
import ErrorPage from '../../ErrorPage';
@@ -46,17 +46,11 @@ const ActivateWorkPackageModalContainer: React.FC<ActivateWorkPackageModalContai
4646
submitterId: auth.user?.userId,
4747
wbsNum,
4848
type: ChangeRequestType.Activation,
49-
projectLeadId: 0,
50-
projectManagerId: 0,
51-
startDate: '',
52-
confirmDetails,
53-
confirmDone: false,
54-
crId: 0,
55-
description: '',
56-
scopeImpact: '',
57-
timelineImpact: 0,
58-
budgetImpact: 0
59-
} as ChangeRequestPayload);
49+
projectLeadId: projectLeadId || 0,
50+
projectManagerId: projectManagerId || 0,
51+
startDate: startDate.toISOString(),
52+
confirmDetails
53+
});
6054
history.push(routes.CHANGE_REQUESTS);
6155
} catch (e: unknown) {
6256
if (e instanceof Error) {

src/frontend/src/pages/WorkPackageDetailPage/StageGateWorkPackageModalContainer/StageGateWorkPackageModalContainer.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,7 @@ const StageGateWorkPackageModalContainer: React.FC<StageGateWorkPackageModalCont
4141
submitterId: auth.user?.userId,
4242
wbsNum,
4343
type: ChangeRequestType.StageGate,
44-
confirmDone,
45-
projectLeadId: 0,
46-
projectManagerId: 0,
47-
startDate: '',
48-
confirmDetails: false,
49-
crId: 0,
50-
description: '',
51-
scopeImpact: '',
52-
timelineImpact: 0,
53-
budgetImpact: 0
44+
confirmDone
5445
});
5546
history.push(routes.CHANGE_REQUESTS);
5647
} catch (e: unknown) {

0 commit comments

Comments
 (0)