diff --git a/src/applications/_mock-form-ae-design-patterns/hooks/useLocalStorage.js b/src/applications/_mock-form-ae-design-patterns/hooks/useLocalStorage.js
index 810859636ea8..fd86dbbfa505 100644
--- a/src/applications/_mock-form-ae-design-patterns/hooks/useLocalStorage.js
+++ b/src/applications/_mock-form-ae-design-patterns/hooks/useLocalStorage.js
@@ -1,5 +1,4 @@
import { useState, useEffect } from 'react';
-
/**
* useLocalStorage is a hook that provides a way to store and retrieve values from localStorage
* @param {string} key - The key to store the value under
@@ -11,10 +10,17 @@ export const useLocalStorage = (key, defaultValue) => {
let currentValue;
try {
- currentValue = JSON.parse(
- localStorage.getItem(key) || String(defaultValue),
- );
+ const item = localStorage.getItem(key);
+ if (item === null) {
+ currentValue = defaultValue;
+ } else if (item.startsWith('{') || item.startsWith('[')) {
+ currentValue = JSON.parse(item);
+ } else {
+ currentValue = item;
+ }
} catch (error) {
+ // eslint-disable-next-line no-console
+ console.error('Error getting value from localStorage', error);
currentValue = defaultValue;
}
@@ -30,6 +36,7 @@ export const useLocalStorage = (key, defaultValue) => {
const clearValue = () => {
localStorage.removeItem(key);
+ setValue(defaultValue);
};
return [value, setValue, clearValue];
diff --git a/src/applications/_mock-form-ae-design-patterns/hooks/useMockedLogin.js b/src/applications/_mock-form-ae-design-patterns/hooks/useMockedLogin.js
index db016ed8a8e9..6c0c6cfff355 100644
--- a/src/applications/_mock-form-ae-design-patterns/hooks/useMockedLogin.js
+++ b/src/applications/_mock-form-ae-design-patterns/hooks/useMockedLogin.js
@@ -1,37 +1,51 @@
-import { useEffect } from 'react';
-import { useDispatch } from 'react-redux';
+import { useEffect, useMemo } from 'react';
+import { useDispatch, useSelector } from 'react-redux';
import { teardownProfileSession } from 'platform/user/profile/utilities';
import { updateLoggedInStatus } from 'platform/user/authentication/actions';
import { useLocalStorage } from './useLocalStorage';
export const useMockedLogin = () => {
- const [, setHasSession] = useLocalStorage('hasSession', '');
+ const [
+ localHasSession,
+ setLocalHasSession,
+ clearLocalHasSession,
+ ] = useLocalStorage('hasSession', '');
+
+ const loggedInFromState = useSelector(
+ state => state?.user?.login?.currentlyLoggedIn,
+ );
+
+ const loggedIn = useMemo(
+ () => localHasSession === 'true' || loggedInFromState,
+ [localHasSession, loggedInFromState],
+ );
+
const dispatch = useDispatch();
const logIn = () => {
- setHasSession('true');
+ setLocalHasSession('true');
dispatch(updateLoggedInStatus(true));
};
const logOut = () => {
teardownProfileSession();
dispatch(updateLoggedInStatus(false));
- setHasSession('');
+ clearLocalHasSession();
};
const useLoggedInQuery = location => {
useEffect(
() => {
if (location?.query?.loggedIn === 'true') {
- setHasSession('true');
+ setLocalHasSession('true');
dispatch(updateLoggedInStatus(true));
}
if (location?.query?.loggedIn === 'false') {
teardownProfileSession();
dispatch(updateLoggedInStatus(false));
- setHasSession('');
+ clearLocalHasSession();
}
// having the pollTimeout present triggers some api calls to be made locally and in codespaces
@@ -43,5 +57,5 @@ export const useMockedLogin = () => {
);
};
- return { logIn, logOut, useLoggedInQuery };
+ return { logIn, logOut, useLoggedInQuery, loggedIn };
};
diff --git a/src/applications/_mock-form-ae-design-patterns/mocks/endpoints/in-progress-forms/22-1990.js b/src/applications/_mock-form-ae-design-patterns/mocks/endpoints/in-progress-forms/22-1990.js
index 3ba89f4f564f..ed27973d8926 100644
--- a/src/applications/_mock-form-ae-design-patterns/mocks/endpoints/in-progress-forms/22-1990.js
+++ b/src/applications/_mock-form-ae-design-patterns/mocks/endpoints/in-progress-forms/22-1990.js
@@ -18,7 +18,7 @@ const response = {
street: USER.MAILING_ADDRESS.ADDRESS_LINE1,
city: USER.MAILING_ADDRESS.CITY,
state: USER.MAILING_ADDRESS.STATE_CODE,
- country: USER.MAILING_ADDRESS.COUNTRY_CODE_ISO2,
+ country: USER.MAILING_ADDRESS.COUNTRY_CODE_ISO3,
postalCode: USER.MAILING_ADDRESS.ZIP_CODE,
isMilitary: false,
},
diff --git a/src/applications/_mock-form-ae-design-patterns/mocks/endpoints/in-progress-forms/26-1880.js b/src/applications/_mock-form-ae-design-patterns/mocks/endpoints/in-progress-forms/26-1880.js
index 51d26fb2e097..e9f49c9e0356 100644
--- a/src/applications/_mock-form-ae-design-patterns/mocks/endpoints/in-progress-forms/26-1880.js
+++ b/src/applications/_mock-form-ae-design-patterns/mocks/endpoints/in-progress-forms/26-1880.js
@@ -8,7 +8,7 @@ const response = {
street: USER.MAILING_ADDRESS.ADDRESS_LINE1,
city: USER.MAILING_ADDRESS.CITY,
state: USER.MAILING_ADDRESS.STATE_CODE,
- country: USER.MAILING_ADDRESS.COUNTRY_CODE_ISO2,
+ country: USER.MAILING_ADDRESS.COUNTRY_CODE_ISO3,
postalCode: USER.MAILING_ADDRESS.ZIP_CODE,
},
contactPhone: `${USER.HOME_PHONE.AREA_CODE}${USER.HOME_PHONE.PHONE_NUMBER}`,
diff --git a/src/applications/_mock-form-ae-design-patterns/mocks/server.js b/src/applications/_mock-form-ae-design-patterns/mocks/server.js
index 673b05df5270..d2f138bfe2bc 100644
--- a/src/applications/_mock-form-ae-design-patterns/mocks/server.js
+++ b/src/applications/_mock-form-ae-design-patterns/mocks/server.js
@@ -47,8 +47,8 @@ const responses = {
res.json(
generateFeatureToggles({
aedpVADX: true,
- coeAccess: true,
- profileUseExperimental: true,
+ coeAccess: false,
+ profileUseExperimental: false,
}),
),
secondsOfDelay,
diff --git a/src/applications/_mock-form-ae-design-patterns/patterns/pattern2/TaskBlue/ProfileInformationEditView.jsx b/src/applications/_mock-form-ae-design-patterns/patterns/pattern2/TaskBlue/ProfileInformationEditView.jsx
index 88b5281d5a73..edfa1bc9a2c4 100644
--- a/src/applications/_mock-form-ae-design-patterns/patterns/pattern2/TaskBlue/ProfileInformationEditView.jsx
+++ b/src/applications/_mock-form-ae-design-patterns/patterns/pattern2/TaskBlue/ProfileInformationEditView.jsx
@@ -346,7 +346,7 @@ export class ProfileInformationEditView extends Component {
VADX Plugin
-- Pattern 1 -
-- Pattern 2 -
+VADX Plugin Example
+
-
-
- Is your api running at {environment.API_URL}? -
-Form Structure
+No data available
; + } + + // Recursively check if an object has any defined values + const hasDefinedValues = obj => { + if (!obj || typeof obj !== 'object') { + return obj !== undefined; + } + + return Object.values(obj).some(value => { + if (value && typeof value === 'object') { + return hasDefinedValues(value); + } + return value !== undefined; + }); + }; + + const renderValue = (key, value) => { + // Skip undefined values + if (value === undefined) { + return null; + } + + // Skip objects with no defined values + if (value && typeof value === 'object' && !hasDefinedValues(value)) { + return null; + } + + switch (typeof value) { + case 'boolean': + return ( ++ {key} +
++ No form data entered yet +
+Active element:
+
+
+
+ Heading Hierarchy
{analysis?.issues?.length > 0 ? (
-
- Heading Issues Found ({analysis.issues.length})
+
+ Issues Found ({analysis.issues.length})
) : (
@@ -94,9 +95,6 @@ const HeadingHierarchyInspectorBase = ({ location }) => {
)}
- Heading Hierarchy
-
+