Skip to content

Commit e12c2ba

Browse files
authored
Merge pull request #5436 from raft-tech/5418-refresh-df-pages
Refresh Tolerant Data File Pages
2 parents 08002bd + 386ed3c commit e12c2ba

File tree

8 files changed

+69
-22
lines changed

8 files changed

+69
-22
lines changed

tdrs-frontend/src/components/FileUploadForms/QuarterFileUploadForm.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react'
21
import classNames from 'classnames'
32
import Button from '../Button'
43
import FileUpload from '../FileUpload'

tdrs-frontend/src/components/FileUploadForms/QuarterFileUploadForm.test.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import React from 'react'
21
import { fireEvent, waitFor, render } from '@testing-library/react'
32
import { Provider } from 'react-redux'
43
import configureStore from '../../configureStore'
54
import QuarterFileUploadForm from './QuarterFileUploadForm'
65
import { ReportsProvider } from '../Reports/ReportsContext'
7-
import * as reportsActions from '../../actions/reports'
86
import { useFormSubmission } from '../../hooks/useFormSubmission'
97
import { useEventLogger } from '../../utils/eventLogger'
8+
import { MemoryRouter } from 'react-router-dom'
109

1110
// Mock dependencies
1211
jest.mock('../../hooks/useFormSubmission')
@@ -91,9 +90,11 @@ describe('QuarterFileUploadForm', () => {
9190

9291
return render(
9392
<Provider store={store}>
94-
<ReportsProvider>
95-
<QuarterFileUploadForm stt={stt} />
96-
</ReportsProvider>
93+
<MemoryRouter>
94+
<ReportsProvider>
95+
<QuarterFileUploadForm stt={stt} />
96+
</ReportsProvider>
97+
</MemoryRouter>
9798
</Provider>
9899
)
99100
}

tdrs-frontend/src/components/FileUploadForms/SectionFileUploadForm.test.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import SectionFileUploadForm from './SectionFileUploadForm'
66
import { ReportsProvider } from '../Reports/ReportsContext'
77
import { useFormSubmission } from '../../hooks/useFormSubmission'
88
import { useEventLogger } from '../../utils/eventLogger'
9+
import { MemoryRouter } from 'react-router-dom'
910

1011
// Mock dependencies
1112
jest.mock('../../hooks/useFormSubmission')
@@ -100,9 +101,11 @@ describe('SectionFileUploadForm', () => {
100101

101102
return render(
102103
<Provider store={store}>
103-
<ReportsProvider>
104-
<SectionFileUploadForm stt={stt} />
105-
</ReportsProvider>
104+
<MemoryRouter>
105+
<ReportsProvider>
106+
<SectionFileUploadForm stt={stt} />
107+
</ReportsProvider>
108+
</MemoryRouter>
106109
</Provider>
107110
)
108111
}

tdrs-frontend/src/components/Reports/FRAReports.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,8 @@ const FRAReportsContent = () => {
567567
(needsSttSelection ? !!currentStt : !!userProfileStt) &&
568568
!!fileTypeInputValue &&
569569
!!yearInputValue &&
570-
!!quarterInputValue
570+
!!quarterInputValue &&
571+
!!stt
571572

572573
// Automatically fetch submission history when all fields are filled
573574
useEffect(() => {

tdrs-frontend/src/components/Reports/FRAReports.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import React from 'react'
22
import { fireEvent, waitFor, render, within } from '@testing-library/react'
33
import axios from 'axios'
44
import { Provider } from 'react-redux'
5+
import { MemoryRouter } from 'react-router-dom'
56
import { FRAReports } from '.'
67
import configureStore from '../../configureStore'
7-
import { MemoryRouter } from 'react-router-dom'
88

99
const initialState = {
1010
auth: {

tdrs-frontend/src/components/Reports/Reports.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import React from 'react'
22
import { render, screen, fireEvent, waitFor } from '@testing-library/react'
33

44
import { Provider } from 'react-redux'
5+
import { MemoryRouter } from 'react-router-dom'
56
import { thunk } from 'redux-thunk'
67
import configureStore from 'redux-mock-store'
78
import appConfigureStore from '../../configureStore'
89
import Reports from './Reports'
910
import { SET_FILE, upload } from '../../actions/reports'
10-
import { MemoryRouter } from 'react-router-dom'
1111

1212
describe('Reports', () => {
1313
let originalScrollIntoView

tdrs-frontend/src/components/Reports/ReportsContext.jsx

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/* istanbul ignore file */
2-
import React, { createContext, useContext, useState, useRef } from 'react'
2+
import { createContext, useContext, useState, useRef, useEffect } from 'react'
33
import { useDispatch, useSelector } from 'react-redux'
44
import {
55
clearFileList,
66
reinitializeSubmittedFiles,
77
setStt,
88
} from '../../actions/reports'
99
import { openFeedbackWidget } from '../../reducers/feedbackWidget'
10+
import { useSearchParams } from 'react-router-dom'
1011
import { accountCanSelectStt } from '../../selectors/auth'
1112

1213
const ReportsContext = createContext()
@@ -23,18 +24,63 @@ export const ReportsProvider = ({ isFra = false, children }) => {
2324
const dispatch = useDispatch()
2425
const canSelectStt = useSelector(accountCanSelectStt)
2526

27+
// Search params
28+
const [searchParams, setSearchParams] = useSearchParams()
29+
2630
// Form state
27-
const [yearInputValue, setYearInputValue] = useState('')
28-
const [quarterInputValue, setQuarterInputValue] = useState('')
31+
const [yearInputValue, setYearInputValue] = useState(
32+
searchParams.get('fy') || ''
33+
)
34+
const [quarterInputValue, setQuarterInputValue] = useState(
35+
searchParams.get('q') || ''
36+
)
2937
const [fileTypeInputValue, setFileTypeInputValue] = useState(
30-
isFra ? 'workOutcomesOfTanfExiters' : 'tanf'
38+
searchParams.get('type')
39+
? searchParams.get('type')
40+
: isFra
41+
? 'workOutcomesOfTanfExiters'
42+
: 'tanf'
43+
)
44+
const [sttInputValue, setSttInputValue] = useState(
45+
searchParams.get('stt') || ''
46+
)
47+
48+
const [selectedSubmissionTab, setSelectedSubmissionTab] = useState(
49+
parseInt(searchParams.get('tab')) || 1
3150
)
32-
const [sttInputValue, setSttInputValue] = useState('')
51+
3352
const [pendingChange, setPendingChange] = useState({
3453
type: null,
3554
value: null,
3655
})
3756

57+
useEffect(() => {
58+
const newParams = new URLSearchParams()
59+
if (yearInputValue) {
60+
newParams.set('fy', yearInputValue)
61+
}
62+
if (quarterInputValue) {
63+
newParams.set('q', quarterInputValue)
64+
}
65+
if (fileTypeInputValue) {
66+
newParams.set('type', fileTypeInputValue)
67+
}
68+
if (sttInputValue) {
69+
newParams.set('stt', sttInputValue)
70+
}
71+
if (selectedSubmissionTab) {
72+
newParams.set('tab', selectedSubmissionTab)
73+
}
74+
setSearchParams(newParams)
75+
}, [
76+
yearInputValue,
77+
quarterInputValue,
78+
fileTypeInputValue,
79+
sttInputValue,
80+
selectedSubmissionTab,
81+
setSearchParams,
82+
])
83+
3884
// Touched state for validation
3985
const [yearTouched, setYearTouched] = useState(false)
4086
const [quarterTouched, setQuarterTouched] = useState(false)
@@ -58,9 +104,6 @@ export const ReportsProvider = ({ isFra = false, children }) => {
58104
message: null,
59105
})
60106

61-
// Tab state
62-
const [selectedSubmissionTab, setSelectedSubmissionTab] = useState(1)
63-
64107
// Refs
65108
const headerRef = useRef(null)
66109
const alertRef = useRef(null)

tdrs-frontend/src/components/Routes/Routes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const AppRoutes = () => {
6060
/>
6161
<Route
6262
exact
63-
path="/data-files"
63+
path="/data-files/:fy?/:q?/:type?/:stt?/:tab?"
6464
element={
6565
<PrivateRoute
6666
title="TANF Data Files"
@@ -74,7 +74,7 @@ const AppRoutes = () => {
7474
/>
7575
<Route
7676
exact
77-
path="/fra-data-files"
77+
path="/fra-data-files/:fy?/:q?/:type?/:stt?/:tab?"
7878
element={
7979
<PrivateRoute
8080
title="FRA Data Files"

0 commit comments

Comments
 (0)