Multi-month samples, page breathing room (v4)

This commit is contained in:
2026-09-19 01:20:27 +00:00
parent 9e543bec1a
commit 7753cbcb35
5 changed files with 64 additions and 14 deletions

View File

@@ -151,8 +151,14 @@ export function groupTitle(key, tab) {
/* Sample data relative to today so every view has content on first run. */
export function seedSamples() {
const t = todayStr();
const first = t.slice(0, 8) + "01";
const tp = t.split("-");
const now = Date.now();
function monthFirst(offset) {
return toDateStr(new Date(+tp[0], +tp[1] - 1 + offset, 1));
}
function monthDay(offset, day) {
return toDateStr(new Date(+tp[0], +tp[1] - 1 + offset, Math.min(day, 28)));
}
function mk(desc, amount, cat, date, freq) {
return {
id: uid() + Math.floor(Math.random() * 1e6).toString(36),
@@ -166,18 +172,37 @@ export function seedSamples() {
};
}
return [
/* this month */
mk("Groceries", 54.2, "Food", t),
mk("Bus pass", 28.0, "Transport", t, "monthly"),
mk("Coffee", 4.5, "Food", addDaysStr(t, -1)),
mk("Pharmacy", 12.75, "Health", addDaysStr(t, -2)),
mk("Electricity bill", 85.4, "Utilities", addDaysStr(t, -3), "monthly"),
mk("Movie night", 16.0, "Entertainment", addDaysStr(t, -5)),
mk("Gym", 35.0, "Health", addDaysStr(t, -6), "monthly"),
mk("Gym", 35.0, "Health", addDaysStr(t, -7), "monthly"),
mk("Haircut", 25.0, "Beauty", addDaysStr(t, -6)),
mk("New shoes", 79.99, "Shopping", addDaysStr(t, -8)),
mk("Team lunch", 13.4, "Food", addDaysStr(t, -9), "weekly"),
mk("Internet", 59.99, "Utilities", addDaysStr(t, -12), "monthly"),
mk("Rent", 1200.0, "Household", first, "monthly"),
mk("Concert ticket", 45.0, "Entertainment", addDaysStr(t, -20)),
mk("Groceries", 62.1, "Food", addDaysStr(t, -33)),
mk("Rent", 1200.0, "Household", monthFirst(0), "monthly"),
/* last month */
mk("Rent", 1200.0, "Household", monthFirst(-1)),
mk("Internet", 59.99, "Utilities", monthDay(-1, 12)),
mk("Groceries", 48.7, "Food", monthDay(-1, 8)),
mk("Concert ticket", 45.0, "Entertainment", monthDay(-1, 21)),
mk("Skincare", 22.5, "Beauty", monthDay(-1, 17)),
mk("Doctor visit", 60.0, "Health", monthDay(-1, 25)),
/* two months ago */
mk("Rent", 1200.0, "Household", monthFirst(-2)),
mk("Electricity bill", 82.1, "Utilities", monthDay(-2, 10)),
mk("Groceries", 51.3, "Food", monthDay(-2, 6)),
mk("Bus pass", 28.0, "Transport", monthDay(-2, 2)),
mk("Face cream", 18.75, "Beauty", monthDay(-2, 19)),
mk("Dinner out", 34.5, "Food", monthDay(-2, 23)),
/* three months ago */
mk("Rent", 1200.0, "Household", monthFirst(-3)),
mk("Groceries", 49.9, "Food", monthDay(-3, 11)),
mk("Gym", 35.0, "Health", monthDay(-3, 5)),
mk("Movie night", 14.0, "Entertainment", monthDay(-3, 16)),
];
}