44 useState ,
55} from 'react' ;
66import {
7+ Button ,
78 Container ,
89 Grid ,
910 SelectInput ,
@@ -29,11 +30,14 @@ import {
2930} from '@togglecorp/fujs' ;
3031
3132import Link from '#components/Link' ;
33+ import useAlert from '#hooks/useAlert' ;
3234import useGlobalEnums from '#hooks/domain/useGlobalEnums' ;
3335import useFilterState from '#hooks/useFilterState' ;
3436import { joinStrings } from '#utils/common' ;
37+ import { api } from '#config' ;
3538import {
3639 type GoApiResponse ,
40+ useLazyRequest ,
3741 useRequest ,
3842} from '#utils/restRequest' ;
3943
@@ -72,6 +76,8 @@ function EmergencyResponseUnitReadiness() {
7276 filter : { } ,
7377 } ) ;
7478
79+ const alert = useAlert ( ) ;
80+
7581 const {
7682 error : eruOwnersError ,
7783 response : eruOwnersResponse ,
@@ -93,6 +99,12 @@ function EmergencyResponseUnitReadiness() {
9399 eru_type : filter . selectEruTypes ,
94100 eru_owner : filter . selectEruOwner ,
95101 } ,
102+ onFailure : ( ) => {
103+ alert . show (
104+ strings . fetchEruReadinessFailed ,
105+ { variant : 'danger' } ,
106+ ) ;
107+ } ,
96108 } ) ;
97109
98110 const {
@@ -107,8 +119,32 @@ function EmergencyResponseUnitReadiness() {
107119 type : filter . selectEruTypes ,
108120 eru_owner : filter . selectEruOwner ,
109121 } ,
122+ onFailure : ( ) => {
123+ alert . show (
124+ strings . fetchEruReadinessFailed ,
125+ { variant : 'danger' } ,
126+ ) ;
127+ } ,
128+ } ) ;
129+
130+ const {
131+ pending : eruReadinessExportPending ,
132+ trigger : triggerEruReadinessExport ,
133+ } = useLazyRequest ( {
134+ method : 'GET' ,
135+ url : '/api/v2/export-eru-readiness' ,
136+ onFailure : ( ) => {
137+ alert . show (
138+ strings . exportEruReadinessFailed ,
139+ { variant : 'danger' } ,
140+ ) ;
141+ } ,
110142 } ) ;
111143
144+ const handleEruReadinessExport = ( ) => {
145+ triggerEruReadinessExport ( null ) ;
146+ } ;
147+
112148 const {
113149 deployments_eru_type : deploymentEruType ,
114150 } = useGlobalEnums ( ) ;
@@ -173,12 +209,21 @@ function EmergencyResponseUnitReadiness() {
173209 ) }
174210 withHeaderBorder
175211 actions = { (
176- < Link
177- to = "eruReadinessForm"
178- variant = "primary"
179- >
180- { strings . eruReadinessUpdateButton }
181- </ Link >
212+ < >
213+ < Link
214+ href = { `${ api } /api/v2/export-eru-readiness` }
215+ variant = "secondary"
216+ external
217+ >
218+ { strings . exportEruReadiness }
219+ </ Link >
220+ < Link
221+ to = "eruReadinessForm"
222+ variant = "primary"
223+ >
224+ { strings . eruReadinessUpdateButton }
225+ </ Link >
226+ </ >
182227 ) }
183228 contentViewType = "vertical"
184229 filters = { (
@@ -238,7 +283,7 @@ function EmergencyResponseUnitReadiness() {
238283 />
239284 </ TabPanel >
240285 </ Container >
241- </ Tabs >
286+ </ Tabs >
242287 ) ;
243288}
244289
0 commit comments