Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
BearHanded committed Jul 5, 2024
1 parent 3e2416b commit e43df7e
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 67 deletions.
37 changes: 15 additions & 22 deletions services/ui-src/src/components/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
import { useLocation, Routes, Route } from "react-router-dom";
import {
LoginCognito,
LoginIDM,
PostLogoutRedirect,
} from "components";
import {
UserContext,
useStore,
} from "utils";
import { Routes, Route } from "react-router-dom";
import { LoginCognito, LoginIDM, PostLogoutRedirect } from "components";
import { useStore } from "utils";
import { makeMediaQueryClasses } from "utils/other/useBreakpoint";
import { Container, Divider, Heading, Stack } from "@chakra-ui/react";

export const App = () => {
const mqClasses = makeMediaQueryClasses();
// const context = useContext(UserContext);
const { user, showLocalLogins } = useStore();
const { pathname } = useLocation();
// const { pathname } = useLocation();

// TODO: fire tealium page view on route change
// useEffect(() => {
// fireTealiumPageView(
// user,
// window.location.href,
// pathname,
// isApparentReportPage(pathname)
// );
// }, [key]);
/*
* useEffect(() => {
* fireTealiumPageView(
* user,
* window.location.href,
* pathname,
* isApparentReportPage(pathname)
* );
* }, [key]);
*/

const authenticatedRoutes = (
<>
{user && (
<p>Hello World</p>
)}
{user && <p>Hello World</p>}
{!user && showLocalLogins && (
<main>
<Container sx={sx.appContainer}>
Expand Down
3 changes: 1 addition & 2 deletions services/ui-src/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

// alerts
export { Alert } from "./alerts/Alert";
export { ErrorAlert } from "./alerts/ErrorAlert";
Expand All @@ -11,4 +10,4 @@ export { LoginIDM } from "./logins/LoginIDM";
// layout
export { PageTemplate } from "./layout/PageTemplate";
// Redirects
export { PostLogoutRedirect } from "./PostLogoutRedirect/index";
export { PostLogoutRedirect } from "./PostLogoutRedirect/index";
2 changes: 1 addition & 1 deletion services/ui-src/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "./users";
export * from "./states";
export * from "./other";
export * from "./other";
28 changes: 14 additions & 14 deletions services/ui-src/src/types/other.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
// ALERTS

export enum AlertTypes {
ERROR = "error",
INFO = "info",
SUCCESS = "success",
WARNING = "warning",
}
ERROR = "error",
INFO = "info",
SUCCESS = "success",
WARNING = "warning",
}

// OTHER

export interface CustomHtmlElement {
type: string;
content: string | any;
as?: string;
props?: {[key: string]: any};
children?: CustomHtmlElement[];
}
type: string;
content: string | any;
as?: string;
props?: { [key: string]: any };
children?: CustomHtmlElement[];
}

export interface ErrorVerbiage {
title: string;
description: string | CustomHtmlElement[];
title: string;
description: string | CustomHtmlElement[];
}
6 changes: 2 additions & 4 deletions services/ui-src/src/types/states.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {
HcbsUser,
} from "types";
import { HcbsUser } from "types";

// initial user state
export interface HcbsUserState {
Expand All @@ -10,4 +8,4 @@ export interface HcbsUserState {
// ACTIONS
setUser: (newUser?: HcbsUser) => void;
setShowLocalLogins: (showLocalLogins: boolean) => void;
}
}
3 changes: 1 addition & 2 deletions services/ui-src/src/utils/auth/userProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ describe("<UserProvider />", () => {
describe("Test UserProvider", () => {
beforeEach(async () => {
await act(async () => {
mockedUseStore
.mockReturnValue(mockStateUserStore);
mockedUseStore.mockReturnValue(mockStateUserStore);
render(testComponent);
});
});
Expand Down
2 changes: 1 addition & 1 deletion services/ui-src/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export * from "./state/useStore";
// tracking
export * from "./tracking/tealium";
//other
export * from "./other/parsing"
export * from "./other/parsing";
16 changes: 5 additions & 11 deletions services/ui-src/src/utils/state/useStore.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { create } from "zustand";
import { devtools, persist } from "zustand/middleware";
import {
HcbsUserState,
HcbsUser,
} from "types";
import { HcbsUserState, HcbsUser } from "types";

// USER STORE
const userStore = (set: Function) => ({
Expand All @@ -19,18 +16,15 @@ const userStore = (set: Function) => ({
set(() => ({ showLocalLogins: true }), false, { type: "showLocalLogins" }),
});


export const useStore = create(
// devtools is being used for debugging state
persist(
devtools<HcbsUserState>(
(set) => ({
...userStore(set),
})
),
devtools<HcbsUserState>((set) => ({
...userStore(set),
})),
{
name: "hcbs-store",
partialize: (state) => ({}),
partialize: () => ({}),
}
)
);
12 changes: 3 additions & 9 deletions services/ui-src/src/utils/testing/setupJest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import { BrowserRouter as Router } from "react-router-dom";
import "@testing-library/jest-dom";
import "jest-axe/extend-expect";
import { mockFlags, resetLDMocks } from "jest-launchdarkly-mock";
import {
UserRoles,
HcbsUserState,
UserContextShape,
} from "types";
import { UserRoles, HcbsUserState, UserContextShape } from "types";
// GLOBALS

global.React = React;
Expand Down Expand Up @@ -154,12 +150,10 @@ export const mockUseStore: HcbsUserState = {
...mockStateUserStore,
};

export const mockUseAdminStore: HcbsUserState =
{
...mockAdminUserStore
export const mockUseAdminStore: HcbsUserState = {
...mockAdminUserStore,
};


// ROUTER

export const RouterWrappedComponent: React.FC = ({ children }) => (
Expand Down
2 changes: 1 addition & 1 deletion services/ui-src/src/verbiage/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ export const genericErrorContent = [
type: "span",
content: ".",
},
];
];

0 comments on commit e43df7e

Please sign in to comment.