Skip to content

Commit

Permalink
Fix Travel Section fields not being repopulated (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
mzhou08 authored Jan 3, 2025
1 parent 380d949 commit 8806638
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/components/form/ApplicationForm/ConsentSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ const ConsentSection = ({

useEffect(() => {
if (fetchedProfile) {
console.log(consentFields);

setTartanhacksCodeOfConduct(consentFields.tartanHacksCodeOfConductAcknowledgement);
setMediaRelease(consentFields.tartanHacksMediaReleaseAcknowledgement);
setSignature(consentFields.tartanHacksMediaReleaseSignature);
Expand Down
17 changes: 16 additions & 1 deletion src/components/form/ApplicationForm/TravelSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import React, {
useEffect,
useState,
} from 'react';
import { useDispatch } from 'react-redux';
import { useDispatch, useSelector } from 'react-redux';
import actions from 'src/actions';
import { TravelFields } from 'types/ApplicationForm';
import { RootState } from 'types/RootState';
import styles from './index.module.scss';

const TravelSection = ({
Expand All @@ -28,6 +29,12 @@ const TravelSection = ({
}): ReactElement => {
const dispatch = useDispatch();

const fetchedProfile = useSelector(
(state: RootState) => state?.application?.fetchedProfile,
);
const travelFields =
useSelector((state: RootState) => state?.application?.travel) ?? {};

const [wantsTravelReimbursement, setWantsTravelReimbursement] = useState<boolean>(false);
const [travelDetails, setTravelDetails] = useState<string>('');

Expand Down Expand Up @@ -57,6 +64,14 @@ const TravelSection = ({
// eslint-disable-next-line
}, [validate]);

useEffect(() => {
if (fetchedProfile) {
setWantsTravelReimbursement(travelFields.wantsTravelReimbursement);
setTravelDetails(travelFields.travelDetails ?? "");
}
// eslint-disable-next-line
}, [fetchedProfile]);

const maxChars = 100;

return (
Expand Down

0 comments on commit 8806638

Please sign in to comment.