-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add product details page and navigation to it
- Loading branch information
Showing
36 changed files
with
643 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,23 @@ | ||
# List of next steps | ||
|
||
- add switch to product with re-fetching product data in background | ||
- add fetching one product for details | ||
- disable remove button if there is no item in the cart | ||
- change title of add buttons if there are such items in the cart | ||
- display cart | ||
- checkout | ||
- decide to use `getSmth` or just `smth` | ||
|
||
# Later | ||
|
||
- add E2E tests for existing features | ||
- fix warning in storybook about React 18 (Storybook itself still uses React 17, so it will take time to remove the warning completely) | ||
- show update status on the page without shifting the content down | ||
- host FE/BE somewhere | ||
- keep the currency knowledge somewhere in a formatter | ||
|
||
# Maybe | ||
|
||
- add date of last cart update and reset the cart on load if too much time have passed | ||
- share data types between BE & FE | ||
- data migration or reset on the client (when stored entities aren't correct anymore) | ||
- entity description data with formatting including some React components |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { FC, PropsWithChildren } from "react"; | ||
import { DEV_ENV } from "../env"; | ||
|
||
export const LoggerComponent: FC<PropsWithChildren<Record<string, unknown>>> = ( | ||
props | ||
) => { | ||
if (DEV_ENV) { | ||
console.log("LoggerComponent:", props); | ||
} | ||
return <>{props.children ?? null}</>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const DEV_ENV: boolean = | ||
!process.env.NODE_ENV || process.env.NODE_ENV === "development"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { FC, PropsWithChildren } from "react"; | ||
|
||
export const MockLink: FC<PropsWithChildren<{}>> = ({ children }) => ( | ||
<a href="#">{children}</a> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { ComponentMeta, ComponentStory } from "@storybook/react"; | ||
import { HTMLProps } from "react"; | ||
import { Button as Component } from "./button"; | ||
|
||
export default { | ||
component: Component, | ||
} as ComponentMeta<typeof Component>; | ||
|
||
const Template: ComponentStory<typeof Component> = (args) => ( | ||
<Component {...args} /> | ||
); | ||
|
||
const Props: HTMLProps<HTMLButtonElement> = { | ||
onClick: () => alert("CLICK"), | ||
children: "Title", | ||
}; | ||
|
||
export const Normal = Template.bind({}); | ||
Normal.args = { | ||
...Props, | ||
}; | ||
|
||
export const Hover = Template.bind({}); | ||
Hover.parameters = { pseudo: { hover: true } }; | ||
Hover.args = { | ||
...Props, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { color, gradient } from "@app/core/ui/theme/api"; | ||
import styled from "styled-components"; | ||
|
||
export const Button = styled.button` | ||
padding: 8px 12px; | ||
background: ${gradient("buttonBg")}; | ||
margin: 8px; | ||
border: 0; | ||
font-size: 16px; | ||
font-weight: 600; | ||
color: black; | ||
border: 2px solid black; | ||
cursor: pointer; | ||
&:hover { | ||
border-color: ${color("hoverButtonText")}; | ||
color: ${color("hoverButtonText")}; | ||
background: ${gradient("buttonBgHover")}; | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
export { CartStatus } from "./components/cart-status/cart-status.view"; | ||
export { CartStatusWireframe } from "./components/cart-status/cart-status.wireframe"; | ||
export { addProductToCart } from "./use-cases/add-product-to-cart"; | ||
export { | ||
addProductToCart, | ||
removeProductFromCart, | ||
} from "./use-cases/update-product-in-cart"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
frontend/src/features/cart/use-cases/update-product-in-cart.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Product } from "@app/core/entities/Product"; | ||
import { | ||
updateOrRemoveProductIdFromCart, | ||
upsertProductIdToCart, | ||
} from "../repository/cart.repository"; | ||
|
||
export const addProductToCart = (product: Product) => { | ||
upsertProductIdToCart(product.id); | ||
}; | ||
|
||
export const removeProductFromCart = (product: Product) => { | ||
updateOrRemoveProductIdFromCart(product.id); | ||
}; |
18 changes: 16 additions & 2 deletions
18
frontend/src/features/navigation/components/navigation/navigation.wireframe.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,25 @@ | ||
import { CartStatusWireframe } from "@app/features/cart"; | ||
import { RestaurantMenuWireframe } from "@app/features/restaurant-menu"; | ||
import { | ||
ProductDetailsWireframe, | ||
RestaurantMenuWireframe, | ||
} from "@app/features/restaurant-menu"; | ||
import { FC } from "react"; | ||
import { BrowserRouter, Route, Routes } from "react-router-dom"; | ||
import { NotFound } from "../not-found/not-found.view"; | ||
import { TopBar } from "../top-bar/top-bar.view"; | ||
|
||
export const NavigationWireframe: FC<{}> = () => ( | ||
<> | ||
<TopBar CartStatus={CartStatusWireframe} /> | ||
<RestaurantMenuWireframe /> | ||
<BrowserRouter> | ||
<Routes> | ||
<Route index element={<RestaurantMenuWireframe />} /> | ||
<Route path="menu"> | ||
<Route index element={<RestaurantMenuWireframe />} /> | ||
<Route path=":productSlug" element={<ProductDetailsWireframe />} /> | ||
</Route> | ||
<Route path="*" element={<NotFound />} /> | ||
</Routes> | ||
</BrowserRouter> | ||
</> | ||
); |
12 changes: 12 additions & 0 deletions
12
frontend/src/features/navigation/components/not-found/not-found.view.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { ComponentMeta, ComponentStory } from "@storybook/react"; | ||
import { NotFound as Component } from "./not-found.view"; | ||
|
||
export default { | ||
component: Component, | ||
} as ComponentMeta<typeof Component>; | ||
|
||
const Template: ComponentStory<typeof Component> = (args) => ( | ||
<Component {...args} /> | ||
); | ||
|
||
export const NotFound = Template.bind({}); |
Oops, something went wrong.