-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
translate remaining parts of the app
- Loading branch information
1 parent
feef671
commit f491f35
Showing
17 changed files
with
2,005 additions
and
1,197 deletions.
There are no files selected for viewing
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
127 changes: 77 additions & 50 deletions
127
examples/ecommerce-jewellery-store/src/pages/AllProductsListView.tsx
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 |
---|---|---|
@@ -1,99 +1,126 @@ | ||
import * as React from "react"; | ||
|
||
import bracelets from "@/assets/bracelets.png?url"; | ||
import necklace from "@/assets/necklace_1.jfif?url"; | ||
import ring from "@/assets/ring_1.jfif?url"; | ||
import jewel from "@/assets/1111.jfif?url"; | ||
import React, { useState, useEffect, useCallback } from "react"; | ||
import { Layout } from "../components/Layout"; | ||
import { OrderedImgText } from "../components/OrderedImageCard"; | ||
import { CustomSection } from "../components/CustomizedSection"; | ||
import { listData } from "../data/listData"; | ||
import { FilterComponent } from "../components/FilterComponent"; | ||
import { CardsList } from "../components/CardsList"; | ||
import { CategoryList } from "../components/CategoryList"; | ||
import { CardDescriptor } from "../data/types"; | ||
import { DataModel } from "../data/types"; | ||
|
||
import { Breadcrumb } from "@progress/kendo-react-layout"; | ||
import { Button, ButtonGroup } from "@progress/kendo-react-buttons"; | ||
import { layout2By2Icon, gridLayoutIcon } from "@progress/kendo-svg-icons"; | ||
import { process, State } from "@progress/kendo-data-query"; | ||
import getTranslatedListData from "../data/listData"; | ||
import { useStore } from "@nanostores/react"; | ||
import { selectedLanguage } from "../helpers/languageStore"; | ||
|
||
import enMessages from "../data/messages/en"; | ||
import frMessages from "../data/messages/fr"; | ||
import esMessages from "../data/messages/es"; | ||
|
||
const messages = { | ||
en: enMessages, | ||
fr: frMessages, | ||
es: esMessages, | ||
}; | ||
|
||
export const AllProductsListView: React.FC = () => { | ||
const language = useStore(selectedLanguage); | ||
const t = messages[language] || messages["en"]; | ||
const [translatedData, setTranslatedData] = useState(() => getTranslatedListData()); | ||
const [filteredData, setFilteredData] = useState(translatedData); | ||
const [currentLayout, setCurrentLayout] = useState<"grid" | "list">("grid"); | ||
|
||
export const AllProductsListView = () => { | ||
const title = "Fine Selection"; | ||
const subtitle = "Enjoy the real craftsmanship"; | ||
const contentText = | ||
"Jewelry is a meaningful form of self-expression that enhances personal style and adds beauty to any occasion."; | ||
const order = "first"; | ||
useEffect(() => { | ||
const updatedData = getTranslatedListData(); | ||
setTranslatedData(updatedData); | ||
setFilteredData(updatedData); | ||
}, [language]); | ||
|
||
const [data, setData] = React.useState(listData); | ||
|
||
const updateUI = (newState: State) => { | ||
const newData = process(listData, newState) | ||
setData(newData.data) | ||
}; | ||
const updateUI = useCallback( | ||
(newState: State) => { | ||
const updatedData = process(translatedData, newState).data; | ||
setFilteredData(updatedData); | ||
}, | ||
[translatedData] | ||
); | ||
|
||
const cards: CardDescriptor[] = [ | ||
const cards = [ | ||
{ | ||
img: necklace, | ||
collectionText: 'Collection "SERENE"', | ||
img: "/necklace_1.jfif", | ||
collectionText: t.collectionSerene, | ||
}, | ||
{ | ||
img: ring, | ||
collectionText: 'Collection "AURELIA"', | ||
img: "/ring_1.jfif", | ||
collectionText: t.collectionAurelia, | ||
}, | ||
{ | ||
img: jewel, | ||
collectionText: 'Collection "RAVINA"', | ||
img: "/1111.jfif", | ||
collectionText: t.collectionRavina, | ||
}, | ||
]; | ||
|
||
const BreakcrumbData: DataModel[] = [{ | ||
text: "Home" | ||
}, | ||
{ | ||
text: "Jewelry" | ||
}] | ||
const breadcrumbData = [ | ||
{ text: t.breadcrumbHome }, | ||
{ text: t.breadcrumbJewelry }, | ||
]; | ||
|
||
return ( | ||
<> | ||
<Layout> | ||
<section | ||
className="k-d-grid k-grid-cols-12 k-justify-content-center k-align-items-center k-col-span-12" | ||
style={{ | ||
paddingTop: "60px", | ||
}} | ||
style={{ paddingTop: "60px" }} | ||
> | ||
<OrderedImgText | ||
title={title} | ||
subtitle={subtitle} | ||
contentText={contentText} | ||
img={bracelets} | ||
order={order} | ||
title={t.allProductsTitle} | ||
subtitle={t.allProductsSubtitle} | ||
contentText={t.allProductsContentText} | ||
img="/bracelets.png" | ||
order="first" | ||
link={null} | ||
/> | ||
</section> | ||
</Layout> | ||
|
||
<Layout> | ||
<CustomSection> | ||
<CategoryList title="Our Collections" subtitle="Enjoy an excellent selection of fine jewelry" data={cards}></CategoryList> | ||
<CategoryList | ||
title={t.ourCollectionsTitle} | ||
subtitle={t.ourCollectionsSubtitle} | ||
data={cards} | ||
/> | ||
</CustomSection> | ||
</Layout> | ||
|
||
<Layout> | ||
<section className="k-d-flex k-justify-content-between"> | ||
<Breadcrumb data={BreakcrumbData}></Breadcrumb> | ||
<section className="k-d-flex k-justify-content-between k-align-items-center k-py-4"> | ||
<Breadcrumb data={breadcrumbData} /> | ||
<ButtonGroup> | ||
<Button fillMode={"flat"} svgIcon={gridLayoutIcon}></Button> | ||
<Button fillMode={"flat"} svgIcon={layout2By2Icon}></Button> | ||
<Button | ||
fillMode="flat" | ||
svgIcon={gridLayoutIcon} | ||
selected={currentLayout === "grid"} | ||
onClick={() => setCurrentLayout("grid")} | ||
/> | ||
<Button | ||
fillMode="flat" | ||
svgIcon={layout2By2Icon} | ||
selected={currentLayout === "list"} | ||
onClick={() => setCurrentLayout("list")} | ||
/> | ||
</ButtonGroup> | ||
</section> | ||
</Layout> | ||
|
||
<Layout> | ||
<FilterComponent updateUI={updateUI}></FilterComponent> | ||
<FilterComponent updateUI={updateUI} /> | ||
</Layout> | ||
|
||
<Layout> | ||
<CardsList data={data}></CardsList> | ||
<CardsList data={filteredData} layout={currentLayout} /> | ||
</Layout> | ||
</> | ||
); | ||
}; | ||
|
||
export default AllProductsListView; |
Oops, something went wrong.