Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added all orders page component #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Sidebar from './components/Sidebar';
import BookApprovalSys from './components/BookApprovalSys';
import MenuRoundedIcon from '@material-ui/icons/MenuRounded';
import {useState} from 'react';
import AllOrders from './components/AllOrders';

function App() {
const [sidebarOpen, setSidebarOpen] = useState(false);
Expand All @@ -18,6 +19,7 @@ function App() {
<div className='main'>
<Switch>
<Route exact path='/BookApprovalSys' component={BookApprovalSys}/>
<Route exact path='/allOrders' component={AllOrders}/>
</Switch>
</div>
</div>
Expand Down
26 changes: 22 additions & 4 deletions src/components/AddFilter.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'
import './css/AddFilter.css'
import DeleteRoundedIcon from '@material-ui/icons/DeleteRounded';

const AddFilter = ({ openStatus, close }) => {

Expand All @@ -9,11 +10,28 @@ const AddFilter = ({ openStatus, close }) => {
<h4>+ AddFilter</h4>
<h4 id='closebtn' onClick={close}>close x</h4>
</div>
<div className="filterCondition">
<h4>condition1 </h4>
<h4 id='closebtn' >x</h4>
<div className="condition">
<form>
<p>Medium of rent</p>
<input type="reset" value="Clear" name="Button"></input>
<fieldset id="Medium">
<input type="radio" value="Pick Up" name="Medium"></input>
<lable htmlFor="Pick Up">Pick Up</lable>
<br></br>
<input type="radio" value="Delivery" name="Medium"></input>
<lable htmlFor="Delivery">Delivery</lable>
</fieldset>
</form>
</div>
<div className="clearAll">
<div className="deleteIcon">
<DeleteRoundedIcon color='error' />
</div>
<div className="clearText">
<h4>Clear All Filters</h4>
</div>
<button className="doneButton">Done</button>
</div>


</div>
)
Expand Down
77 changes: 77 additions & 0 deletions src/components/AllOrders.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import React, { useState, useEffect } from 'react'
import './css/AllOrders.css'
import BookOrderCards from './BookOrderCards'
import FilterListIcon from '@material-ui/icons/FilterList';
import OrdersList from './apis/Orders.json'
import AddFilter from './AddFilter';
import Pagignation from './Pagignation';

const AllOrders = () => {
const [Orders, setOrders] = useState(OrdersList);
const [filterOpen, setFilterOpen] = useState(false);
const [currentPage, setCurrentPage] = useState(1);

const [active, setActive] = useState({
'rent': false,
'buysell': false
})

function filterOrders(status) {
const filteredOrders = OrdersList.filter((book) => {
return book.status === status;
})
setOrders(filteredOrders);

if (status === "rent") {
setActive({
"rent": true,
"buysell": false
});
}
else {
setActive({
"rent": false,
"buysell": true
});
}
}

useEffect(() => {
filterOrders("rent");
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

// Get current posts
const indexOfLastBook = currentPage * 3;
const indexOfFirstBook = indexOfLastBook - 3;
const currentBooks = Orders.slice(indexOfFirstBook, indexOfLastBook);

const paginate = pageNumber => setCurrentPage(pageNumber);

return (
<>
<AddFilter openStatus={filterOpen} close={() => { setFilterOpen(false) }}/>
<div className='bookContainer'>
<div className="bookContainerNav">
<p id={active.rent ? 'activeTab' : ''} onClick={() => { filterOrders("rent") }}>Rent</p>
<p id={active.buysell ? 'activeTab' : ''} onClick={() => { filterOrders("buysell") }}>Buy/Sell</p>
</div>


<div className="form">
<button className='filterbtn' onClick={(e) => { setFilterOpen(!filterOpen) }}><FilterListIcon fontSize='small' color="primary" /> Filter</button>
<input type="text" placeholder='Search' className='searchbox' />
</div>


<div className='line' />
<BookOrderCards books={currentBooks} />
<Pagignation totalBooks={Orders.length}
paginate={paginate} currentPage={currentPage}/>
</div>

</>
)
}

export default AllOrders
22 changes: 22 additions & 0 deletions src/components/BookOrderCards.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react'
import './css/BookOrderCards.css'

const BookOrderCards = ({ books }) => {
return (
books.map((book) => {
return (
<div className="bookCard" key={book.title}>
<div className="cardHead">
<h4>{book.title}</h4>
</div>
<p >{book.desc}</p>
{book.medium === 'pickup' ? <button className='bbtn' >Pick Up</button> :
<button className='bbtn' style={{ border:`2px solid #FFAE00`, color: '#FFAE00'}}>Delivery</button>}

</div>
)
})
)
}

export default BookOrderCards
122 changes: 122 additions & 0 deletions src/components/apis/Orders.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
[
{
"title": "Book1",
"desc": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel, eos temporibus aliquid reprehenderit, veniam distinctio dolorum consequatur quo iusto magnam tempora officiis, optio ab deserunt.",
"medium": "pickup",
"status": "rent"
},
{
"title": "Book2",
"desc": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel, eos temporibus aliquid reprehenderit, veniam distinctio dolorum consequatur quo iusto magnam tempora officiis, optio ab deserunt.",
"medium": "pickup",
"status": "rent"
},
{
"title": "Book3",
"desc": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel, eos temporibus aliquid reprehenderit, veniam distinctio dolorum consequatur quo iusto magnam tempora officiis, optio ab deserunt.",
"medium": "pickup",
"status": "buysell"
},
{
"title": "Book4",
"desc": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel, eos temporibus aliquid reprehenderit, veniam distinctio dolorum consequatur quo iusto magnam tempora officiis, optio ab deserunt.",
"medium": "pickup",
"status": "rent"
},
{
"title": "Book5",
"desc": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel, eos temporibus aliquid reprehenderit, veniam distinctio dolorum consequatur quo iusto magnam tempora officiis, optio ab deserunt.",
"medium": "pickup",
"status": "buysell"
},
{
"title": "Book6",
"desc": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel, eos temporibus aliquid reprehenderit, veniam distinctio dolorum consequatur quo iusto magnam tempora officiis, optio ab deserunt.",
"medium": "delivery",
"status": "buysell"
},
{
"title": "Book7",
"desc": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel, eos temporibus aliquid reprehenderit, veniam distinctio dolorum consequatur quo iusto magnam tempora officiis, optio ab deserunt.",
"medium": "delivery",
"status": "rent"
},
{
"title": "Book8",
"desc": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel, eos temporibus aliquid reprehenderit, veniam distinctio dolorum consequatur quo iusto magnam tempora officiis, optio ab deserunt.",
"medium": "delivery",
"status": "buysell"
},
{
"title": "Book9",
"desc": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel, eos temporibus aliquid reprehenderit, veniam distinctio dolorum consequatur quo iusto magnam tempora officiis, optio ab deserunt.",
"medium": "delivery",
"status": "rent"
},
{
"title": "Book10",
"desc": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel, eos temporibus aliquid reprehenderit, veniam distinctio dolorum consequatur quo iusto magnam tempora officiis, optio ab deserunt.",
"medium": "delivery",
"status": "buysell"
},
{
"title": "Book11",
"desc": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel, eos temporibus aliquid reprehenderit, veniam distinctio dolorum consequatur quo iusto magnam tempora officiis, optio ab deserunt.",
"medium": "pickup",
"status": "rent"
},
{
"title": "Book12",
"desc": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel, eos temporibus aliquid reprehenderit, veniam distinctio dolorum consequatur quo iusto magnam tempora officiis, optio ab deserunt.",
"medium": "pickup",
"status": "rent"
},
{
"title": "Book13",
"desc": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel, eos temporibus aliquid reprehenderit, veniam distinctio dolorum consequatur quo iusto magnam tempora officiis, optio ab deserunt.",
"medium": "pickup",
"status": "rent"
},
{
"title": "Book14",
"desc": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel, eos temporibus aliquid reprehenderit, veniam distinctio dolorum consequatur quo iusto magnam tempora officiis, optio ab deserunt.",
"medium": "pickup",
"status": "buysell"
},
{
"title": "Book15",
"desc": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel, eos temporibus aliquid reprehenderit, veniam distinctio dolorum consequatur quo iusto magnam tempora officiis, optio ab deserunt.",
"medium": "pickup",
"status": "rent"
},
{
"title": "Book16",
"desc": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel, eos temporibus aliquid reprehenderit, veniam distinctio dolorum consequatur quo iusto magnam tempora officiis, optio ab deserunt.",
"medium": "delivery",
"status": "rent"
},
{
"title": "Book17",
"desc": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel, eos temporibus aliquid reprehenderit, veniam distinctio dolorum consequatur quo iusto magnam tempora officiis, optio ab deserunt.",
"medium": "delivery",
"status": "buysell"
},
{
"title": "Book18",
"desc": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel, eos temporibus aliquid reprehenderit, veniam distinctio dolorum consequatur quo iusto magnam tempora officiis, optio ab deserunt.",
"medium": "delivery",
"status": "rent"
},
{
"title": "Book19",
"desc": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel, eos temporibus aliquid reprehenderit, veniam distinctio dolorum consequatur quo iusto magnam tempora officiis, optio ab deserunt.",
"medium": "delivery",
"status": "buysell"
},
{
"title": "Book20",
"desc": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel, eos temporibus aliquid reprehenderit, veniam distinctio dolorum consequatur quo iusto magnam tempora officiis, optio ab deserunt.",
"medium": "delivery",
"status": "rent"
}
]
Loading