From 4d3cd780d22118fb855916a4d13915d587a7a9da Mon Sep 17 00:00:00 2001 From: Scott J Dickerson Date: Wed, 17 Jan 2024 16:29:41 -0500 Subject: [PATCH] Refactor i18n and dayjs initialization Refactoring: - Explicitly add `i18n` initialization on the root `index.tsx`. - Move `dayjs` initialization to its own file `dayjs.ts` referenced from `index.tsx`. This follows the `i18n` init style. - Move PF css includes from App.tsx to index.tsx Signed-off-by: Scott J Dickerson --- client/src/app/App.tsx | 3 --- client/src/app/dayjs.ts | 10 ++++++++++ client/src/index.tsx | 14 +++++--------- 3 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 client/src/app/dayjs.ts diff --git a/client/src/app/App.tsx b/client/src/app/App.tsx index 6b7409777..3414477ed 100644 --- a/client/src/app/App.tsx +++ b/client/src/app/App.tsx @@ -5,9 +5,6 @@ import { AppRoutes } from "./Routes"; import { DefaultLayout } from "./layout"; import { NotificationsProvider } from "./components/NotificationsContext"; -import "@patternfly/patternfly/patternfly.css"; -import "@patternfly/patternfly/patternfly-addons.css"; - import "./app.css"; const App: React.FC = () => { diff --git a/client/src/app/dayjs.ts b/client/src/app/dayjs.ts new file mode 100644 index 000000000..a86cf31f9 --- /dev/null +++ b/client/src/app/dayjs.ts @@ -0,0 +1,10 @@ +import dayjs from "dayjs"; +import isSameOrBefore from "dayjs/plugin/isSameOrBefore"; +import utc from "dayjs/plugin/utc"; +import timezone from "dayjs/plugin/timezone"; +import customParseFormat from "dayjs/plugin/customParseFormat"; + +dayjs.extend(utc); +dayjs.extend(timezone); +dayjs.extend(customParseFormat); +dayjs.extend(isSameOrBefore); diff --git a/client/src/index.tsx b/client/src/index.tsx index 29774a8cb..ce826f80d 100644 --- a/client/src/index.tsx +++ b/client/src/index.tsx @@ -1,3 +1,6 @@ +import "@patternfly/patternfly/patternfly.css"; +import "@patternfly/patternfly/patternfly-addons.css"; + import React from "react"; import ReactDOM from "react-dom"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; @@ -7,16 +10,9 @@ import ENV from "@app/env"; import App from "@app/App"; import reportWebVitals from "@app/reportWebVitals"; import { KeycloakProvider } from "@app/components/KeycloakProvider"; -import dayjs from "dayjs"; -import isSameOrBefore from "dayjs/plugin/isSameOrBefore"; -import utc from "dayjs/plugin/utc"; -import timezone from "dayjs/plugin/timezone"; -import customParseFormat from "dayjs/plugin/customParseFormat"; -dayjs.extend(utc); -dayjs.extend(timezone); -dayjs.extend(customParseFormat); -dayjs.extend(isSameOrBefore); +import "@app/dayjs"; +import "@app/i18n"; const queryClient = new QueryClient();