From 6413ce0b9b28ade1dd209cfc82dbca099a5f7dcf Mon Sep 17 00:00:00 2001 From: mifi Date: Wed, 24 Jan 2024 20:05:59 -0500 Subject: [PATCH] Goodbye extraneous console logging... --- .../binner/components/ProductInfo/ProductInfo.tsx | 2 -- .../(authenticated)/dashboard/bins/page.module.scss | 1 + src/app/(authenticated)/dashboard/bins/page.tsx | 8 +++----- src/app/lib/data/binned.ts | 11 ++++++----- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/app/(authenticated)/binner/components/ProductInfo/ProductInfo.tsx b/src/app/(authenticated)/binner/components/ProductInfo/ProductInfo.tsx index c328729..dcacdde 100644 --- a/src/app/(authenticated)/binner/components/ProductInfo/ProductInfo.tsx +++ b/src/app/(authenticated)/binner/components/ProductInfo/ProductInfo.tsx @@ -23,13 +23,11 @@ export function ProductInfo() { const [isEntryMode, setIsEntryMode] = useState(!isCompleteItem(item)); useEffect(() => { - console.log('item', { item, complete: isCompleteItem(item) }); setIsEntryMode(!isCompleteItem(item)); }, [item]) useEffect(() => { if (isCompleteItem(inputItem)) { - console.log('inputItem', { inputItem, barcode: `${inputItem?.product}${inputItem?.date}${inputItem?.processor}${inputItem?.weight}` }); setItem(barcodeToProduct(`${inputItem?.product}${inputItem?.date}${inputItem?.processor}${inputItem?.weight}`)); setInputItem(null); } diff --git a/src/app/(authenticated)/dashboard/bins/page.module.scss b/src/app/(authenticated)/dashboard/bins/page.module.scss index a2e883b..6726057 100644 --- a/src/app/(authenticated)/dashboard/bins/page.module.scss +++ b/src/app/(authenticated)/dashboard/bins/page.module.scss @@ -2,6 +2,7 @@ .page { padding: 1rem; + min-height: 100vh; h1 { margin-bottom: 1em; diff --git a/src/app/(authenticated)/dashboard/bins/page.tsx b/src/app/(authenticated)/dashboard/bins/page.tsx index be53733..33c462c 100644 --- a/src/app/(authenticated)/dashboard/bins/page.tsx +++ b/src/app/(authenticated)/dashboard/bins/page.tsx @@ -48,11 +48,9 @@ export default function Page() { onDrop={handleDrop} >

{binToLabel(parseInt(k))}

- {v.length > 0 && ( - - )} + ))} diff --git a/src/app/lib/data/binned.ts b/src/app/lib/data/binned.ts index 15f37f7..fd84ee8 100644 --- a/src/app/lib/data/binned.ts +++ b/src/app/lib/data/binned.ts @@ -16,14 +16,15 @@ export async function addToBin(bin: number, item: Omit) { export async function getBinsContents(): Promise { await db(); - const bins = {} as BinsContents; const createdAt = new Date(); - createdAt.setUTCHours(0,0,0,0); - + createdAt.setDate(createdAt.getDate() - 1); + createdAt.setHours(0,0,0,0); // Should be today, but lets do yesterday so there is more to see for demo purposes const binned = await Binned.find({ createdAt: { $gte: createdAt }}); - binned.forEach((item: BinItem) => bins[item.bin] = [...(bins[item.bin] ?? []), item]); - return JSON.parse(JSON.stringify(bins)); + return JSON.parse(JSON.stringify(binned.reduce((bins: { [key in Bin]: BinItem[] }, cur: BinItem) => { + bins[cur.bin] = [...bins[cur.bin], cur]; + return bins; + }, { [Bin.LOSS]: [], [Bin.PROCESS]: [], [Bin.DONATE]: [], [Bin.SHOULDER_TAP]: [] }))); } export async function switchBin(bin: number, id: StringSchemaDefinition) {