From edd392a8779d9f21d4b8221c7075bedcbe46b774 Mon Sep 17 00:00:00 2001 From: Ayoub Adib Date: Wed, 25 Dec 2024 23:46:03 +0100 Subject: [PATCH] refactor: rename App to Main component to follow clean architecture book language --- hosts/web/src/{App.tsx => Main.tsx} | 6 ++---- hosts/web/src/index.tsx | 4 ++-- .../frameworks/web/useDependencyInjection.tsx | 17 +++++++++-------- 3 files changed, 13 insertions(+), 14 deletions(-) rename hosts/web/src/{App.tsx => Main.tsx} (55%) diff --git a/hosts/web/src/App.tsx b/hosts/web/src/Main.tsx similarity index 55% rename from hosts/web/src/App.tsx rename to hosts/web/src/Main.tsx index 2bc2bbc..89cd987 100644 --- a/hosts/web/src/App.tsx +++ b/hosts/web/src/Main.tsx @@ -1,11 +1,9 @@ // eslint-disable-next-line import-x/no-namespace import * as Catalog from "@clean-architecture/catalog"; -export const App = () => { +export const Main = () => { return ( - + ); diff --git a/hosts/web/src/index.tsx b/hosts/web/src/index.tsx index 40e7817..a6937f5 100644 --- a/hosts/web/src/index.tsx +++ b/hosts/web/src/index.tsx @@ -1,14 +1,14 @@ import { createRoot } from "react-dom/client"; import { StrictMode } from "react"; -import { App } from "./App"; +import { Main } from "./Main"; const rootElement = document.querySelector("#root"); if (rootElement) { createRoot(rootElement).render( - +
, ); } diff --git a/modules/catalog/src/frameworks/web/useDependencyInjection.tsx b/modules/catalog/src/frameworks/web/useDependencyInjection.tsx index 15a008f..8375246 100644 --- a/modules/catalog/src/frameworks/web/useDependencyInjection.tsx +++ b/modules/catalog/src/frameworks/web/useDependencyInjection.tsx @@ -2,7 +2,7 @@ import { createContext, useContext } from "react"; import type { PropsWithChildren } from "react"; import { Guard } from "@clean-architecture/shared-kernel"; -import type { QuoteEntityGateway } from "../../adapters/QuoteEntityGateway"; +import { QuoteEntityGateway } from "../../adapters/QuoteEntityGateway"; type DependencyInjectionContextValue = { readonly quoteEntityGateway: QuoteEntityGateway; @@ -11,15 +11,16 @@ type DependencyInjectionContextValue = { const DependencyInjectionContext = createContext(null); -type DependencyInjectionProps = - PropsWithChildren; +// TODO: add data source as props to enable test vs. real host +type DependencyInjectionProps = PropsWithChildren; -export const DependencyInjection = ({ - children, - ...contextValue -}: DependencyInjectionProps) => { +const CONTEXT_VALUE: DependencyInjectionContextValue = { + quoteEntityGateway: new QuoteEntityGateway(), +}; + +export const DependencyInjection = ({ children }: DependencyInjectionProps) => { return ( - + {children} );