Skip to content

Commit 4929592

Browse files
committed
received dates
1 parent d96ee7b commit 4929592

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/pages/DashboardPage.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,15 @@ export default function Dashboard({ user, onSignOut }) {
157157
updates['Date Purchased'] = `${year}-${month}-${day}`;
158158
}
159159

160+
// If changing to "Received", set the Date Received to today
161+
if (newState === 'Received') {
162+
const now = new Date();
163+
const year = now.getFullYear();
164+
const month = String(now.getMonth() + 1).padStart(2, '0'); // months are 0-indexed
165+
const day = String(now.getDate()).padStart(2, '0');
166+
updates['Date Received'] = `${year}-${month}-${day}`;
167+
}
168+
160169
// Update all selected purchases
161170
await Promise.all(
162171
selectedPurchases.map(purchase =>

0 commit comments

Comments
 (0)