edited categories and added translations
This commit is contained in:
@@ -5,10 +5,12 @@
|
|||||||
"addToCart": "In den Warenkorb",
|
"addToCart": "In den Warenkorb",
|
||||||
"addedToCart": "Produkt wurde erfolgreich dem Warenkorb hinzugefügt",
|
"addedToCart": "Produkt wurde erfolgreich dem Warenkorb hinzugefügt",
|
||||||
"almostSoldOut": "Fast ausverkauft",
|
"almostSoldOut": "Fast ausverkauft",
|
||||||
|
"all": "Alle",
|
||||||
"available": "Stück verfügbar",
|
"available": "Stück verfügbar",
|
||||||
"backToHome": "Zurück zur Startseite",
|
"backToHome": "Zurück zur Startseite",
|
||||||
"cancel": "Abbrechen",
|
"cancel": "Abbrechen",
|
||||||
"categories": "Kategorien",
|
"categories": "Kategorien",
|
||||||
|
"category": "Kategorie",
|
||||||
"checkout": "Zur Kasse",
|
"checkout": "Zur Kasse",
|
||||||
"close": "Schließen",
|
"close": "Schließen",
|
||||||
"contact": "Kontakt",
|
"contact": "Kontakt",
|
||||||
@@ -17,22 +19,28 @@
|
|||||||
"edit": "Bearbeiten",
|
"edit": "Bearbeiten",
|
||||||
"email": "E-Mail",
|
"email": "E-Mail",
|
||||||
"freeShipping": "Kostenloser Versand ab 50 € Bestellwert",
|
"freeShipping": "Kostenloser Versand ab 50 € Bestellwert",
|
||||||
|
"gardenSupplies": "Gartenzubehör",
|
||||||
"inStock": "Verfügbar",
|
"inStock": "Verfügbar",
|
||||||
"logout": "Ausloggen",
|
"logout": "Ausloggen",
|
||||||
"myAccount": "Mein Konto",
|
"myAccount": "Mein Konto",
|
||||||
"name": "Name",
|
"name": "Name",
|
||||||
"orders": "Bestellungen",
|
"orders": "Bestellungen",
|
||||||
|
"other": "Sonstiges",
|
||||||
"outOfStock": "Ausverkauft",
|
"outOfStock": "Ausverkauft",
|
||||||
"pageDoesNotExist": "Ups! Diese Seite existiert nicht.",
|
"pageDoesNotExist": "Ups! Diese Seite existiert nicht.",
|
||||||
"phone": "Telefon",
|
"phone": "Telefon",
|
||||||
|
"price": "Preis",
|
||||||
"productDoesNotExist": "Dieses Produkt existiert nicht oder wurde bereits gelöscht.",
|
"productDoesNotExist": "Dieses Produkt existiert nicht oder wurde bereits gelöscht.",
|
||||||
"productNotFound": "Produkt nicht gefunden!",
|
"productNotFound": "Produkt nicht gefunden!",
|
||||||
"quantity": "Anzahl",
|
"quantity": "Anzahl",
|
||||||
"rateThisProduct": "Dieses Produkt bewerten",
|
"rateThisProduct": "Dieses Produkt bewerten",
|
||||||
|
"rating": "Bewertung",
|
||||||
"ratingFrom": "Bewertung vom",
|
"ratingFrom": "Bewertung vom",
|
||||||
"review": "Produktrezension (optional)",
|
"review": "Produktrezension (optional)",
|
||||||
"save": "Speichern",
|
"save": "Speichern",
|
||||||
"search": "Suchen",
|
"search": "Suchen",
|
||||||
|
"seeds": "Saatgut",
|
||||||
"submit": "Senden",
|
"submit": "Senden",
|
||||||
|
"technicalComponents": "Technik",
|
||||||
"wrongTurn": "Ein falscher Weg wurde eingeschlagen. Zurück auf den richtigen Pfad."
|
"wrongTurn": "Ein falscher Weg wurde eingeschlagen. Zurück auf den richtigen Pfad."
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,12 @@
|
|||||||
"addToCart": "Add to cart",
|
"addToCart": "Add to cart",
|
||||||
"addedToCart": "Product added to shopping cart successfully",
|
"addedToCart": "Product added to shopping cart successfully",
|
||||||
"almostSoldOut": "Almost sold out",
|
"almostSoldOut": "Almost sold out",
|
||||||
|
"all": "Show all",
|
||||||
"available": "items available",
|
"available": "items available",
|
||||||
"backToHome": "Go back to home",
|
"backToHome": "Go back to home",
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
"categories": "Categories",
|
"categories": "Categories",
|
||||||
|
"category": "Category",
|
||||||
"checkout": "Checkout",
|
"checkout": "Checkout",
|
||||||
"close": "Close",
|
"close": "Close",
|
||||||
"contact": "Contact",
|
"contact": "Contact",
|
||||||
@@ -17,22 +19,28 @@
|
|||||||
"edit": "Edit",
|
"edit": "Edit",
|
||||||
"email": "Email",
|
"email": "Email",
|
||||||
"freeShipping": "Free shipping for orders over 50 €",
|
"freeShipping": "Free shipping for orders over 50 €",
|
||||||
|
"gardenSupplies": "Garden supplies",
|
||||||
"inStock": "In stock",
|
"inStock": "In stock",
|
||||||
"logout": "Logout",
|
"logout": "Logout",
|
||||||
"myAccount": "My Account",
|
"myAccount": "My Account",
|
||||||
"name": "Name",
|
"name": "Name",
|
||||||
"orders": "Orders",
|
"orders": "Orders",
|
||||||
|
"other": "Other",
|
||||||
"outOfStock": "Out of stock",
|
"outOfStock": "Out of stock",
|
||||||
"pageDoesNotExist": "Oops! The page you're looking for doesn't exist.",
|
"pageDoesNotExist": "Oops! The page you're looking for doesn't exist.",
|
||||||
"phone": "Phone number",
|
"phone": "Phone number",
|
||||||
|
"price": "Price",
|
||||||
"productDoesNotExist": "It seems you are locking for a product that doesn't exist or has been removed.",
|
"productDoesNotExist": "It seems you are locking for a product that doesn't exist or has been removed.",
|
||||||
"productNotFound": "Product not found!",
|
"productNotFound": "Product not found!",
|
||||||
"quantity": "Quantity",
|
"quantity": "Quantity",
|
||||||
"rateThisProduct": "Rate this product",
|
"rateThisProduct": "Rate this product",
|
||||||
|
"rating": "Rating",
|
||||||
"ratingFrom": "Rating from",
|
"ratingFrom": "Rating from",
|
||||||
"review": "Product review (optional)",
|
"review": "Product review (optional)",
|
||||||
"save": "Save",
|
"save": "Save",
|
||||||
"search": "Search",
|
"search": "Search",
|
||||||
|
"seeds": "Seeds",
|
||||||
"submit": "Submit",
|
"submit": "Submit",
|
||||||
|
"technicalComponents": "Technical components",
|
||||||
"wrongTurn": "It seems you may have taken a wrong turn. Let's get you back on track."
|
"wrongTurn": "It seems you may have taken a wrong turn. Let's get you back on track."
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
import { FormControl, FormControlLabel, Radio, RadioGroup, Rating } from "@mui/material";
|
import { FormControl, FormControlLabel, Radio, RadioGroup, Rating } from "@mui/material";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
|
type FilterItemOption = {
|
||||||
|
value: string;
|
||||||
|
label: string;
|
||||||
|
};
|
||||||
|
|
||||||
type FilterItemProps = {
|
type FilterItemProps = {
|
||||||
filterName: string;
|
filterName: string;
|
||||||
filterItems: any[];
|
filterItems: FilterItemOption[];
|
||||||
value?: string | null;
|
value?: string | null;
|
||||||
onChange?: (value: string) => void;
|
onChange?: (value: string) => void;
|
||||||
};
|
};
|
||||||
@@ -14,12 +19,14 @@ export default function FilterItem({
|
|||||||
value,
|
value,
|
||||||
onChange
|
onChange
|
||||||
}: FilterItemProps) {
|
}: FilterItemProps) {
|
||||||
if(!value) {
|
if (!value && filterItems.length > 0) {
|
||||||
value = filterItems[0];
|
value = filterItems[0].value;
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
value = (event.target.value);
|
if (onChange) {
|
||||||
|
onChange(event.target.value);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -30,13 +37,13 @@ export default function FilterItem({
|
|||||||
{filterItems.map((item, idx) => (
|
{filterItems.map((item, idx) => (
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
key={idx}
|
key={idx}
|
||||||
value={item}
|
value={item.value}
|
||||||
control={<Radio />}
|
control={<Radio />}
|
||||||
label={
|
label={
|
||||||
filterName === "Rating" ? (
|
/^[1-5]$/.test(item.value) ? (
|
||||||
<Rating readOnly value={Number(item)} precision={1} size="small" />
|
<Rating readOnly value={Number(item.value)} precision={1} size="small" />
|
||||||
) : (
|
) : (
|
||||||
item
|
item.label
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -5,33 +5,36 @@ import SpaIcon from "@mui/icons-material/Spa";
|
|||||||
import { Box, Card, CardActionArea, CardContent, Grid, Typography } from "@mui/material";
|
import { Box, Card, CardActionArea, CardContent, Grid, Typography } from "@mui/material";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import "./pages.css";
|
import "./pages.css";
|
||||||
|
import {useTranslation} from "react-i18next";
|
||||||
const categories = [
|
|
||||||
{
|
|
||||||
name: "Seeds",
|
|
||||||
icon: <SpaIcon sx={{ fontSize: 48, color: "#388e3c" }} />,
|
|
||||||
filter: "Seeds"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Fertilizers",
|
|
||||||
icon: <ScienceIcon sx={{ fontSize: 48, color: "#fbc02d" }} />,
|
|
||||||
filter: "Fertilizers"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Technical Components",
|
|
||||||
icon: <PrecisionManufacturingIcon sx={{ fontSize: 48, color: "#1976d2" }} />,
|
|
||||||
filter: "Technical Components"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Sonstiges",
|
|
||||||
icon: <CategoryIcon sx={{ fontSize: 48, color: "#757575" }} />,
|
|
||||||
filter: "Other"
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
export default function Category() {
|
export default function Category() {
|
||||||
|
|
||||||
|
const { t } = useTranslation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
const categories = [
|
||||||
|
{
|
||||||
|
name: t('seeds'),
|
||||||
|
icon: <SpaIcon sx={{ fontSize: 48, color: "#388e3c" }} />,
|
||||||
|
filter: "Seeds",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: t('gardenSupplies'),
|
||||||
|
icon: <ScienceIcon sx={{ fontSize: 48, color: "#fbc02d" }} />,
|
||||||
|
filter: "GardenSupplies"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: t('technicalComponents'),
|
||||||
|
icon: <PrecisionManufacturingIcon sx={{ fontSize: 48, color: "#1976d2" }} />,
|
||||||
|
filter: "TechnicalComponents"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: t('other'),
|
||||||
|
icon: <CategoryIcon sx={{ fontSize: 48, color: "#757575" }} />,
|
||||||
|
filter: "Other"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
const handleCategoryClick = (filter: string) => {
|
const handleCategoryClick = (filter: string) => {
|
||||||
// Navigiere zur Home-Seite und übergebe die gewählte Kategorie als Query-Parameter
|
// Navigiere zur Home-Seite und übergebe die gewählte Kategorie als Query-Parameter
|
||||||
navigate(`/?category=${encodeURIComponent(filter)}`);
|
navigate(`/?category=${encodeURIComponent(filter)}`);
|
||||||
@@ -39,11 +42,11 @@ export default function Category() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Box className="page-background" sx={{ minHeight: "100vh", pt: 4 }}>
|
<Box className="page-background" sx={{ minHeight: "100vh", pt: 4 }}>
|
||||||
<Typography variant="h4" align="center" gutterBottom>
|
<Typography variant="h3" align="center" gutterBottom>
|
||||||
Kategorien entdecken
|
{t('categories')}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="subtitle1" align="center" sx={{ mb: 4 }}>
|
<Typography variant="subtitle1" align="center" sx={{ mb: 4 }}>
|
||||||
Wähle eine Kategorie, um passende Produkte zu entdecken.
|
...
|
||||||
</Typography>
|
</Typography>
|
||||||
<Grid container spacing={4} justifyContent="center">
|
<Grid container spacing={4} justifyContent="center">
|
||||||
{categories.map((cat) => (
|
{categories.map((cat) => (
|
||||||
|
|||||||
@@ -5,8 +5,12 @@ import FilterItem from "../helper/homepage/FilterItem";
|
|||||||
import ItemCard from "../helper/homepage/ItemCard";
|
import ItemCard from "../helper/homepage/ItemCard";
|
||||||
import "./pages.css"; // Import der CSS-Datei
|
import "./pages.css"; // Import der CSS-Datei
|
||||||
import { useLocation } from "react-router-dom";
|
import { useLocation } from "react-router-dom";
|
||||||
|
import {useTranslation} from "react-i18next";
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
|
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const items: Item[] = [
|
const items: Item[] = [
|
||||||
{
|
{
|
||||||
id: "1",
|
id: "1",
|
||||||
@@ -131,28 +135,42 @@ export default function Home() {
|
|||||||
// Weitere Items hinzufügen
|
// Weitere Items hinzufügen
|
||||||
];
|
];
|
||||||
|
|
||||||
const categoriesFilter: string[] = [
|
const categoriesFilter = [
|
||||||
"Seeds",
|
{ value: "", label: t("all") },
|
||||||
"Fertilizers",
|
{ value: "Seeds", label: t("seeds") },
|
||||||
"Technical Components"
|
{ value: "GardenSupplies", label: t("gardenSupplies") },
|
||||||
|
{ value: "TechnicalComponents", label: t("technicalComponents") },
|
||||||
|
{ value: "Other", label: t("other") }
|
||||||
];
|
];
|
||||||
const priceFilter: string[] = [
|
|
||||||
"< 10",
|
const priceFilter = [
|
||||||
"< 20",
|
{ value: "", label: t("all") },
|
||||||
"> 20"
|
{ value: "< 10", label: "< 10" },
|
||||||
|
{ value: "< 20", label: "< 20" },
|
||||||
|
{ value: ">= 20", label: ">= 20" }
|
||||||
|
];
|
||||||
|
|
||||||
|
const ratingFilter = [
|
||||||
|
{ value: "", label: t("all") },
|
||||||
|
...[5, 4, 3, 2, 1].map(value => ({
|
||||||
|
value: value.toString(),
|
||||||
|
label: value.toString()
|
||||||
|
}))
|
||||||
];
|
];
|
||||||
const ratingFilter: number[] = [1, 2, 3, 4, 5];
|
|
||||||
|
|
||||||
const [currentPage, setCurrentPage] = useState(1); // Zustand für die aktuelle Seite
|
const [currentPage, setCurrentPage] = useState(1); // Zustand für die aktuelle Seite
|
||||||
const [itemsPerPage, setItemsPerPage] = useState(9); // Dynamische Anzahl der Items pro Seite
|
const [itemsPerPage, setItemsPerPage] = useState(9); // Dynamische Anzahl der Items pro Seite
|
||||||
const [visibleItems, setVisibleItems] = useState<Item[]>([]); // Zustand für die sichtbaren Items
|
const [visibleItems, setVisibleItems] = useState<Item[]>([]); // Zustand für die sichtbaren Items
|
||||||
const [selectedCategory, setSelectedCategory] = useState<string | null>(null);
|
const [selectedCategory, setSelectedCategory] = useState<string | null>(null);
|
||||||
|
const [selectedPrice, setSelectedPrice] = useState<string | null>(null);
|
||||||
|
const [selectedRating, setSelectedRating] = useState<string | null>(null);
|
||||||
|
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const params = new URLSearchParams(location.search);
|
const params = new URLSearchParams(location.search);
|
||||||
const category = params.get("category");
|
const category = params.get("category");
|
||||||
if (category && categoriesFilter.includes(category)) {
|
if (category && categoriesFilter.some(filter => filter.value === category)) {
|
||||||
setSelectedCategory(category);
|
setSelectedCategory(category);
|
||||||
}
|
}
|
||||||
}, [location.search]);
|
}, [location.search]);
|
||||||
@@ -163,7 +181,6 @@ export default function Home() {
|
|||||||
// navigate(`/?category=${encodeURIComponent(category)}`);
|
// navigate(`/?category=${encodeURIComponent(category)}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Handler für die Pagination
|
// Handler für die Pagination
|
||||||
const handlePageChange = (event: React.ChangeEvent<unknown>, page: number) => {
|
const handlePageChange = (event: React.ChangeEvent<unknown>, page: number) => {
|
||||||
setCurrentPage(page);
|
setCurrentPage(page);
|
||||||
@@ -197,13 +214,23 @@ export default function Home() {
|
|||||||
<div className="home-page-background">
|
<div className="home-page-background">
|
||||||
<div className="filter-container">
|
<div className="filter-container">
|
||||||
<FilterItem
|
<FilterItem
|
||||||
filterName="Category"
|
filterName={t('category')}
|
||||||
filterItems={categoriesFilter}
|
filterItems={categoriesFilter}
|
||||||
value={selectedCategory}
|
value={selectedCategory}
|
||||||
onChange={handleCategoryChange}
|
onChange={handleCategoryChange}
|
||||||
/>
|
/>
|
||||||
<FilterItem filterName="Price" filterItems={priceFilter} />
|
<FilterItem
|
||||||
<FilterItem filterName="Rating" filterItems={ratingFilter} />
|
filterName={t('price')}
|
||||||
|
filterItems={priceFilter}
|
||||||
|
value={selectedPrice}
|
||||||
|
onChange={setSelectedPrice}
|
||||||
|
/>
|
||||||
|
<FilterItem
|
||||||
|
filterName={t('rating')}
|
||||||
|
filterItems={ratingFilter}
|
||||||
|
value={selectedRating}
|
||||||
|
onChange={setSelectedRating}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="page-background">
|
<div className="page-background">
|
||||||
<Box className="cardgrid">
|
<Box className="cardgrid">
|
||||||
|
|||||||
Reference in New Issue
Block a user