fix: clear demo data button, seed user ID bug, duplicate endpoint (v0.23.4)
- DataPage: removed 'coming soon' placeholder, made Clear Demo Data button accessible from seeded state - seedDemoData.js: fixed userId -> targetUserId bug - settings.js: removed duplicate /api/settings/seed-demo-data endpoint - Version bumped to 0.23.4
This commit is contained in:
parent
6d488aa8bd
commit
5537ab2bd5
|
|
@ -3,7 +3,7 @@
|
||||||
**This document tracks potential future enhancements for Bill Tracker.**
|
**This document tracks potential future enhancements for Bill Tracker.**
|
||||||
|
|
||||||
**Last Updated:** 2026-05-10
|
**Last Updated:** 2026-05-10
|
||||||
**Current Version:** v0.23.3
|
**Current Version:** v0.23.4
|
||||||
|
|
||||||
## How to Use This Document
|
## How to Use This Document
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,12 @@
|
||||||
# Bill Tracker — Changelog
|
# Bill Tracker — Changelog
|
||||||
|
|
||||||
|
## v0.23.4
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- **Clear Demo Data button now works** — Removed misleading "coming soon" placeholder text. The Clear Demo Data button with AlertDialog confirmation is now accessible from the seeded state view.
|
||||||
|
- **Seed script user ID bug** — Fixed `seedDemoData.js` creating bills with wrong user ID (`userId` instead of `targetUserId`).
|
||||||
|
- **Removed duplicate seed endpoint** — Deleted redundant `/api/settings/seed-demo-data` route (canonical endpoint is `/api/user/seed-demo-data`).
|
||||||
|
|
||||||
## v0.23.3
|
## v0.23.3
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
export const APP_VERSION = '0.23.3';
|
export const APP_VERSION = '0.23.4';
|
||||||
export const APP_NAME = 'BillTracker';
|
export const APP_NAME = 'BillTracker';
|
||||||
|
|
||||||
export const RELEASE_NOTES = {
|
export const RELEASE_NOTES = {
|
||||||
version: '0.23.3',
|
version: '0.23.4',
|
||||||
date: '2026-05-10',
|
date: '2026-05-10',
|
||||||
highlights: [
|
highlights: [
|
||||||
{ icon: '✅', title: 'AlertDialog Integration', desc: 'Replaced native confirm() calls with shadcn/ui AlertDialog for consistent UI across tracker and data pages.' },
|
{ icon: '🧹', title: 'Clear Demo Data Fix', desc: 'Fixed Clear Demo Data button — removed misleading placeholder, made button accessible from seeded state, fixed seed script user ID bug, and removed duplicate endpoint.' },
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
@ -1509,9 +1509,27 @@ function SeedDemoDataSection({ onSeeded }) {
|
||||||
<Button size="sm" variant="outline" onClick={() => { setSeeded(false); setResult(null); }}>
|
<Button size="sm" variant="outline" onClick={() => { setSeeded(false); setResult(null); }}>
|
||||||
Reset
|
Reset
|
||||||
</Button>
|
</Button>
|
||||||
<p className="text-xs text-muted-foreground">
|
<AlertDialog open={showClearConfirm} onOpenChange={setShowClearConfirm}>
|
||||||
Temp demo data removal coming soon ✨
|
<AlertDialogTrigger asChild>
|
||||||
</p>
|
<Button size="sm" variant="destructive" disabled={clearing}>
|
||||||
|
{clearing ? <><Loader2 className="h-3.5 w-3.5 mr-1.5 animate-spin" />Clearing…</> : 'Clear Demo Data'}
|
||||||
|
</Button>
|
||||||
|
</AlertDialogTrigger>
|
||||||
|
<AlertDialogContent>
|
||||||
|
<AlertDialogHeader>
|
||||||
|
<AlertDialogTitle>Clear Demo Data</AlertDialogTitle>
|
||||||
|
<AlertDialogDescription>
|
||||||
|
This action will remove {result?.billsCreated || 0} demo bills and {result?.categoriesCreated || 0} demo categories from your account. This action cannot be undone.
|
||||||
|
</AlertDialogDescription>
|
||||||
|
</AlertDialogHeader>
|
||||||
|
<AlertDialogFooter>
|
||||||
|
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||||
|
<AlertDialogAction onClick={handleClearDemoData} className="bg-destructive text-destructive-foreground hover:bg-destructive/90">
|
||||||
|
{clearing ? <><Loader2 className="h-3.5 w-3.5 mr-1.5 animate-spin" />Clearing…</> : 'Clear Data'}
|
||||||
|
</AlertDialogAction>
|
||||||
|
</AlertDialogFooter>
|
||||||
|
</AlertDialogContent>
|
||||||
|
</AlertDialog>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -1527,55 +1545,12 @@ function SeedDemoDataSection({ onSeeded }) {
|
||||||
The data will be associated with your account.
|
The data will be associated with your account.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{/* Temp Data Deletion Placeholder */}
|
|
||||||
<div className="mt-4 rounded-md bg-muted/40 border border-border/60 p-3">
|
|
||||||
<div className="flex items-start gap-2.5">
|
|
||||||
<AlertTriangle className="mt-0.5 h-4 w-4 text-amber-600 dark:text-amber-500 shrink-0" />
|
|
||||||
<div className="space-y-1">
|
|
||||||
<p className="text-xs font-semibold text-amber-700 dark:text-amber-500">Temp Demo Data Removal</p>
|
|
||||||
<p className="text-xs text-muted-foreground">
|
|
||||||
Demo data removal functionality is coming soon. Once fixed, you'll be able to clear all seeded demo bills and categories with one click.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mt-4 space-y-4">
|
<div className="mt-4 space-y-4">
|
||||||
<div className="border-t border-border pt-4">
|
<div className="border-t border-border pt-4">
|
||||||
<Button size="sm" variant="outline" onClick={handleSeed} disabled={loading}>
|
<Button size="sm" variant="outline" onClick={handleSeed} disabled={loading}>
|
||||||
{loading ? <><Loader2 className="h-3.5 w-3.5 mr-1.5 animate-spin" />Seeding…</> : 'Seed Demo Data'}
|
{loading ? <><Loader2 className="h-3.5 w-3.5 mr-1.5 animate-spin" />Seeding…</> : 'Seed Demo Data'}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{seeded && (
|
|
||||||
<div className="border-t border-border pt-4">
|
|
||||||
<div className="flex items-center justify-between">
|
|
||||||
<p className="text-xs text-muted-foreground">
|
|
||||||
This will remove only seeded demo bills and categories from your account.
|
|
||||||
</p>
|
|
||||||
<AlertDialog open={showClearConfirm} onOpenChange={setShowClearConfirm}>
|
|
||||||
<AlertDialogTrigger asChild>
|
|
||||||
<Button size="sm" variant="destructive" disabled={clearing}>
|
|
||||||
{clearing ? <><Loader2 className="h-3.5 w-3.5 mr-1.5 animate-spin" />Clearing…</> : 'Clear Demo Data'}
|
|
||||||
</Button>
|
|
||||||
</AlertDialogTrigger>
|
|
||||||
<AlertDialogContent>
|
|
||||||
<AlertDialogHeader>
|
|
||||||
<AlertDialogTitle>Clear Demo Data</AlertDialogTitle>
|
|
||||||
<AlertDialogDescription>
|
|
||||||
This action will remove {result?.billsCreated || 0} demo bills and {result?.categoriesCreated || 0} demo categories from your account. This action cannot be undone.
|
|
||||||
</AlertDialogDescription>
|
|
||||||
</AlertDialogHeader>
|
|
||||||
<AlertDialogFooter>
|
|
||||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
|
||||||
<AlertDialogAction onClick={handleClearDemoData} className="bg-destructive text-destructive-foreground hover:bg-destructive/90">
|
|
||||||
{clearing ? <><Loader2 className="h-3.5 w-3.5 mr-1.5 animate-spin" />Clearing…</> : 'Clear Data'}
|
|
||||||
</AlertDialogAction>
|
|
||||||
</AlertDialogFooter>
|
|
||||||
</AlertDialogContent>
|
|
||||||
</AlertDialog>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</SectionCard>
|
</SectionCard>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "bill-tracker",
|
"name": "bill-tracker",
|
||||||
"version": "0.23.3",
|
"version": "0.23.4",
|
||||||
"description": "Monthly bill tracking system",
|
"description": "Monthly bill tracking system",
|
||||||
"main": "server.js",
|
"main": "server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const { getDb, getSetting, setSetting } = require('../db/database');
|
const { getDb, getSetting, setSetting } = require('../db/database');
|
||||||
const { seedDemoData } = require('../scripts/seedDemoData');
|
|
||||||
|
|
||||||
// Keys a regular user is allowed to read and write.
|
// Keys a regular user is allowed to read and write.
|
||||||
// Admin/SMTP/backup/auth settings are excluded — they are only readable through
|
// Admin/SMTP/backup/auth settings are excluded — they are only readable through
|
||||||
|
|
@ -38,20 +37,4 @@ router.put('/', (req, res) => {
|
||||||
res.json(settings);
|
res.json(settings);
|
||||||
});
|
});
|
||||||
|
|
||||||
// POST /api/settings/seed-demo-data — seeds 20 demo bills for the requesting user
|
|
||||||
router.post('/seed-demo-data', (req, res) => {
|
|
||||||
try {
|
|
||||||
const result = seedDemoData(req.user.id);
|
|
||||||
res.json({
|
|
||||||
success: true,
|
|
||||||
message: `Created ${result.billsCreated} demo bills and ${result.categoriesCreated} demo categories`,
|
|
||||||
billsCreated: result.billsCreated,
|
|
||||||
categoriesCreated: result.categoriesCreated,
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
const status = err.status || 500;
|
|
||||||
res.status(status).json({ error: status === 500 ? 'Seed operation failed' : err.message });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ function seedDemoData(userId = null) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
insertBill.run(
|
insertBill.run(
|
||||||
userId,
|
targetUserId,
|
||||||
billData.name,
|
billData.name,
|
||||||
category,
|
category,
|
||||||
billData.dueDay || Math.floor(Math.random() * 28) + 1,
|
billData.dueDay || Math.floor(Math.random() * 28) + 1,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue