Skip to content

Commit

Permalink
Merge pull request #65 from AAISS/finished-events-flag
Browse files Browse the repository at this point in the history
Finished events flag
  • Loading branch information
AlirezaYousefpourM authored Dec 6, 2023
2 parents 4372d17 + 43d9ebf commit d878416
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
8 changes: 8 additions & 0 deletions frontend/src/components/item-card/item-card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const ItemCard = ({
startDate,
endDate,
presenterName,
finished,
level,
cost = 50000,
purchaseState = 0, // 0 -> not purchased, 1 -> in cart, 2 -> purchased
Expand Down Expand Up @@ -169,6 +170,12 @@ const ItemCard = ({
{levelComponentMapping[level]}
{!hasBought && <Cost cost={cost} />}
{!hasBought && shouldShowFullCapacity && <FullCapacityChip />}
{finished && <div style={{
backgroundColor: "grey",
borderRadius: "5px",
display: "inline-block",
padding: "2px 5px 2px 5px"
}}>Finished!</div>}
</CardContent>
<CardActions
sx={{
Expand Down Expand Up @@ -208,6 +215,7 @@ ItemCard.propTypes = {
addToCalendarLink: PropTypes.string,
onClickAddToCart: PropTypes.func,
remainingCapacity: PropTypes.number,
finished: PropTypes.bool,
};

export default ItemCard;
2 changes: 0 additions & 2 deletions frontend/src/pages/my-account/useMyAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,6 @@ export default function useMyAccount() {
})
}

console.log(userTempCart)

setTalks(userTempPresentations)
setWorkshops(userTempWorkshops)
setCart(userTempCart)
Expand Down
1 change: 1 addition & 0 deletions frontend/src/pages/workshops/WorkshopsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default function WorkshopsPage() {
capacity={item.capacity}
cost={item.cost}
hasProject={item.has_project}
finished={item.finished}
onClickAddToCart={() =>
addToCart({
id: item.id,
Expand Down
25 changes: 12 additions & 13 deletions frontend/src/pages/workshops/useWorkshopsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export default function useWorkshopsPage() {

const handleCheckbox = useCallback(e => {
setRadioSelectedItem(e.target.value)
console.log(e.target.value)
}, [])

useEffect(() => {
Expand Down Expand Up @@ -113,39 +112,39 @@ export default function useWorkshopsPage() {
item['capacity'] = workshop.capacity;
item['cost'] = workshop.cost;
item['remaining_capacity'] = workshop.remaining_capacity
item['finished'] = false
return item;
})
.filter((e) => e != null);
parsedData.sort((a, b) => a.start_date > b.start_date ? 1 : -1)

const now = removeEverythingFromDateString(new Date().toLocaleString('fa-IR-u-nu-latn'))
let index = -1
console.log("now:", now)
for (const item of parsedData) {
const itemDate = removeEverythingFromDateString(new Date(item.start_date).toLocaleString('fa-IR-u-nu-latn'))
console.log(itemDate, now, itemDate > now)
index++
if (itemDate > now)
break
item['finished'] = true
}

const notEligibleItems = parsedData.slice(0, index)
parsedData = parsedData.slice(index)
parsedData.push(...notEligibleItems)
console.log(parsedData)
console.log(index)
setParsedItemsList(parsedData);
setFileteredItems(parsedData);

function removeEverythingFromDateString(str) {
const splittedStr = str.split('/')
if (splittedStr[1].length === 1)
splittedStr[1] = '0' + splittedStr[1]
const secondSplittedStr = splittedStr[2].split(",")
if (secondSplittedStr[0].length === 1)
splittedStr[2] = "0" + secondSplittedStr.join(",")
str = splittedStr.join('/')
console.log(str)
const splitStr = str.split('/')
if (splitStr[1].length === 1)
splitStr[1] = '0' + splitStr[1]
const secondSplitStr = splitStr[2].split(",")
if (secondSplitStr[0].length === 1)
splitStr[2] = "0" + secondSplitStr.join(",")
const timeSplitStr = splitStr[2].split(",")[1].split(":")[0].trim()
if (timeSplitStr.length === 1)
splitStr[2] = splitStr[2].split(",")[0] + "0" + splitStr[2].split(",")[1].split(":")[0].trim()
str = splitStr.join('/')
return str
.replaceAll("/", '')
.replaceAll(" ", '')
Expand Down
1 change: 0 additions & 1 deletion frontend/src/providers/APIProvider/APIProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export function APIProvider({ children }) {
.catch((error) => {
if (error == null) return;

console.log(error);
if (error.response.status === 401) {
localStorage.removeItem('user');
window.location.reload();
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/providers/config-provider/ConfigProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@ export function ConfigProvider({ children }) {
if (!currentPath) return;
switch ('/' + currentPath) {
case ROUTES.myAccount.path:
console.log('myacc');
if (!accessToken) {
window.location.replace(ROUTES.signup.path);
// navigate(ROUTES.signup.path)
}
break;
case ROUTES.signup.path:
console.log('sign');
if (accessToken) {
window.location.replace(ROUTES.myAccount.path);
// navigate(ROUTES.myAccount.path)
Expand Down

0 comments on commit d878416

Please sign in to comment.