add shopping list to flatastic
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { useFlatasticStore } from "@/store/flatastic";
|
import { useFlatasticStore } from "@/store/flatastic";
|
||||||
import type { FlatasticChore, FlatasticUser } from "@/types/flatasticChore";
|
import type { FlatasticChore, FlatasticShoppingItem, FlatasticUser } from "@/types/flatasticChore";
|
||||||
import style from "./style.module.css";
|
import style from "./style.module.css";
|
||||||
|
|
||||||
function choreItem(chore: FlatasticChore, idToNameMap: Record<number, string>) {
|
function choreItem(chore: FlatasticChore, idToNameMap: Record<number, string>) {
|
||||||
@@ -84,22 +84,17 @@ export default function Flatastic() {
|
|||||||
return choreItem(chore, idToNameMap);
|
return choreItem(chore, idToNameMap);
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: implement shopping list
|
const shoppingList = flatasticData?.shoppingList || [];
|
||||||
// const shoppingList = flatasticData?.shoppingList || [];
|
|
||||||
|
|
||||||
// const shoppingListRender = shoppingList.map((item) => {
|
const shoppingListRender = shoppingList.map((item) => {
|
||||||
// return (
|
return shoppingItem(item);
|
||||||
// <li key={item.id} className={style.shoppingListItem}>
|
});
|
||||||
// {item.itemName}
|
const shoppingListContainer = shoppingList.length > 0 && (
|
||||||
// </li>
|
<div className={style.shoppingListContainer}>
|
||||||
// );
|
<h1>Shopping List</h1>
|
||||||
// });
|
<ul className={style.shoppingList}>{shoppingListRender}</ul>
|
||||||
// const shoppingListContainer = shoppingList.length > 0 && (
|
</div>
|
||||||
// <div className={style.shoppingListContainer}>
|
);
|
||||||
// <h1>Shopping List</h1>
|
|
||||||
// <ul className={style.shoppingList}>{shoppingListRender}</ul>
|
|
||||||
// </div>
|
|
||||||
// );
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={style.container}>
|
<div className={style.container}>
|
||||||
@@ -110,7 +105,16 @@ export default function Flatastic() {
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* {shoppingListContainer} */}
|
{shoppingListContainer}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function shoppingItem(item: FlatasticShoppingItem) {
|
||||||
|
return (
|
||||||
|
<li key={item.id} className={style.shoppingListItem}>
|
||||||
|
{item.itemName}
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -14,10 +14,23 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.shoppingList {
|
.shoppingList {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
padding: 10px 0;
|
padding: 10px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.shoppingListItem {
|
||||||
|
padding: 5px 10px;
|
||||||
|
text-align: left;
|
||||||
|
border-top: 2px solid white;
|
||||||
|
border-left: 2px solid white;
|
||||||
|
border-bottom: 2px solid #828282;
|
||||||
|
border-right: 2px solid #828282;
|
||||||
|
}
|
||||||
|
|
||||||
.choreList {
|
.choreList {
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -55,4 +68,4 @@
|
|||||||
|
|
||||||
.timeLeft {
|
.timeLeft {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,6 @@ import Flatastic from "@/api/flatastic";
|
|||||||
import type {
|
import type {
|
||||||
FlatasticChore,
|
FlatasticChore,
|
||||||
FlatasticShoppingItem,
|
FlatasticShoppingItem,
|
||||||
FlatasticShoppingList,
|
|
||||||
FlatasticUser,
|
FlatasticUser,
|
||||||
} from "@/types/flatasticChore";
|
} from "@/types/flatasticChore";
|
||||||
|
|
||||||
@@ -22,7 +21,7 @@ const useFlatasticStore = create(
|
|||||||
flatasticData: {
|
flatasticData: {
|
||||||
chores: [] as FlatasticChore[],
|
chores: [] as FlatasticChore[],
|
||||||
users: [] as FlatasticUser[],
|
users: [] as FlatasticUser[],
|
||||||
shoppingList: [] as FlatasticShoppingList[],
|
shoppingList: [] as FlatasticShoppingItem[],
|
||||||
},
|
},
|
||||||
fetch: async () => {
|
fetch: async () => {
|
||||||
if (!import.meta.env.VITE_FLATTASTIC_API_KEY) {
|
if (!import.meta.env.VITE_FLATTASTIC_API_KEY) {
|
||||||
@@ -53,7 +52,7 @@ const useFlatasticStore = create(
|
|||||||
chores: taskList as FlatasticChore[],
|
chores: taskList as FlatasticChore[],
|
||||||
users: parseInformationData(generalInformatiom),
|
users: parseInformationData(generalInformatiom),
|
||||||
shoppingList:
|
shoppingList:
|
||||||
filteredShoppingList as FlatasticShoppingList[],
|
filteredShoppingList as FlatasticShoppingItem[],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -14,10 +14,6 @@ interface FlatasticShoppingItem {
|
|||||||
id: string;
|
id: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface FlatasticShoppingList {
|
|
||||||
items: Array<FlatasticShoppingItem>;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface FlatasticChore {
|
interface FlatasticChore {
|
||||||
id: number;
|
id: number;
|
||||||
title: string;
|
title: string;
|
||||||
@@ -30,10 +26,4 @@ interface FlatasticChore {
|
|||||||
timeLeftNext: number;
|
timeLeftNext: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type {
|
export type { Flatastic, FlatasticChore, FlatasticShoppingItem, FlatasticUser };
|
||||||
Flatastic,
|
|
||||||
FlatasticChore,
|
|
||||||
FlatasticShoppingItem,
|
|
||||||
FlatasticShoppingList,
|
|
||||||
FlatasticUser,
|
|
||||||
};
|
|
||||||
|
|||||||
Reference in New Issue
Block a user