Skip to content

Commit

Permalink
Refactor i18n and dayjs initialization
Browse files Browse the repository at this point in the history
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 <sdickers@redhat.com>
  • Loading branch information
sjd78 committed Jan 17, 2024
1 parent 2ea144d commit 4d3cd78
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
3 changes: 0 additions & 3 deletions client/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down
10 changes: 10 additions & 0 deletions client/src/app/dayjs.ts
Original file line number Diff line number Diff line change
@@ -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);
14 changes: 5 additions & 9 deletions client/src/index.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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();

Expand Down

0 comments on commit 4d3cd78

Please sign in to comment.