fix non-https crypto issue

This commit is contained in:
Owen
2026-08-11 16:39:52 -04:00
parent 1782f31075
commit f5b10df7cf
+8 -1
View File
@@ -82,10 +82,17 @@ function nextAvailableCombo(rows: BudgetRow[]): {
return { unit: "usd", period: "monthly" };
}
function newRowKey(): string {
if (typeof crypto !== "undefined" && "randomUUID" in crypto) {
return crypto.randomUUID();
}
return `tmp-${Date.now()}-${Math.random().toString(36).slice(2)}`;
}
export function newBudgetRow(rows: BudgetRow[]): BudgetRow {
const combo = nextAvailableCombo(rows);
return {
key: crypto.randomUUID(),
key: newRowKey(),
amount: "",
unit: combo.unit,
period: combo.period