From 9a972d9332fd55e4828a64bf872f573cf5c0e1b3 Mon Sep 17 00:00:00 2001 From: Sarah Meko Date: Tue, 17 Sep 2024 08:51:18 -0700 Subject: [PATCH 01/11] implemented getDaysBetweenDate to get days until next purchase --- src/api/firebase.js | 40 ++++++++++++++++++++++++++++++++++++++++ src/views/List.jsx | 3 +++ 2 files changed, 43 insertions(+) diff --git a/src/api/firebase.js b/src/api/firebase.js index 72a4dd5..896016b 100644 --- a/src/api/firebase.js +++ b/src/api/firebase.js @@ -235,3 +235,43 @@ export async function deleteItem() { * this function must accept! */ } + +// api/firestore.js exports a new comparePurchaseUrgency function with the following behaviors +// sorts inactive items last, then +// sorts items in ascending order of days until purchase, and +// sorts items with the same days until purchase alphabetically + +// if daysBetweenNextPurchase >= 60, then the item is inactive. Else, the item is active. + +export async function comparePurchaseUrgency(list) { + //calculate date + const currentDate = new Date(); + + // const daysUntilNextPurchase = getDaysBetweenDates( + // dateNextPurchased, + // currentDate + // ); + + list.forEach((x) => { + const dateNextPurchasedAsDate = x.dateNextPurchased?.toDate(); + + const daysUntilNextPurchase = getDaysBetweenDates( + currentDate, + dateNextPurchasedAsDate, + ); + + console.log(x); + console.log( + 'currentDate: ', + currentDate, + 'x.dateNextPurchased: ', + x.dateNextPurchased, + ); + console.log('daysUntilNextPurchase: ', daysUntilNextPurchase); + }); + + // const urgent = items.filter(x => daysUntilNextPurchase < 7) + // const soon = items.filter(x => daysUntilNextPurchase >= 7) + // const kindOfSoon = items.filter(x => daysUntilNextPurchase < 7 && <= 14) + // const notSoon = items.filter(x => daysUntilNextPurchase < 14 && <= 21) +} diff --git a/src/views/List.jsx b/src/views/List.jsx index 7fe9ee0..e802ad6 100644 --- a/src/views/List.jsx +++ b/src/views/List.jsx @@ -1,6 +1,7 @@ import { ListItem } from '../components'; import { useState, useEffect } from 'react'; import BasicModal from './Modal'; +import { comparePurchaseUrgency } from '../api'; export function List({ data, userId }) { const [filterVal, setFilterVal] = useState(''); @@ -44,6 +45,8 @@ export function List({ data, userId }) { )} + +
Date: Tue, 17 Sep 2024 09:05:42 -0700 Subject: [PATCH 02/11] filtered list by daysLastPurchased and saved into arrays --- src/api/firebase.js | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/api/firebase.js b/src/api/firebase.js index 896016b..18f3971 100644 --- a/src/api/firebase.js +++ b/src/api/firebase.js @@ -251,6 +251,10 @@ export async function comparePurchaseUrgency(list) { // dateNextPurchased, // currentDate // ); + const soon = []; + const kindOfSoon = []; + const notSoon = []; + const inactive = []; list.forEach((x) => { const dateNextPurchasedAsDate = x.dateNextPurchased?.toDate(); @@ -260,7 +264,7 @@ export async function comparePurchaseUrgency(list) { dateNextPurchasedAsDate, ); - console.log(x); + // console.log(x); console.log( 'currentDate: ', currentDate, @@ -268,10 +272,29 @@ export async function comparePurchaseUrgency(list) { x.dateNextPurchased, ); console.log('daysUntilNextPurchase: ', daysUntilNextPurchase); + + if (daysUntilNextPurchase <= 7) { + soon.push(x); + console.log('SOON - it pushed!'); + } else if (daysUntilNextPurchase > 7 && daysUntilNextPurchase < 30) { + kindOfSoon.push(x); + console.log('KINDOFSOON - it pushed!'); + } else if (daysUntilNextPurchase >= 30 && daysUntilNextPurchase < 60) { + notSoon.push(x); + console.log('NOT SOON - it pushed!'); + } else if (daysUntilNextPurchase >= 30 && daysUntilNextPurchase < 60) { + inactive.push(x); + console.log('INACTIVE - it pushed!'); + } }); - // const urgent = items.filter(x => daysUntilNextPurchase < 7) - // const soon = items.filter(x => daysUntilNextPurchase >= 7) + console.log('soon: ', soon); + console.log('kinda: ', kindOfSoon); + console.log('not: ', notSoon); + console.log('inactive: ', inactive); + + // return soon , kindoFs // const kindOfSoon = items.filter(x => daysUntilNextPurchase < 7 && <= 14) // const notSoon = items.filter(x => daysUntilNextPurchase < 14 && <= 21) + // const inactive = items.filter(x => daysUntilNextPurchase < 14 && <= 21) } From 0ed0a0d698c8667cabb878ce7a1fc19e4f7187ea Mon Sep 17 00:00:00 2001 From: Sarah Meko Date: Tue, 17 Sep 2024 09:37:42 -0700 Subject: [PATCH 03/11] created a sorted list before filtering --- src/api/firebase.js | 48 +++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/src/api/firebase.js b/src/api/firebase.js index 18f3971..e777f7d 100644 --- a/src/api/firebase.js +++ b/src/api/firebase.js @@ -256,6 +256,34 @@ export async function comparePurchaseUrgency(list) { const notSoon = []; const inactive = []; + // console.log('sorting', list.sort((a,b) => { + // const dateNextPurchasedAsDateA = a.dateNextPurchased?.toDate(); + // const dateNextPurchasedAsDateB = b.dateNextPurchased?.toDate(); + + // const daysUntilNextPurchase = getDaysBetweenDates( + // currentDate, + // dateNextPurchasedAsDateA, + // ); + // daysUntilNextPurchase(a) - daysUntilNextPurchase(b) + // })) + + const sortedList = list.sort((a, b) => { + const dateNextPurchasedAsDateA = a.dateNextPurchased?.toDate(); + const dateNextPurchasedAsDateB = b.dateNextPurchased?.toDate(); + + const daysUntilNextPurchaseA = getDaysBetweenDates( + currentDate, + dateNextPurchasedAsDateA, + ); + const daysUntilNextPurchaseB = getDaysBetweenDates( + currentDate, + dateNextPurchasedAsDateB, + ); + + return daysUntilNextPurchaseA > daysUntilNextPurchaseB ? 1 : -1; + }); + console.log('ALERT!! its sorted', sortedList); + list.forEach((x) => { const dateNextPurchasedAsDate = x.dateNextPurchased?.toDate(); @@ -264,17 +292,9 @@ export async function comparePurchaseUrgency(list) { dateNextPurchasedAsDate, ); - // console.log(x); - console.log( - 'currentDate: ', - currentDate, - 'x.dateNextPurchased: ', - x.dateNextPurchased, - ); - console.log('daysUntilNextPurchase: ', daysUntilNextPurchase); - if (daysUntilNextPurchase <= 7) { soon.push(x); + // soon.sort((x,b) => x.dateNextPurchased - b.dateNextPurchased) console.log('SOON - it pushed!'); } else if (daysUntilNextPurchase > 7 && daysUntilNextPurchase < 30) { kindOfSoon.push(x); @@ -288,13 +308,15 @@ export async function comparePurchaseUrgency(list) { } }); + // soon.sort((a,b) => a.daysUntilNextPurchase - b.daysUntilNextPurchase); + // kindOfSoon.sort((a,b) => a.daysUntilNextPurchase - b.daysUntilNextPurchase); + // notSoon.sort((a,b) => a.daysUntilNextPurchase - b.daysUntilNextPurchase); + // inactive.sort((a,b) => a.daysUntilNextPurchase - b.daysUntilNextPurchase); + console.log('soon: ', soon); console.log('kinda: ', kindOfSoon); console.log('not: ', notSoon); console.log('inactive: ', inactive); - // return soon , kindoFs - // const kindOfSoon = items.filter(x => daysUntilNextPurchase < 7 && <= 14) - // const notSoon = items.filter(x => daysUntilNextPurchase < 14 && <= 21) - // const inactive = items.filter(x => daysUntilNextPurchase < 14 && <= 21) + return; } From b36e20dbebf0e2d19c01a7bd52947384aac2794e Mon Sep 17 00:00:00 2001 From: Sarah Meko Date: Tue, 17 Sep 2024 09:56:17 -0700 Subject: [PATCH 04/11] sorted list alphabetically if same dateBetween --- src/api/firebase.js | 49 ++++++++------------------------------------- 1 file changed, 8 insertions(+), 41 deletions(-) diff --git a/src/api/firebase.js b/src/api/firebase.js index e777f7d..0599df5 100644 --- a/src/api/firebase.js +++ b/src/api/firebase.js @@ -236,37 +236,13 @@ export async function deleteItem() { */ } -// api/firestore.js exports a new comparePurchaseUrgency function with the following behaviors -// sorts inactive items last, then -// sorts items in ascending order of days until purchase, and -// sorts items with the same days until purchase alphabetically - -// if daysBetweenNextPurchase >= 60, then the item is inactive. Else, the item is active. - export async function comparePurchaseUrgency(list) { - //calculate date const currentDate = new Date(); - - // const daysUntilNextPurchase = getDaysBetweenDates( - // dateNextPurchased, - // currentDate - // ); const soon = []; const kindOfSoon = []; const notSoon = []; const inactive = []; - // console.log('sorting', list.sort((a,b) => { - // const dateNextPurchasedAsDateA = a.dateNextPurchased?.toDate(); - // const dateNextPurchasedAsDateB = b.dateNextPurchased?.toDate(); - - // const daysUntilNextPurchase = getDaysBetweenDates( - // currentDate, - // dateNextPurchasedAsDateA, - // ); - // daysUntilNextPurchase(a) - daysUntilNextPurchase(b) - // })) - const sortedList = list.sort((a, b) => { const dateNextPurchasedAsDateA = a.dateNextPurchased?.toDate(); const dateNextPurchasedAsDateB = b.dateNextPurchased?.toDate(); @@ -280,11 +256,11 @@ export async function comparePurchaseUrgency(list) { dateNextPurchasedAsDateB, ); - return daysUntilNextPurchaseA > daysUntilNextPurchaseB ? 1 : -1; + return daysUntilNextPurchaseB > daysUntilNextPurchaseA ? -1 : 1; }); console.log('ALERT!! its sorted', sortedList); - list.forEach((x) => { + sortedList.forEach((x) => { const dateNextPurchasedAsDate = x.dateNextPurchased?.toDate(); const daysUntilNextPurchase = getDaysBetweenDates( @@ -294,29 +270,20 @@ export async function comparePurchaseUrgency(list) { if (daysUntilNextPurchase <= 7) { soon.push(x); - // soon.sort((x,b) => x.dateNextPurchased - b.dateNextPurchased) - console.log('SOON - it pushed!'); } else if (daysUntilNextPurchase > 7 && daysUntilNextPurchase < 30) { kindOfSoon.push(x); - console.log('KINDOFSOON - it pushed!'); } else if (daysUntilNextPurchase >= 30 && daysUntilNextPurchase < 60) { notSoon.push(x); - console.log('NOT SOON - it pushed!'); } else if (daysUntilNextPurchase >= 30 && daysUntilNextPurchase < 60) { inactive.push(x); - console.log('INACTIVE - it pushed!'); } }); - // soon.sort((a,b) => a.daysUntilNextPurchase - b.daysUntilNextPurchase); - // kindOfSoon.sort((a,b) => a.daysUntilNextPurchase - b.daysUntilNextPurchase); - // notSoon.sort((a,b) => a.daysUntilNextPurchase - b.daysUntilNextPurchase); - // inactive.sort((a,b) => a.daysUntilNextPurchase - b.daysUntilNextPurchase); - - console.log('soon: ', soon); - console.log('kinda: ', kindOfSoon); - console.log('not: ', notSoon); - console.log('inactive: ', inactive); + // console.log('soon: ', soon); + // console.log('kinda: ', kindOfSoon); + // console.log('not: ', notSoon); + // console.log('inactive: ', inactive); - return; + console.log([...soon, ...kindOfSoon, ...notSoon, ...inactive]); + return [...soon, ...kindOfSoon, ...notSoon, ...inactive]; } From 4cc019174a603b895acfee7ea72d915de40383cc Mon Sep 17 00:00:00 2001 From: arandel1 Date: Wed, 18 Sep 2024 15:21:15 -0500 Subject: [PATCH 05/11] list renders in order of how soon dateNextPurchase is -- not separated out by category of soonness --- src/api/firebase.js | 10 +++++++--- src/views/List.jsx | 8 ++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/api/firebase.js b/src/api/firebase.js index 0599df5..52fcf17 100644 --- a/src/api/firebase.js +++ b/src/api/firebase.js @@ -258,7 +258,7 @@ export async function comparePurchaseUrgency(list) { return daysUntilNextPurchaseB > daysUntilNextPurchaseA ? -1 : 1; }); - console.log('ALERT!! its sorted', sortedList); + // console.log('ALERT!! its sorted', sortedList); sortedList.forEach((x) => { const dateNextPurchasedAsDate = x.dateNextPurchased?.toDate(); @@ -284,6 +284,10 @@ export async function comparePurchaseUrgency(list) { // console.log('not: ', notSoon); // console.log('inactive: ', inactive); - console.log([...soon, ...kindOfSoon, ...notSoon, ...inactive]); - return [...soon, ...kindOfSoon, ...notSoon, ...inactive]; + // console.log([...soon, ...kindOfSoon, ...notSoon, ...inactive]); + // console.log('soon', soon) + // console.log( 'kinda' , kindOfSoon) + // console.log( 'notsoon', notSoon) + // console.log('inactive', inactive) + return soon; } diff --git a/src/views/List.jsx b/src/views/List.jsx index e802ad6..da70fca 100644 --- a/src/views/List.jsx +++ b/src/views/List.jsx @@ -29,6 +29,8 @@ export function List({ data, userId }) { }; useEffect(() => { + comparePurchaseUrgency(data); + setFilteredList( data.filter((item) => item.name.toLowerCase().includes(filterVal.toLowerCase()), @@ -36,6 +38,12 @@ export function List({ data, userId }) { ); }, [filterVal, data]); + // useEffect(() => { + // setFilteredList(comparePurchaseUrgency(data)) + // }, [data]); + + // console.log(filteredList) + return ( <>

From ff64cbc01a7afbed65b95220a1c8ec24c579e0b4 Mon Sep 17 00:00:00 2001 From: arandel1 Date: Wed, 18 Sep 2024 16:04:50 -0500 Subject: [PATCH 06/11] beginning of incorporating mindy suggestions --- src/api/firebase.js | 9 +++++++-- src/views/List.jsx | 39 +++++++++++++++++++++++++++++++-------- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/src/api/firebase.js b/src/api/firebase.js index 52fcf17..d2c8d92 100644 --- a/src/api/firebase.js +++ b/src/api/firebase.js @@ -236,7 +236,7 @@ export async function deleteItem() { */ } -export async function comparePurchaseUrgency(list) { +export function comparePurchaseUrgency(list) { const currentDate = new Date(); const soon = []; const kindOfSoon = []; @@ -289,5 +289,10 @@ export async function comparePurchaseUrgency(list) { // console.log( 'kinda' , kindOfSoon) // console.log( 'notsoon', notSoon) // console.log('inactive', inactive) - return soon; + return { + soon, + kindOfSoon, + notSoon, + inactive, + }; } diff --git a/src/views/List.jsx b/src/views/List.jsx index da70fca..abbea06 100644 --- a/src/views/List.jsx +++ b/src/views/List.jsx @@ -6,6 +6,7 @@ import { comparePurchaseUrgency } from '../api'; export function List({ data, userId }) { const [filterVal, setFilterVal] = useState(''); const [filteredList, setFilteredList] = useState([]); + const [sortedList, setSortedList] = useState([]); const [showModal, setShowModal] = useState(false); const dataEmpty = userId && !data.length; @@ -29,14 +30,29 @@ export function List({ data, userId }) { }; useEffect(() => { - comparePurchaseUrgency(data); + // const { soon, kindOfSoon, notSoon, inactive } = comparePurchaseUrgency(data) + setSortedList(comparePurchaseUrgency(data)); + }, [data]); - setFilteredList( - data.filter((item) => - item.name.toLowerCase().includes(filterVal.toLowerCase()), - ), - ); - }, [filterVal, data]); + // useEffect(() => { + // comparePurchaseUrgency(data); + // // setFilteredList( + // // data.filter((item) => + // // item.name.toLowerCase().includes(filterVal.toLowerCase()), + // // ), + // // ); + + // // { + // // 'soon', [....], + // // 'kindOfSoon', [...] + // // } + // // const filteredObject = {} + + // // Object.entries(sortedList).forEach([timeBucket, list]) => { + // // filteredObject[timeBucket] = list.filter() + // // } + // // setFilteredObject(filteredObject) + // }, [filterVal, data]); // useEffect(() => { // setFilteredList(comparePurchaseUrgency(data)) @@ -67,11 +83,18 @@ export function List({ data, userId }) { {filterVal && } -

    + {/*
      {filteredList && filteredList.map((item) => { return ; })} +
    */} + {/* {console.log(sortedList.forEach(x => x))} */} +
      + {sortedList && + sortedList.map((item) => { + return ; + })}
    ); From 0c814b69c37b40d57c151cdebbebce931894a2a1 Mon Sep 17 00:00:00 2001 From: Sarah Meko Date: Wed, 18 Sep 2024 14:28:01 -0700 Subject: [PATCH 07/11] rendering sortedList with object.enteries and mapping through --- src/views/List.jsx | 44 +++++++++++++------------------------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/src/views/List.jsx b/src/views/List.jsx index abbea06..b868a1b 100644 --- a/src/views/List.jsx +++ b/src/views/List.jsx @@ -5,7 +5,7 @@ import { comparePurchaseUrgency } from '../api'; export function List({ data, userId }) { const [filterVal, setFilterVal] = useState(''); - const [filteredList, setFilteredList] = useState([]); + // const [filteredList, setFilteredList] = useState([]); const [sortedList, setSortedList] = useState([]); const [showModal, setShowModal] = useState(false); @@ -30,35 +30,13 @@ export function List({ data, userId }) { }; useEffect(() => { - // const { soon, kindOfSoon, notSoon, inactive } = comparePurchaseUrgency(data) setSortedList(comparePurchaseUrgency(data)); }, [data]); - // useEffect(() => { - // comparePurchaseUrgency(data); - // // setFilteredList( - // // data.filter((item) => - // // item.name.toLowerCase().includes(filterVal.toLowerCase()), - // // ), - // // ); - - // // { - // // 'soon', [....], - // // 'kindOfSoon', [...] - // // } - // // const filteredObject = {} - - // // Object.entries(sortedList).forEach([timeBucket, list]) => { - // // filteredObject[timeBucket] = list.filter() - // // } - // // setFilteredObject(filteredObject) - // }, [filterVal, data]); - - // useEffect(() => { - // setFilteredList(comparePurchaseUrgency(data)) - // }, [data]); - - // console.log(filteredList) + const labels = { + soon: 'Soon', + kindOfSoon: 'Kind of soon', + }; return ( <> @@ -91,10 +69,14 @@ export function List({ data, userId }) {
*/} {/* {console.log(sortedList.forEach(x => x))} */}
    - {sortedList && - sortedList.map((item) => { - return ; - })} + {Object.entries(sortedList).map(([timeBucket, list]) => ( + <> +
    {labels[timeBucket]}
    + {list.map((item) => ( + + ))} + + ))}
); From 9dff0c9caf38cff00da3942b85acf957cd04034f Mon Sep 17 00:00:00 2001 From: Sarah Meko Date: Thu, 19 Sep 2024 10:45:10 -0700 Subject: [PATCH 08/11] incorporated filtered list and changed its dependency to sortedlist --- src/api/firebase.js | 2 +- src/views/List.jsx | 48 +++++++++++++++++++++++++++++++++++---------- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/api/firebase.js b/src/api/firebase.js index d2c8d92..aa14d9d 100644 --- a/src/api/firebase.js +++ b/src/api/firebase.js @@ -274,7 +274,7 @@ export function comparePurchaseUrgency(list) { kindOfSoon.push(x); } else if (daysUntilNextPurchase >= 30 && daysUntilNextPurchase < 60) { notSoon.push(x); - } else if (daysUntilNextPurchase >= 30 && daysUntilNextPurchase < 60) { + } else if (daysUntilNextPurchase >= 60) { inactive.push(x); } }); diff --git a/src/views/List.jsx b/src/views/List.jsx index b868a1b..d7abdb0 100644 --- a/src/views/List.jsx +++ b/src/views/List.jsx @@ -5,7 +5,7 @@ import { comparePurchaseUrgency } from '../api'; export function List({ data, userId }) { const [filterVal, setFilterVal] = useState(''); - // const [filteredList, setFilteredList] = useState([]); + const [filteredObject, setFilteredObject] = useState({}); const [sortedList, setSortedList] = useState([]); const [showModal, setShowModal] = useState(false); @@ -36,8 +36,33 @@ export function List({ data, userId }) { const labels = { soon: 'Soon', kindOfSoon: 'Kind of soon', + notSoon: 'Not soon', + inactive: 'Inactive Items', }; + useEffect(() => { + // setFilteredObject( + // data.filter((item) => + // item.name.toLowerCase().includes(filterVal.toLowerCase()), + // ), + // ); + + const filteredObject = {}; + + Object.entries(sortedList).forEach(([timeBucket, list]) => { + filteredObject[timeBucket] = list.filter((item) => + item.name.toLowerCase().includes(filterVal.toLowerCase()), + ); + }); + setFilteredObject(filteredObject); + }, [filterVal, sortedList]); + + // useEffect(() => { + // setFilteredList(comparePurchaseUrgency(data)) + // }, [data]); + + // console.log(filteredList) + return ( <>

@@ -50,7 +75,7 @@ export function List({ data, userId }) {

- + */} {/* {console.log(sortedList.forEach(x => x))} */}
    - {Object.entries(sortedList).map(([timeBucket, list]) => ( - <> -
    {labels[timeBucket]}
    - {list.map((item) => ( - - ))} - - ))} + {filteredObject && + Object.entries(filteredObject).map(([timeBucket, list]) => ( + <> +
    +

    {labels[timeBucket]}

    +
    + {list.map((item) => ( + + ))} + + ))}
); From 7d314d107a414fafb477d883ae0bb7898825536f Mon Sep 17 00:00:00 2001 From: Sarah Meko Date: Thu, 19 Sep 2024 11:00:22 -0700 Subject: [PATCH 09/11] added overdue section in firebase --- src/api/firebase.js | 18 +++++------------- src/views/List.jsx | 23 +---------------------- 2 files changed, 6 insertions(+), 35 deletions(-) diff --git a/src/api/firebase.js b/src/api/firebase.js index aa14d9d..3855aeb 100644 --- a/src/api/firebase.js +++ b/src/api/firebase.js @@ -242,6 +242,7 @@ export function comparePurchaseUrgency(list) { const kindOfSoon = []; const notSoon = []; const inactive = []; + const overdue = []; const sortedList = list.sort((a, b) => { const dateNextPurchasedAsDateA = a.dateNextPurchased?.toDate(); @@ -258,7 +259,6 @@ export function comparePurchaseUrgency(list) { return daysUntilNextPurchaseB > daysUntilNextPurchaseA ? -1 : 1; }); - // console.log('ALERT!! its sorted', sortedList); sortedList.forEach((x) => { const dateNextPurchasedAsDate = x.dateNextPurchased?.toDate(); @@ -267,8 +267,9 @@ export function comparePurchaseUrgency(list) { currentDate, dateNextPurchasedAsDate, ); - - if (daysUntilNextPurchase <= 7) { + if (daysUntilNextPurchase < 0) { + overdue.push(x); + } else if (daysUntilNextPurchase >= 0 && daysUntilNextPurchase <= 7) { soon.push(x); } else if (daysUntilNextPurchase > 7 && daysUntilNextPurchase < 30) { kindOfSoon.push(x); @@ -279,17 +280,8 @@ export function comparePurchaseUrgency(list) { } }); - // console.log('soon: ', soon); - // console.log('kinda: ', kindOfSoon); - // console.log('not: ', notSoon); - // console.log('inactive: ', inactive); - - // console.log([...soon, ...kindOfSoon, ...notSoon, ...inactive]); - // console.log('soon', soon) - // console.log( 'kinda' , kindOfSoon) - // console.log( 'notsoon', notSoon) - // console.log('inactive', inactive) return { + overdue, soon, kindOfSoon, notSoon, diff --git a/src/views/List.jsx b/src/views/List.jsx index d7abdb0..c47d3fd 100644 --- a/src/views/List.jsx +++ b/src/views/List.jsx @@ -34,6 +34,7 @@ export function List({ data, userId }) { }, [data]); const labels = { + overdue: 'Overdue', soon: 'Soon', kindOfSoon: 'Kind of soon', notSoon: 'Not soon', @@ -41,14 +42,7 @@ export function List({ data, userId }) { }; useEffect(() => { - // setFilteredObject( - // data.filter((item) => - // item.name.toLowerCase().includes(filterVal.toLowerCase()), - // ), - // ); - const filteredObject = {}; - Object.entries(sortedList).forEach(([timeBucket, list]) => { filteredObject[timeBucket] = list.filter((item) => item.name.toLowerCase().includes(filterVal.toLowerCase()), @@ -57,12 +51,6 @@ export function List({ data, userId }) { setFilteredObject(filteredObject); }, [filterVal, sortedList]); - // useEffect(() => { - // setFilteredList(comparePurchaseUrgency(data)) - // }, [data]); - - // console.log(filteredList) - return ( <>

@@ -72,8 +60,6 @@ export function List({ data, userId }) { )} - - Clear} - {/*

    - {filteredList && - filteredList.map((item) => { - return ; - })} -
*/} - {/* {console.log(sortedList.forEach(x => x))} */}
    {filteredObject && Object.entries(filteredObject).map(([timeBucket, list]) => ( From 0d550c97298fb97ec605d1130826d7aafcdc9ead Mon Sep 17 00:00:00 2001 From: Sarah Meko Date: Thu, 19 Sep 2024 11:04:10 -0700 Subject: [PATCH 10/11] added urgency labels as placeholders --- src/views/List.jsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/views/List.jsx b/src/views/List.jsx index c47d3fd..c5c3f92 100644 --- a/src/views/List.jsx +++ b/src/views/List.jsx @@ -34,10 +34,10 @@ export function List({ data, userId }) { }, [data]); const labels = { - overdue: 'Overdue', - soon: 'Soon', - kindOfSoon: 'Kind of soon', - notSoon: 'Not soon', + overdue: 'Overdue (!!!!)', + soon: 'Soon (!!!)', + kindOfSoon: 'Kind of soon (!!)', + notSoon: 'Not soon (!)', inactive: 'Inactive Items', }; From 547cad07d7767591ea2c4ad97d177fb59ed437c4 Mon Sep 17 00:00:00 2001 From: arandel1 Date: Fri, 20 Sep 2024 09:34:03 -0500 Subject: [PATCH 11/11] replaced x variable name with item to make it more descriptive --- src/api/firebase.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/api/firebase.js b/src/api/firebase.js index 3855aeb..ba9ec3a 100644 --- a/src/api/firebase.js +++ b/src/api/firebase.js @@ -260,23 +260,23 @@ export function comparePurchaseUrgency(list) { return daysUntilNextPurchaseB > daysUntilNextPurchaseA ? -1 : 1; }); - sortedList.forEach((x) => { - const dateNextPurchasedAsDate = x.dateNextPurchased?.toDate(); + sortedList.forEach((item) => { + const dateNextPurchasedAsDate = item.dateNextPurchased?.toDate(); const daysUntilNextPurchase = getDaysBetweenDates( currentDate, dateNextPurchasedAsDate, ); if (daysUntilNextPurchase < 0) { - overdue.push(x); + overdue.push(item); } else if (daysUntilNextPurchase >= 0 && daysUntilNextPurchase <= 7) { - soon.push(x); + soon.push(item); } else if (daysUntilNextPurchase > 7 && daysUntilNextPurchase < 30) { - kindOfSoon.push(x); + kindOfSoon.push(item); } else if (daysUntilNextPurchase >= 30 && daysUntilNextPurchase < 60) { - notSoon.push(x); + notSoon.push(item); } else if (daysUntilNextPurchase >= 60) { - inactive.push(x); + inactive.push(item); } });