les filtres fonctionnent mais le ui est laid.

This commit is contained in:
Victor Turgeon 2022-10-29 08:24:43 -07:00
parent f3dcc0c4d8
commit deee825a48
2 changed files with 19 additions and 6 deletions

View File

@ -1,5 +1,6 @@
import { Form } from "react-bootstrap"; import { Form } from "react-bootstrap";
import { useState } from "react"; import { useState } from "react";
import {Button} from "react-bootstrap";
const Filters = ({ onChange }) => { const Filters = ({ onChange }) => {
@ -72,7 +73,7 @@ const Filters = ({ onChange }) => {
value="" value=""
/> />
<Form.Check <Form.Check
label="Displonible" label="Disponible"
name="stateFilter" name="stateFilter"
type='radio' type='radio'
id="state-available" id="state-available"
@ -110,6 +111,9 @@ const Filters = ({ onChange }) => {
</Form.Group> </Form.Group>
</div> </div>
</Form> </Form>
<Button onClick={() => { onChange(priceFilter, stateFilter) }} className='btn-filter'>
Filtrer
</Button>
</div> </div>
) )
} }

View File

@ -58,8 +58,17 @@ const Morceaux = (startingProducts) => {
setProducts([...json]); setProducts([...json]);
setIsLoading(false); setIsLoading(false);
} }
const handleFilters = async () => {
const handleFilters = async (price, state) => {
setFilterPrice(price);
setFilterState(state);
var url = `https://localhost:7292/api/Inventory?order=${order}&filterPrice=${price}&filterState=${state}`;
setIsLoading(true);
const response = await fetch(url);
const json = await response.json();
if (json.length > 0)
setProducts([...json]);
setIsLoading(false);
} }
return ( return (