-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add circular progress to workshops page
- Loading branch information
KimiaMontazeri
committed
Nov 27, 2023
1 parent
84e69cb
commit ee6ba85
Showing
1 changed file
with
47 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,51 @@ | ||
import ItemCard from "../../components/item-card/item-card.jsx"; | ||
import Toast from "../../components/toast/Toast.jsx"; | ||
import {Helper} from "../../utils/Helper.js"; | ||
import useWorkshopsPage from "./useWorkshopsPage.js"; | ||
import { CircularProgress } from '@mui/material'; | ||
import ItemCard from '../../components/item-card/item-card.jsx'; | ||
import Toast from '../../components/toast/Toast.jsx'; | ||
import { Helper } from '../../utils/Helper.js'; | ||
import useWorkshopsPage from './useWorkshopsPage.js'; | ||
|
||
export default function WorkshopsPage() { | ||
const { parsedItemsList, addToCart, toastData, setOpenToast, openToast } = useWorkshopsPage(); | ||
|
||
const { | ||
parsedItemsList, | ||
addToCart, | ||
gridTemplateColumnsValue, | ||
toastData, | ||
setOpenToast, | ||
openToast, | ||
} = useWorkshopsPage() | ||
const getItemsList = () => { | ||
if (parsedItemsList) { | ||
return parsedItemsList.map((item, index) => ( | ||
<ItemCard | ||
key={index} | ||
isWorkshop={item.isWorkshop} | ||
title={item.name} | ||
description={item.desc && Helper.omitLongString(item.desc, 50)} | ||
purchaseState={0} | ||
presenterName={item.presenters.join(', ')} | ||
startDate={new Date(item.start_date).toLocaleString()} | ||
endDate={new Date(item.end_date).toLocaleString()} | ||
level={item.level} | ||
onClickAddToCart={() => | ||
addToCart({ | ||
id: item.id, | ||
type: item.isWorkshop ? 'workshop' : 'presentation', | ||
}) | ||
} | ||
/> | ||
)); | ||
} | ||
|
||
return ( | ||
<section style={{ | ||
display: 'flex', | ||
flexWrap: 'wrap', | ||
justifyContent: 'center', | ||
gap: '20px', | ||
}}> | ||
{toastData && <Toast | ||
open={openToast} | ||
setOpen={setOpenToast} | ||
alertType={toastData.type} | ||
message={toastData.message} | ||
/>} | ||
{parsedItemsList && parsedItemsList.map((e, index) => { | ||
return ( | ||
<ItemCard | ||
key={index} | ||
isWorkshop={e.isWorkshop} | ||
title={e.name} | ||
description={e.desc && Helper.omitLongString(e.desc, 50)} | ||
purchaseState={0} | ||
presenterName={e.presenters.join(", ")} | ||
startDate={new Date(e.start_date).toLocaleString()} | ||
endDate={new Date(e.end_date).toLocaleString()} | ||
level={e.level} | ||
onClickAddToCart={() => addToCart({ | ||
id: e.id, | ||
type: e.isWorkshop ? "workshop" : "presentation" | ||
})} | ||
/> | ||
) | ||
})} | ||
</section> | ||
) | ||
} | ||
return <CircularProgress />; | ||
}; | ||
|
||
return ( | ||
<section | ||
style={{ | ||
display: 'flex', | ||
flexWrap: 'wrap', | ||
justifyContent: 'center', | ||
gap: '20px', | ||
}} | ||
> | ||
{toastData && ( | ||
<Toast open={openToast} setOpen={setOpenToast} alertType={toastData.type} message={toastData.message} /> | ||
)} | ||
{getItemsList()} | ||
</section> | ||
); | ||
} |