Skip to content

Commit

Permalink
Add pension module routes to use flipper flag. (#30524)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottsdevelopment committed Jul 11, 2024
1 parent 387c610 commit f3609ce
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/applications/pensions/PensionsApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import { useFeatureToggle } from 'platform/utilities/feature-toggles';
import formConfig from './config/form';
import { NoFormPage } from './components/NoFormPage';
import { useBrowserMonitoring } from './hooks/useBrowserMonitoring';
import { submit } from './config/submit';

export default function PensionEntry({ location, children }) {
const { useToggleValue, TOGGLE_NAMES } = useFeatureToggle();
const pensionFormEnabled = useToggleValue(TOGGLE_NAMES.pensionFormEnabled);
const pensionModuleEnabled = useToggleValue(
TOGGLE_NAMES.pensionModuleEnabled,
);
const isLoadingFeatures = useSelector(
state => state?.featureToggles?.loading,
);
Expand All @@ -32,6 +36,10 @@ export default function PensionEntry({ location, children }) {
return <NoFormPage />;
}

if (pensionModuleEnabled) {
formConfig.submit = (f, fc) => submit(f, fc, 'pensions/v0/pension_claims');
}

return (
<RoutedSavableApp formConfig={formConfig} currentLocation={location}>
{children}
Expand Down
4 changes: 2 additions & 2 deletions src/applications/pensions/config/submit.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ export function transform(formConfig, form) {
});
}

export function submit(form, formConfig) {
export function submit(form, formConfig, apiPath = '/v0/pension_claims') {
const headers = { 'Content-Type': 'application/json' };
const body = transform(formConfig, form);

return apiRequest(`${environment.API_URL}/v0/pension_claims`, {
return apiRequest(`${environment.API_URL}${apiPath}`, {
body,
headers,
method: 'POST',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
"pdfWarningBanner": "pdf_warning_banner",
"pensionFormEnabled": "pension_form_enabled",
"pensionsBrowserMonitoringEnabled": "pension_browser_monitoring_enabled",
"pensionModuleEnabled": "pension_module_enabled",
"preEntryCovid19Screener": "pre_entry_covid19_screener",
"profileContacts": "profile_contacts",
"profileDoNotRequireInternationalZipCode": "profile_do_not_require_international_zip_code",
Expand Down

0 comments on commit f3609ce

Please sign in to comment.