Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-mereuta committed Dec 2, 2024
1 parent a84343c commit 802fcdb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ const useUserInterfaceSelector = () => {
() => userInterfaces.map((item) => ({ label: item.name, value: item.id })),
[userInterfaces],
);
const validUserInterfaceForTemplate = userInterfaces.find(
(item) => item.id === sessionStorage.getItem(SESSION_USER_INTEFACE_ID_KEY),
)?.id;

const selectedUserInterface =
validUserInterfaceForTemplate || selectedUserInterfaceId || userInterfaces.find((item) => item.default)?.id;
const selectedUserInterface = selectedUserInterfaceId || userInterfaces.find((item) => item.default)?.id;

const navbarItem = useMemo(
() => ({
Expand Down
7 changes: 7 additions & 0 deletions src/contexts/UiConfigContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
defaultOutputSettings,
defaultUiOptions,
} from '../types/types';
import { SESSION_USER_INTEFACE_ID_KEY } from '../utils/constants';

export const UiConfigContextDefaultValues: IUiConfigContext = {
uiOptions: defaultUiOptions,
Expand Down Expand Up @@ -70,6 +71,12 @@ export function UiConfigContextProvider({
if (projectConfig.onFetchUserInterfaces) {
projectConfig.onFetchUserInterfaces().then((res) => {
setUserInterfaces(res?.data?.data || []);
if (res?.data?.data) {
const validUserInterfaceForTemplate = res?.data?.data.find(
(item) => item.id === sessionStorage.getItem(SESSION_USER_INTEFACE_ID_KEY),
)?.id;
setSelectedUserInterfaceId(validUserInterfaceForTemplate || null);
}
});
}
}, [projectConfig]);
Expand Down

0 comments on commit 802fcdb

Please sign in to comment.