Skip to content

Commit 7654e45

Browse files
authored
Merge pull request #1741 from Northeastern-Electric-Racing/#1738-wrong-cr-populating-bug
#1738 - CR correctly auto-populates on WP/Project forms now
2 parents 3a5b06a + 291034c commit 7654e45

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/frontend/src/pages/ProjectDetailPage/ProjectForm/ProjectCreateContainer.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,13 @@ import { routes } from '../../../utils/routes';
1414
import { getRequiredLinkTypeNames } from '../../../utils/link.utils';
1515
import ErrorPage from '../../ErrorPage';
1616
import LoadingIndicator from '../../../components/LoadingIndicator';
17+
import { useQuery } from '../../../hooks/utils.hooks';
1718

1819
const ProjectCreateContainer: React.FC = () => {
1920
const toast = useToast();
2021
const history = useHistory();
22+
const query = useQuery();
2123

22-
//const links: { linkId: string; url: string; linkTypeName: string }[] = [];
23-
//const goals: { bulletId: number; detail: string }[] = [];
24-
//const features: { bulletId: number; detail: string }[] = [];
25-
//const rules: { bulletId: number; detail: string }[] = [];
26-
//const constraints: { bulletId: number; detail: string }[] = [];
2724
const [projectManagerId, setProjectManagerId] = useState<string | undefined>();
2825
const [projectLeadId, setProjectLeadId] = useState<string | undefined>();
2926

@@ -48,7 +45,7 @@ const ProjectCreateContainer: React.FC = () => {
4845
teamId: String(),
4946
carNumber: 0,
5047
links: [],
51-
crId: 0,
48+
crId: query.get('crId') || '',
5249
goals: [],
5350
features: [],
5451
constraints: [],
@@ -67,7 +64,7 @@ const ProjectCreateContainer: React.FC = () => {
6764

6865
try {
6966
const payload: CreateSingleProjectPayload = {
70-
crId,
67+
crId: Number(crId),
7168
name,
7269
carNumber,
7370
summary,

src/frontend/src/pages/ProjectDetailPage/ProjectForm/ProjectEditContainer.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { ProjectFormInput } from './ProjectForm';
1414
import LoadingIndicator from '../../../components/LoadingIndicator';
1515
import ErrorPage from '../../ErrorPage';
1616
import { getRequiredLinkTypeNames } from '../../../utils/link.utils';
17+
import { useQuery } from '../../../hooks/utils.hooks';
1718

1819
interface ProjectEditContainerProps {
1920
project: Project;
@@ -22,6 +23,7 @@ interface ProjectEditContainerProps {
2223

2324
const ProjectEditContainer: React.FC<ProjectEditContainerProps> = ({ project, exitEditMode }) => {
2425
const toast = useToast();
26+
const query = useQuery();
2527

2628
const { name, budget, summary } = project;
2729
const [projectManagerId, setProjectManagerId] = useState<string | undefined>(project.projectManager?.userId.toString());
@@ -30,7 +32,6 @@ const ProjectEditContainer: React.FC<ProjectEditContainerProps> = ({ project, ex
3032
const features = bulletsToObject(project.features);
3133
const constraints = bulletsToObject(project.otherConstraints);
3234
const rules = rulesToObject(project.rules);
33-
const crId = project.changes[0].changeRequestId;
3435

3536
const { mutateAsync, isLoading } = useEditSingleProject(project.wbsNum);
3637
const {
@@ -74,7 +75,7 @@ const ProjectEditContainer: React.FC<ProjectEditContainerProps> = ({ project, ex
7475
teamId: '',
7576
carNumber: 0,
7677
links,
77-
crId,
78+
crId: query.get('crId') || project.changes[0].changeRequestId.toString(),
7879
goals,
7980
features,
8081
constraints,
@@ -99,7 +100,7 @@ const ProjectEditContainer: React.FC<ProjectEditContainerProps> = ({ project, ex
99100
summary,
100101
links,
101102
projectId: project.id,
102-
crId,
103+
crId: Number(crId),
103104
rules,
104105
goals,
105106
features,

src/frontend/src/pages/ProjectDetailPage/ProjectForm/ProjectForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export interface ProjectFormInput {
2424
budget: number;
2525
summary: string;
2626
links: LinkCreateArgs[];
27-
crId: number;
27+
crId: string;
2828
carNumber: number;
2929
goals: {
3030
bulletId: number;

src/frontend/src/pages/WorkPackageForm/WorkPackageForm.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import LoadingIndicator from '../../components/LoadingIndicator';
77
import ErrorPage from '../ErrorPage';
88
import { useAllUsers } from '../../hooks/users.hooks';
99
import { useSingleProject } from '../../hooks/projects.hooks';
10+
import { useQuery } from '../../hooks/utils.hooks';
1011

1112
interface WorkPackageFormProps {
1213
wbsNum: WbsNumber;
@@ -25,6 +26,7 @@ const WorkPackageForm: React.FC<WorkPackageFormProps> = ({ wbsNum, mutateAsync,
2526
error: projectError
2627
} = useSingleProject({ ...wbsNum, workPackageNumber: 0 });
2728
const { data: workPackages, isLoading: wpIsLoading, isError: wpIsError, error: wpError } = useAllWorkPackages();
29+
const query = useQuery();
2830

2931
if (wpIsLoading || !workPackages || usersIsLoading || !users || projectIsLoading || !project) return <LoadingIndicator />;
3032
if (usersIsError) return <ErrorPage message={usersError.message} />;
@@ -43,7 +45,7 @@ const WorkPackageForm: React.FC<WorkPackageFormProps> = ({ wbsNum, mutateAsync,
4345
? {
4446
...workPackage,
4547
workPackageId: workPackage.id,
46-
crId: workPackage!.changes[0].changeRequestId.toString(),
48+
crId: query.get('crId') || workPackage!.changes[0].changeRequestId.toString(),
4749
stage: workPackage!.stage ?? 'NONE',
4850
blockedBy: workPackage!.blockedBy.map(wbsPipe),
4951
expectedActivities: bulletsToObject(workPackage!.expectedActivities),

0 commit comments

Comments
 (0)