Goodbye extraneous console logging...
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-01-24 20:05:59 -05:00
parent ffda5c6a61
commit 6413ce0b9b
4 changed files with 10 additions and 12 deletions

View File

@@ -23,13 +23,11 @@ export function ProductInfo() {
const [isEntryMode, setIsEntryMode] = useState(!isCompleteItem(item)); const [isEntryMode, setIsEntryMode] = useState(!isCompleteItem(item));
useEffect(() => { useEffect(() => {
console.log('item', { item, complete: isCompleteItem(item) });
setIsEntryMode(!isCompleteItem(item)); setIsEntryMode(!isCompleteItem(item));
}, [item]) }, [item])
useEffect(() => { useEffect(() => {
if (isCompleteItem(inputItem)) { 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}`)); setItem(barcodeToProduct(`${inputItem?.product}${inputItem?.date}${inputItem?.processor}${inputItem?.weight}`));
setInputItem(null); setInputItem(null);
} }

View File

@@ -2,6 +2,7 @@
.page { .page {
padding: 1rem; padding: 1rem;
min-height: 100vh;
h1 { h1 {
margin-bottom: 1em; margin-bottom: 1em;

View File

@@ -48,11 +48,9 @@ export default function Page() {
onDrop={handleDrop} onDrop={handleDrop}
> >
<h2>{binToLabel(parseInt(k))}</h2> <h2>{binToLabel(parseInt(k))}</h2>
{v.length > 0 && ( <ul onDrop={handleDrop}>
<ul onDrop={handleDrop}> {v.length > 0 && v.map((item) => (<li key={(item as BinnedDocument)._id} onDragStart={() => setDragging(item)} draggable>{`${item.product} - ${item.weight}lbs`}</li>))}
{v.map((item) => (<li key={(item as BinnedDocument)._id} onDragStart={() => setDragging(item)} draggable>{`${item.product} - ${item.weight}lbs`}</li>))} </ul>
</ul>
)}
</div> </div>
))} ))}
</div> </div>

View File

@@ -16,14 +16,15 @@ export async function addToBin(bin: number, item: Omit<BinItem, 'bin'>) {
export async function getBinsContents(): Promise<BinsContents> { export async function getBinsContents(): Promise<BinsContents> {
await db(); await db();
const bins = {} as BinsContents;
const createdAt = new Date(); 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 // Should be today, but lets do yesterday so there is more to see for demo purposes
const binned = await Binned.find({ createdAt: { $gte: createdAt }}); const binned = await Binned.find({ createdAt: { $gte: createdAt }});
binned.forEach((item: BinItem) => bins[item.bin] = [...(bins[item.bin] ?? []), item]); return JSON.parse(JSON.stringify(binned.reduce((bins: { [key in Bin]: BinItem[] }, cur: BinItem) => {
return JSON.parse(JSON.stringify(bins)); 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) { export async function switchBin(bin: number, id: StringSchemaDefinition) {