Commit c57cf38b authored by Rasoul Madani's avatar Rasoul Madani
Browse files

شماره 24

parent b95fcb7e
......@@ -2,25 +2,40 @@ import "./App.css";
import HomeScreen from "./screens/HomeScreen";
import ProductScreen from "./screens/ProductScreen";
import CartScreen from "./screens/CartScreen";
import { BrowserRouter, Route } from "react-router-dom";
import SigninScreen from "./screens/SigninScreen";
import RegisterScreen from "./screens/RegisterScreen";
import { BrowserRouter, Route, Link } from "react-router-dom";
import { useSelector } from "react-redux";
function App() {
const cart = useSelector((state) => state.cart);
const { cartItems } = cart;
return (
<BrowserRouter>
<div className="grid-container">
<header className="row">
<div>
<a className="brand">amazona</a>
<a href="/" className="brand">
amazona
</a>
</div>
<div>
<a>Cart</a>
<a>Signin</a>
<Link to="/cart">
Cart
{cartItems.length > 0 && (
<span className="badge">{cartItems.length}</span>
)}
</Link>
<Link>Signin</Link>
</div>
</header>
<main>
<Route path="/" component={HomeScreen} exact></Route>
<Route path="/product/:id" component={ProductScreen}></Route>
<Route path="/cart/:id?" component={CartScreen}></Route>
<Route path="/signin" component={SigninScreen}></Route>
<Route path="/register" component={RegisterScreen}></Route>
</main>
<footer className="row center">© 2020 All right reserved.</footer>
</div>
......
......@@ -34,6 +34,14 @@ footer {
background: #203040;
color: #ffffff;
}
.badge {
background-color: #f02020;
color: #ffffff;
border-radius: 50%;
padding: 0.2rem 0.7rem;
font-size: 1.4rem;
margin-left: 0.2rem;
}
.row {
display: flex;
flex-direction: row;
......
export default function RegisterScreen(){
return(
<div>allah register</div>
)
}
\ No newline at end of file
......@@ -6,6 +6,13 @@ import {
productDetailsReducer,
} from "./reducers/productReducers";
import { cartReducer } from "./reducers/cartReducers";
const initialState = {
cart: {
cartItems: localStorage.getItem("cartItems")
? JSON.parse(localStorage.getItem("cartItems"))
: [],
},
};
const reducer = combineReducers({
productList: productListReducer,
......@@ -15,5 +22,9 @@ const reducer = combineReducers({
const composeEnhancer = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(reducer, {}, composeEnhancer(applyMiddleware(thunk)));
const store = createStore(
reducer,
initialState,
composeEnhancer(applyMiddleware(thunk))
);
export default store;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment