Skip to content

Commit

Permalink
web: fix product routes
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Jun 13, 2024
1 parent 14ba857 commit 750eeb0
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 83 deletions.
76 changes: 36 additions & 40 deletions web/src/components/product/ProductSelectionPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import React, { useState } from "react";
import { useNavigate } from "react-router-dom";
import {
Card, CardBody,
Flex, FlexItem,
Flex,
Form,
Grid, GridItem,
Radio
Expand Down Expand Up @@ -75,45 +75,41 @@ function ProductSelectionPage() {
const isSelectionDisabled = !nextProduct || (nextProduct === selectedProduct);

return (
<>
<Page.MainContent>
<Center>
<Form id="productSelectionForm" onSubmit={onSubmit}>
<Grid hasGutter>
{products.map((product, index) => (
<Item key={index}>
<Card key={index} isRounded>
<CardBody>
<Radio
key={index}
name="product"
id={product.name}
label={<Label>{product.name}</Label>}
body={product.description}
isChecked={nextProduct === product}
onChange={() => setNextProduct(product)}
/>
</CardBody>
</Card>
</Item>
))}
<Item>
<Flex justifyContent={{ default: "justifyContentFlexEnd" }}>
{selectedProduct && <Page.CancelAction navigateTo={-1} />}
<Page.Action
type="submit"
form="productSelectionForm"
isDisabled={isSelectionDisabled}
>
{_("Select")}
</Page.Action>
</Flex>
</Item>
</Grid>
</Form>
</Center>
</Page.MainContent>
</>
<Center>
<Form id="productSelectionForm" onSubmit={onSubmit}>
<Grid hasGutter>
{products.map((product, index) => (
<Item key={index}>
<Card key={index} isRounded>
<CardBody>
<Radio
key={index}
name="product"
id={product.name}
label={<Label>{product.name}</Label>}
body={product.description}
isChecked={nextProduct === product}
onChange={() => setNextProduct(product)}
/>
</CardBody>
</Card>
</Item>
))}
<Item>
<Flex justifyContent={{ default: "justifyContentFlexEnd" }}>
{selectedProduct && <Page.CancelAction navigateTo={-1} />}
<Page.Action
type="submit"
form="productSelectionForm"
isDisabled={isSelectionDisabled}
>
{_("Select")}
</Page.Action>
</Flex>
</Item>
</Grid>
</Form>
</Center>
);
}

Expand Down
32 changes: 4 additions & 28 deletions web/src/components/product/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,13 @@
*/

import React from "react";
import { Page } from "~/components/core";
import ProductSelectionPage from "./ProductSelectionPage";
import ProductRegistrationPage from "./ProductRegistrationPage";
import { _ } from "~/i18n";

const registerRoute = {
path: "/product/register",
element: <Page />,
handle: {
name: _("Product registration"),
icon: "inventory_2",
hidden: true
},
children: [
{
index: true,
element: <ProductRegistrationPage />
}
]
};

const selectionRoute = {
path: "/product/select",
element: <ProductSelectionPage />,
handle: {
name: _("Product selection"),
icon: "inventory_2"
}
const productsRoute = {
path: "/products",
element: <ProductSelectionPage />
};

export {
registerRoute,
selectionRoute,
productsRoute
};
19 changes: 4 additions & 15 deletions web/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,24 @@ import App from "~/App";
import Protected from "~/Protected";
import MainLayout from "~/MainLayout";
import SimpleLayout from "./SimpleLayout";
import { Page, LoginPage } from "~/components/core";
import { LoginPage } from "~/components/core";
import { OverviewPage } from "~/components/overview";
import { ProductRegistrationPage, ProductSelectionPage } from "~/components/product";
import { _ } from "~/i18n";
import overviewRoutes from "~/components/overview/routes";
import l10nRoutes from "~/components/l10n/routes";
import networkRoutes from "~/components/network/routes";
import { productsRoute } from "~/components/product/routes";
import storageRoutes from "~/components/storage/routes";
import softwareRoutes from "~/components/software/routes";
import usersRoutes from "~/components/users/routes";
import {
registerRoute as productRegistrationRoute,
selectionRoute as productSelectionRoute
} from "~/components/product/routes";

const rootRoutes = [
overviewRoutes,
l10nRoutes,
networkRoutes,
storageRoutes,
softwareRoutes,
usersRoutes,
productRegistrationRoute
usersRoutes
];

const protectedRoutes = [
Expand All @@ -67,13 +62,7 @@ const protectedRoutes = [
},
{
element: <SimpleLayout />,
children: [
{
path: "products",
element: <ProductSelectionPage />
},
productSelectionRoute
]
children: [productsRoute]
}
]
}
Expand Down

0 comments on commit 750eeb0

Please sign in to comment.