diff --git a/Microfrontends/home/.babelrc b/Microfrontends/home/.babelrc deleted file mode 100644 index fd92641..0000000 --- a/Microfrontends/home/.babelrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "presets": ["@babel/preset-react", "@babel/preset-env"], - "plugins": [ - ["@babel/transform-runtime"] - ] -} diff --git a/Microfrontends/home/src/Navbar.js b/Microfrontends/home/src/Navbar.js deleted file mode 100644 index 2720962..0000000 --- a/Microfrontends/home/src/Navbar.js +++ /dev/null @@ -1,42 +0,0 @@ -import React from 'react'; -import { Menubar } from 'primereact/menubar'; -import { Badge } from 'primereact/badge'; -import { Avatar } from 'primereact/avatar'; -import { Button } from 'primereact/button'; - -export default function Navbar() { - const itemRenderer = (item) => ( - - - {item.label} - {item.badge && } - {item.shortcut && {item.shortcut}} - - ); - const items = [ - { - label: 'Home', - icon: 'pi pi-home' - }, - { - label: 'Orders', - icon: 'pi pi-envelope', - badge: 3, - template: itemRenderer - } - ]; - - const start = logo; - const end = ( -
-
- ); - - return ( -
- -
- ) -} diff --git a/Microfrontends/home/src/ProductsPage.js b/Microfrontends/home/src/ProductsPage.js deleted file mode 100644 index d591224..0000000 --- a/Microfrontends/home/src/ProductsPage.js +++ /dev/null @@ -1,120 +0,0 @@ -import React, { useState, useEffect } from 'react'; -import { Button } from 'primereact/button'; -import { DataView, DataViewLayoutOptions } from 'primereact/dataview'; -import { Rating } from 'primereact/rating'; -import { Tag } from 'primereact/tag'; -import { classNames } from 'primereact/utils'; -import { getProducts } from "./services/ProductsService"; - -export default function ProductsPage() { - const [products, setProducts] = useState([]); - const [layout, setLayout] = useState('grid'); - - useEffect(() => { - console.log('useEffect'); - getProducts().then((data) => { - console.log(data); - setProducts(data) - }); - }, []); - - const getSeverity = (product) => { - return 'success'; - /*switch (product.inventoryStatus) { - case 'INSTOCK': - return 'success'; - - case 'LOWSTOCK': - return 'warning'; - - case 'OUTOFSTOCK': - return 'danger'; - - default: - return null;*/ - } - - const formatProductPrice = (priceInCents) => { - const priceInDollars = priceInCents / 100; - return `$${priceInDollars.toFixed(2)}`; - }; - - const listItem = (product, index) => { - return ( -
-
- {product.name} -
-
-
{product.name}
- -
- - - {product.category} - - -
-
-
- {formatProductPrice(product.price)} - -
-
-
-
- ); - }; - - const gridItem = (product) => { - return ( -
-
-
-
- - {product.name} -
- -
-
- {product.name} -
{product.name}
- -
-
- {formatProductPrice(product.price)} - -
-
-
- ); - }; - - const itemTemplate = (product, layout, index) => { - if (!product) { - return; - } - - if (layout === 'list') return listItem(product, index); - else if (layout === 'grid') return gridItem(product); - }; - - const listTemplate = (products, layout) => { - return
{products.map((product, index) => itemTemplate(product, layout, index))}
; - }; - - const header = () => { - return ( -
- setLayout(e.value)} /> -
- ); - }; - - return ( -
- -
- ) -} diff --git a/Microfrontends/home/src/services/ProductsService.js b/Microfrontends/home/src/services/ProductsService.js deleted file mode 100644 index 7feea6b..0000000 --- a/Microfrontends/home/src/services/ProductsService.js +++ /dev/null @@ -1,2 +0,0 @@ -export const getProducts = () => - fetch(`/api/v1/products/restaurant/66163e8b15226a4958756a26`).then((res) => res.json()); diff --git a/Microfrontends/home/src/setupProxy.js b/Microfrontends/home/src/setupProxy.js deleted file mode 100644 index eeb9161..0000000 --- a/Microfrontends/home/src/setupProxy.js +++ /dev/null @@ -1,13 +0,0 @@ -const { createProxyMiddleware } = require('http-proxy-middleware'); - -module.exports = function(app) { - app.use( - '/api/v1', - createProxyMiddleware({ - target: 'http://localhost:8080/api/v1', - changeOrigin: true, - secure: false - }) - ); -}; - diff --git a/Microfrontends/home/webpack.config.js b/Microfrontends/home/webpack.config.js deleted file mode 100644 index 91bfde8..0000000 --- a/Microfrontends/home/webpack.config.js +++ /dev/null @@ -1,71 +0,0 @@ -const HtmlWebPackPlugin = require("html-webpack-plugin"); -const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin"); - -const deps = require("./package.json").dependencies; -module.exports = { - output: { - publicPath: "http://localhost:3000/", - }, - - resolve: { - extensions: [".tsx", ".ts", ".jsx", ".js", ".json"], - }, - - devServer: { - port: 3000, - historyApiFallback: true, - }, - - module: { - rules: [ - { - test: /\.m?js/, - type: "javascript/auto", - resolve: { - fullySpecified: false, - }, - }, - { - test: /\.(css|s[ac]ss)$/i, - use: ["style-loader", "css-loader", "postcss-loader"], - }, - { - test: /\.(ts|tsx|js|jsx)$/, - exclude: /node_modules/, - use: { - loader: "babel-loader", - }, - }, - ], - }, - - plugins: [ - new ModuleFederationPlugin({ - name: "home", - filename: "remoteEntry.js", - remotes: { - orders: "orders@http://localhost:3001/remoteEntry.js", - }, - exposes: { - "./Navbar": "./src/Navbar.js", - "./ProductsPage": "./src/ProductsPage.js", - "./ProductsService": "./src/services/ProductsService.js", - }, - shared: { - ...deps, - react: { - eager: true, - singleton: true, - requiredVersion: deps.react, - }, - "react-dom": { - singleton: true, - requiredVersion: deps["react-dom"], - }, - }, - }), - new HtmlWebPackPlugin({ - template: "./public/index.html", - }), - ], -}; diff --git a/Microfrontends/orders/.babelrc b/Microfrontends/orders/.babelrc deleted file mode 100644 index 67d7adc..0000000 --- a/Microfrontends/orders/.babelrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "presets": ["@babel/preset-react", "@babel/preset-env"], - "plugins": [ - ["@babel/transform-runtime"] - ] -} diff --git a/Microfrontends/orders/src/OrdersPage.js b/Microfrontends/orders/src/OrdersPage.js deleted file mode 100644 index 6f6e66f..0000000 --- a/Microfrontends/orders/src/OrdersPage.js +++ /dev/null @@ -1,115 +0,0 @@ -import React, { useState, useEffect } from 'react'; -import { Button } from 'primereact/button'; -import { DataView, DataViewLayoutOptions } from 'primereact/dataview'; -import { Rating } from 'primereact/rating'; -import { Tag } from 'primereact/tag'; -import { classNames } from 'primereact/utils'; - -export default function OrdersPage() { - const [products, setProducts] = useState([]); - const [layout, setLayout] = useState('grid'); - - useEffect(() => { - console.log('useEffect'); - }, []); - - const getSeverity = (product) => { - return 'danger'; - /*switch (product.inventoryStatus) { - case 'INSTOCK': - return 'success'; - - case 'LOWSTOCK': - return 'warning'; - - case 'OUTOFSTOCK': - return 'danger'; - - default: - return null;*/ - } - - const formatProductPrice = (priceInCents) => { - const priceInDollars = priceInCents / 100; - return `$${priceInDollars.toFixed(2)}`; - }; - - const listItem = (product, index) => { - return ( -
-
- {product.name} -
-
-
{product.name}
- -
- - - {product.category} - - -
-
-
- {formatProductPrice(product.price)} - -
-
-
-
- ); - }; - - const gridItem = (product) => { - return ( -
-
-
-
- - {product.name} -
- -
-
- {product.name} -
{product.name}
- -
-
- {formatProductPrice(product.price)} - -
-
-
- ); - }; - - const itemTemplate = (product, layout, index) => { - if (!product) { - return; - } - - if (layout === 'list') return listItem(product, index); - else if (layout === 'grid') return gridItem(product); - }; - - const listTemplate = (products, layout) => { - return
{products.map((product, index) => itemTemplate(product, layout, index))}
; - }; - - const header = () => { - return ( -
- setLayout(e.value)} /> -
- ); - }; - - return ( -
- -
- ) -} diff --git a/Microfrontends/orders/webpack.config.js b/Microfrontends/orders/webpack.config.js deleted file mode 100644 index d3e04ed..0000000 --- a/Microfrontends/orders/webpack.config.js +++ /dev/null @@ -1,66 +0,0 @@ -const HtmlWebPackPlugin = require("html-webpack-plugin"); -const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin"); - -const deps = require("./package.json").dependencies; -module.exports = { - output: { - publicPath: "http://localhost:3001/", - }, - - resolve: { - extensions: [".tsx", ".ts", ".jsx", ".js", ".json"], - }, - - devServer: { - port: 3001, - historyApiFallback: true, - }, - - module: { - rules: [ - { - test: /\.m?js/, - type: "javascript/auto", - resolve: { - fullySpecified: false, - }, - }, - { - test: /\.(css|s[ac]ss)$/i, - use: ["style-loader", "css-loader", "postcss-loader"], - }, - { - test: /\.(ts|tsx|js|jsx)$/, - exclude: /node_modules/, - use: { - loader: "babel-loader", - }, - }, - ], - }, - - plugins: [ - new ModuleFederationPlugin({ - name: "orders", - filename: "remoteEntry.js", - exposes: { - "./OrdersPage": "./src/OrdersPage.js", - }, - shared: { - ...deps, - react: { - eager: true, - singleton: true, - requiredVersion: deps.react, - }, - "react-dom": { - singleton: true, - requiredVersion: deps["react-dom"], - }, - }, - }), - new HtmlWebPackPlugin({ - template: "./public/index.html", - }), - ], -};