Skip to content
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
15,595 changes: 10,394 additions & 5,201 deletions client/package-lock.json

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import CartMenu from "./scenes/global/CartMenu";
import Checkout from "./scenes/checkout/Checkout";
import Confirmation from "./scenes/checkout/Confirmation";

//hermano que onda, que onda hermano
//ahora si o no
import Products from "./components/Products/Products";


const ScrollToTop = () => {
const { pathname } = useLocation();

Expand All @@ -26,6 +31,7 @@ function App() {
<ScrollToTop />
<Routes>
<Route path="/" element={<Home />} />
<Route path="the-Products" element={<Products />} />
<Route path="item/:itemId" element={<ItemDetails />} />
<Route path="checkout" element={<Checkout />} />
<Route path="checkout/success" element={<Confirmation />} />
Expand Down
21 changes: 21 additions & 0 deletions client/src/components/Item/MyItem.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.card{
display:flex;
flex-direction: column;
align-items: center;
justify-content: center;

}
.card__image-container{
width:100%;
}
.card__content-container img{
width:100%;
object-fit: cover;
}
.card__content-container{
padding:0 1rem;
display:flex;
align-items: center;
justify-content: space-between;
width:100%;
}
18 changes: 18 additions & 0 deletions client/src/components/Item/MyItem.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react'
import './MyItem.css'
const MyItem = ({item}) => {
return (
<div className='card'>
<div className='card__image-container'>
<img src={item.image} alt="character" />
</div>
<div className='card__content-container'>
<p>{item.name}</p>
<p style={{color:item.status === 'Alive'? 'green':item.status === 'Dead'? 'red':'black'}}>{item.status}</p>
</div>

</div>
)
}

export default MyItem
28 changes: 28 additions & 0 deletions client/src/components/Products/Products.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.products{
margin-top: 60px;
width:100%;
min-height: calc(100vh - 60px);
padding:1.5rem;
}
.products-container{
display:grid;
grid-template-columns: 20% 70%;
row-gap: 10%;
width:100%;
height:100%;
}
.filter-container{
padding:1.5rem;
display:flex;
flex-direction: column;
}
.products-wrapper{
display:grid;
grid-template-columns: repeat(auto-fill,minmax(15rem,1fr));
place-items: center;
padding:1.5rem;
gap:1.5rem;
border:1px solid #eee;
border-radius: 0.5rem;
box-shadow: 1px 1px -2px 1px;
}
93 changes: 93 additions & 0 deletions client/src/components/Products/Products.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import React, { useEffect, useState } from 'react'
import './Products.css'
import { UseFetch } from '../../utils/UseFetch'
import MyItem from '../Item/MyItem';
import { Checkbox, FormControlLabel, FormGroup, Typography } from '@mui/material';

const Products = () => {
const [rickAndMortyData, setRickAndMortyData] = useState([]);
const urlRickAndMorty = 'https://rickandmortyapi.com/api/character'
const [error, setError] = useState('');
const [loading, setLoading] = useState(false)
const [aliveChecked, setAliveChecked] = useState(true);
const [deadChecked, setDeadChecked] = useState(true);
const [unknownChecked, setUnknownChecked] = useState(true);
const [filtedData, setFilteredData] = useState([]);
const fetchingData = async() =>{
try{
setLoading(true);
const result = await UseFetch(`${urlRickAndMorty}`);
setRickAndMortyData(result.results);
setFilteredData(result.results);
setLoading(false);
}catch(error){
setError(error);
setLoading(false);
}

}


useEffect(() =>{
fetchingData();
},[])

const handleAliveCheckboxChange = (event) => {
setAliveChecked(event.target.checked);

const filteringData = rickAndMortyData.filter(item => item.status === 'Alive');
setFilteredData(filteringData);
}




const handleDeadCheckboxChange = (event) => {
setDeadChecked(event.target.checked);
};

const handleUnknownCheckboxChange = (event) => {
setUnknownChecked(event.target.checked);
};



return (
<div className='products'>
<div className='products-container'>
<div className='filter-container'>
<Typography variant="h2" color="initial">Filters</Typography>
<Typography variant="h4" color="initial">Statu</Typography>
<FormGroup>
<FormControlLabel
control={<Checkbox checked={aliveChecked} />}
label="Alive"
onChange={handleAliveCheckboxChange}
/>
<FormControlLabel
control={<Checkbox checked={deadChecked} />}
label="Dead"
onChange={handleDeadCheckboxChange}
/>
<FormControlLabel
control={<Checkbox checked={unknownChecked} />}
label="unknown"
onChange={handleUnknownCheckboxChange}
/>
</FormGroup>

</div>
<div className='products-wrapper'>
{loading?(<div>Loading...</div>):(

filtedData.map(item =>(
<MyItem key={item.key} item={item}/>
))
)}
</div>
</div>
</div>
)
}

export default Products
1 change: 0 additions & 1 deletion client/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ body {
}

.app {
margin: auto;
}
4 changes: 4 additions & 0 deletions client/src/scenes/global/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
MenuOutlined,
SearchOutlined,
} from "@mui/icons-material";
import ChurchIcon from '@mui/icons-material/Church';
import { useNavigate } from "react-router-dom";
import { shades } from "../../theme";
import { setIsCartOpen } from "../../state";
Expand Down Expand Up @@ -78,6 +79,9 @@ function Navbar() {
<IconButton sx={{ color: "black" }}>
<MenuOutlined />
</IconButton>
<IconButton sx={{ color: "black" }}>
<ChurchIcon onClick={() => navigate('/the-Products')} />
</IconButton>
</Box>
</Box>
</Box>
Expand Down
5 changes: 5 additions & 0 deletions client/src/utils/UseFetch.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const UseFetch = async (url, option) =>{
const result = await fetch(url);
const json = await result.json();
return json;
}
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.