-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changed styling for docker-render automation test
- Loading branch information
Showing
4 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import {Product} from "../models/product.tsx"; | ||
import {ChangeEvent, FormEvent, useState} from "react"; | ||
import ProductCard from "./ProductCard.tsx"; | ||
|
||
|
||
type GetGroceriesByIdProps = { | ||
products: Product[], | ||
|
||
} | ||
|
||
export default function GetGroceriesById(props: Readonly<GetGroceriesByIdProps>){ | ||
const [searchText, setSearchText] = useState(""); | ||
const [submittedText, setSubmittedText]=useState(""); | ||
|
||
const handleSubmit =(event: FormEvent<HTMLFormElement>)=>{ | ||
event.preventDefault(); | ||
setSubmittedText(searchText); | ||
} | ||
|
||
const filteredProducts : Product[] = submittedText ? props.products.filter((product:Product) => product.name.toLowerCase().includes(submittedText.toLowerCase())):[]; | ||
|
||
const noProductsMessage = submittedText && filteredProducts.length === 0 ? ( | ||
<p className="no-products-found">No products found</p> | ||
) : null; | ||
|
||
return ( | ||
<div className="search-card"> | ||
<form onSubmit={handleSubmit}> | ||
<input | ||
type="text" | ||
value={searchText} | ||
onChange={(e: ChangeEvent<HTMLInputElement>) => setSearchText(e.target.value)} | ||
placeholder="Search for a Product" | ||
/> | ||
<button type="submit">Search</button> | ||
</form> | ||
{submittedText && filteredProducts.length > 0 ? ( | ||
<div className="product-by-id"> | ||
<div>Found article(s):</div> | ||
{filteredProducts.map(product => ( | ||
<ProductCard key={product.id} product={product} /> | ||
))} | ||
</div> | ||
) : noProductsMessage} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Product } from "../models/product.tsx"; | ||
|
||
type ProductCardProps = { | ||
product: Product; | ||
}; | ||
|
||
export default function ProductCard(props: Readonly<ProductCardProps>) { | ||
return ( | ||
<div className="product-card"> | ||
<div className="product-card-info"> | ||
<h3>{props.product.name}</h3> | ||
<p>Menge: {props.product.amount}</p> | ||
</div> | ||
</div> | ||
); | ||
} |