mirror of
https://github.com/urosran/cally.git
synced 2025-07-16 18:16:17 +00:00
- Added Done category in the grocery list and pushed it to the bottom
This commit is contained in:
@ -51,9 +51,12 @@ const GroceryList = ({onInputFocus}: {onInputFocus: (y: number) => void}) => {
|
|||||||
const [choreDialogVisible, setChoreDialogVisible] = useState<boolean>(false);
|
const [choreDialogVisible, setChoreDialogVisible] = useState<boolean>(false);
|
||||||
|
|
||||||
// Group approved groceries by category
|
// Group approved groceries by category
|
||||||
const approvedGroceriesByCategory = approvedGroceries?.reduce(
|
let approvedGroceriesByCategory = approvedGroceries?.reduce(
|
||||||
(groups: any, item: IGrocery) => {
|
(groups: any, item: IGrocery) => {
|
||||||
const category = item.category || "Uncategorized";
|
let category = item.category || "Uncategorized";
|
||||||
|
if (item.bought) {
|
||||||
|
category = "Done";
|
||||||
|
}
|
||||||
if (!groups[category]) {
|
if (!groups[category]) {
|
||||||
groups[category] = [];
|
groups[category] = [];
|
||||||
}
|
}
|
||||||
@ -261,7 +264,11 @@ const GroceryList = ({onInputFocus}: {onInputFocus: (y: number) => void}) => {
|
|||||||
{approvedGroceries?.length > 0
|
{approvedGroceries?.length > 0
|
||||||
? approvedVisible && (
|
? approvedVisible && (
|
||||||
<FlatList
|
<FlatList
|
||||||
data={Object.keys(approvedGroceriesByCategory)}
|
data={Object.keys(approvedGroceriesByCategory).sort((a, b) => {
|
||||||
|
if (a !== "Done") return -1;
|
||||||
|
if (b === "Done") return 1;
|
||||||
|
return 0;
|
||||||
|
})}
|
||||||
renderItem={({item: category}) => (
|
renderItem={({item: category}) => (
|
||||||
<View key={category}>
|
<View key={category}>
|
||||||
{/* Render Category Header */}
|
{/* Render Category Header */}
|
||||||
|
Reference in New Issue
Block a user