Skip to content

Commit

Permalink
fix-router
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadpy8 committed Aug 26, 2023
1 parent a0b7bb1 commit 9372096
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 61 deletions.
48 changes: 2 additions & 46 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react";
import { AiFillStar, AiOutlineStar, AiOutlineShoppingCart } from "react-icons/ai";

import Headers from "./components/Headers";
import Home from "./Pages/home/Home";
import "./App.css";
import { useRoutes } from "react-router-dom";
import routes from "./routes";
Expand All @@ -14,52 +15,7 @@ function App() {
<div className="app">
{/* Start Content */}
<Headers />
<section>
<p className="title">All Products:</p>
</section>
<img className="index-first-bg" src="/hero-gradient.svg" alt="" />
<main className="main-index">
<div className="card">
<img
src="https://fakestoreapi.com/img/81fPKd-2AYL._AC_SL1500_.jpg"
alt=""
/>
<main>
<p>Test Title ...</p>
<div className="card-details">
<div>
<AiOutlineStar style={{ color: "orange" }} />
<AiOutlineStar style={{ color: "orange" }} />
<AiOutlineStar style={{ color: "orange" }} />
<AiOutlineStar style={{ color: "orange" }} />
<AiOutlineStar style={{ color: "orange" }} />
</div>
<p>231$</p>
</div>
<button>Add to Basket</button>
</main>
</div>
<div className="card">
<img
src="https://fakestoreapi.com/img/81fPKd-2AYL._AC_SL1500_.jpg"
alt=""
/>
<main>
<p>Test Title ...</p>
<div className="card-details">
<div>
<AiFillStar style={{ color: "orange" }} />
<AiFillStar style={{ color: "orange" }} />
<AiFillStar style={{ color: "orange" }} />
<AiFillStar style={{ color: "orange" }} />
<AiFillStar style={{ color: "orange" }} />
</div>
<p>231$</p>
</div>
<button>Add to Basket</button>
</main>
</div>
</main>
{router}

{/* Finish Content */}

Expand Down
57 changes: 57 additions & 0 deletions src/Pages/home/Home.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React from 'react'
import { AiFillStar, AiOutlineStar } from 'react-icons/ai'

const Home = () => {
return (
<>
<section>
<p className="title">All Products:</p>
</section>
<img className="index-first-bg" src="/hero-gradient.svg" alt="" />
<main className="main-index">
<div className="card">
<img
src="https://fakestoreapi.com/img/81fPKd-2AYL._AC_SL1500_.jpg"
alt=""
/>
<main>
<p>Test Title ...</p>
<div className="card-details">
<div>
<AiOutlineStar style={{ color: 'orange' }} />
<AiOutlineStar style={{ color: 'orange' }} />
<AiOutlineStar style={{ color: 'orange' }} />
<AiOutlineStar style={{ color: 'orange' }} />
<AiOutlineStar style={{ color: 'orange' }} />
</div>
<p>231$</p>
</div>
<button>Add to Basket</button>
</main>
</div>
<div className="card">
<img
src="https://fakestoreapi.com/img/81fPKd-2AYL._AC_SL1500_.jpg"
alt=""
/>
<main>
<p>Test Title ...</p>
<div className="card-details">
<div>
<AiFillStar style={{ color: 'orange' }} />
<AiFillStar style={{ color: 'orange' }} />
<AiFillStar style={{ color: 'orange' }} />
<AiFillStar style={{ color: 'orange' }} />
<AiFillStar style={{ color: 'orange' }} />
</div>
<p>231$</p>
</div>
<button>Add to Basket</button>
</main>
</div>
</main>
</>
)
}

export default Home
11 changes: 6 additions & 5 deletions src/components/Headers.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import React from 'react'

import { AiOutlineShoppingCart } from 'react-icons/ai'
import { AiOutlineShoppingCart } from 'react-icons/ai';
import { Link } from "react-router-dom";

const Headers = () => {
return (
<header>
<a className="logo" href="#">
<Link className="logo" to="/">
shop cart
</a>
<a href="#">
</Link>
<Link to="/cart">
<AiOutlineShoppingCart className="shop-icon" />
<span>2</span>
</a>
</Link>
</header>
)
}
Expand Down
19 changes: 11 additions & 8 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import Cart from "./Pages/Cart";
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App'
import { BrowserRouter } from 'react-router-dom'
import Cart from './Pages/Cart'

ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
<App />
<BrowserRouter>
<App />
</BrowserRouter>
{/* <Cart /> */}
</React.StrictMode>
);
</React.StrictMode>,
)
5 changes: 3 additions & 2 deletions src/routes.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import App from "./App";
import React from "react";
import Cart from "./Pages/Cart";
import Home from "./Pages/home/Home";

const routes = [
{ path: "/", element: <App /> },
{ path: "/", element: <Home /> },
{ path: "/cart", element: <Cart /> }
];

Expand Down

0 comments on commit 9372096

Please sign in to comment.