feat: implement PendingDailyCountsView with edit dialog and sticky header#72
feat: implement PendingDailyCountsView with edit dialog and sticky header#72
Conversation
Deploying bintraq with
|
| Latest commit: |
8e7ca85
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://d342e37b.bintraq.pages.dev |
| Branch Preview URL: | https://63-pending-daily-counts.bintraq.pages.dev |
|
In |
|
In |
Changes Requested
Summary of Changes
Overall Feedback@Pertempto, solid start on the daily counts UI with a clean edit dialog and sticky total header 👍. The SMS totals are off without fetching today's DB counts and grouping by picker—fix those to avoid wrong numbers and message spam 📱. Error handling in updates will prevent sneaky failures—try-catch is your friend 🤝. Title and version bump are on point 😎. |
- Fix Supabase select syntax from .select('picker', { count: 'exact' }) to .select('picker, count')
- Correct summation logic to use count.count instead of incrementing by 1
- Make saveCount async and await API call with data reload
- Bump version to 2025.10.17.5
…pdateCount - Move send button from bottom of list to sticky header for better UX - Rename saveCount to updateCount for accuracy since it updates existing counts - Revert version to 2025.10.17.4 as requested
- Remove bottom border from sticky header - Add rounded corners for better visual design - Add top margin for spacing from navigation bar
|
In PendingDailyCountsView.vue, the Supabase select queries for allDailyCounts and allWeeklyCounts are using invalid syntax .select("picker", { count: "exact" }). Change it to .select("picker, count") to properly select the picker and count fields. |
|
In PendingDailyCountsView.vue, the summation logic for dailyCountsFromDB and weeklyCountsFromDB is incorrectly incrementing by + 1 instead of + count.count. It should sum the actual count values: (dailyCountsFromDB[count.picker] ?? 0) + count.count |
|
In |
- Change top-0 to top-2 to maintain gap from navigation when scrolling - Remove mt-2 since top-2 provides the spacing
|
In PendingDailyCountsView.vue, the saveCount function (updateCount) modifies the local object but directly awaits updateDailyCount and reloads. This avoids UI inconsistency if update fails, which is good. As long as no error handling is added, it might silently fail—consider adding try-catch for better UX. |
|
In |
|
In Also, if multiple pending counts exist for the same picker, multiple messages are sent. Consider grouping by picker to send one message per picker with the total day count. |
|
In |
|
content here |
|
In |
1 similar comment
|
In |
|
In |
|
In |
|
... |
1 similar comment
|
... |
The code in |
If there are multiple pending daily counts for the same picker, the current implementation sends separate SMS messages. To improve this, please group the counts by picker and send one consolidated SMS per picker. |
The code in |
|
Add try-catch error handling to the |
|
In |
|
@Pertempto, to fully implement the PendingDailyCountsView as per the spec, the SMS sending needs to group messages by picker and calculate total daily counts including today's already sent pending counts. Currently, it sends separate messages without considering existing daily totals. |
- Convert onMounted callback to async function - Replace .then() with await for better readability - Follow modern async/await pattern
- Remove unnecessary pickers variable - Inline getPickers() call directly into getSettings() - Reduce code verbosity
- Add guidance about avoiding unnecessary variables - Include examples of when to inline vs when to use variables - Promote cleaner, more concise code
|
In |
|
In |
|
In Wrap the fetch in a try-catch if needed, but ensure you fetch: const { data: allDailyCounts } = await supabase
.from("dailyCount")
.select("picker, count")
.gte("date", startOfDay.toISOString())
.lt("date", new Date(startOfDay.getTime() + 24 * 60 * 60 * 1000).toISOString())
.eq("isPending", false);Then sum them into |
|
In |
|
In |
|
In |
|
In |
|
In |
- Convert updateCount to use guard clause pattern - Add guard clause guidelines to AGENTS.md - Promote reduced nesting and better readability
|
In |
|
In |
|
In |
|
In |
|
In |
|
In |
|
In |
|
In |
|
In |
- Add 'curly' ESLint rule to enforce braces for all if blocks - Update AGENTS.md to emphasize brace usage in guard clauses - Fix unused import in PendingDailyCountsView - Ignore .vite directory in ESLint to avoid dependency file errors
|
In Example: // Fetch all non-pending daily counts for today
const { data: allDailyCounts } = await supabase
.from("dailyCount")
.select("picker, count")
.gte("date", startOfDay.toISOString())
.lt("date", new Date(startOfDay.getTime() + 86400000).toISOString())
.eq("isPending", false);
const dailyCountsFromDB: Record<string, number> = {};
allDailyCounts?.forEach((count) => {
dailyCountsFromDB[count.picker] = (dailyCountsFromDB[count.picker] ?? 0) + count.count;
});Then use |
|
Restructure This prevents spamming pickers with multiple SMS and ensures accurate totals in "Cajas hoy". |
|
Wrap try {
await updateDailyCount(editingCount.value);
await loadPendingDailyCounts();
editingCount.value = null;
} catch (e) {
alert('Failed to update count.');
await loadPendingDailyCounts();
}This alerts on update failures and reloads the list to maintain UI consistency. |
Summary
Resolves #63