@pfm-platform/budgets-ui-mui 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +18 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -17
- package/dist/index.d.ts +17 -17
- package/dist/index.js +18 -16
- package/dist/index.js.map +1 -1
- package/package.json +14 -15
package/dist/index.cjs
CHANGED
|
@@ -15,13 +15,13 @@ var DeleteIcon__default = /*#__PURE__*/_interopDefault(DeleteIcon);
|
|
|
15
15
|
// src/components/BudgetList.tsx
|
|
16
16
|
function BudgetList({
|
|
17
17
|
userId,
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
month,
|
|
19
|
+
year,
|
|
20
20
|
title = "Budgets",
|
|
21
21
|
currencySymbol = "$",
|
|
22
22
|
maxItems
|
|
23
23
|
}) {
|
|
24
|
-
const budgets = budgetsFeature.useBudgetProgress({ userId,
|
|
24
|
+
const budgets = budgetsFeature.useBudgetProgress({ userId, month, year });
|
|
25
25
|
if (!budgets) {
|
|
26
26
|
return /* @__PURE__ */ jsxRuntime.jsx(material.Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(material.CardContent, { children: [
|
|
27
27
|
/* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "h6", gutterBottom: true, children: title }),
|
|
@@ -84,12 +84,12 @@ function BudgetList({
|
|
|
84
84
|
}
|
|
85
85
|
function BudgetSummary({
|
|
86
86
|
userId,
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
month,
|
|
88
|
+
year,
|
|
89
89
|
title = "Budget Summary",
|
|
90
90
|
currencySymbol = "$"
|
|
91
91
|
}) {
|
|
92
|
-
const summary = budgetsFeature.useBudgetSummary({ userId,
|
|
92
|
+
const summary = budgetsFeature.useBudgetSummary({ userId, month, year });
|
|
93
93
|
if (!summary) {
|
|
94
94
|
return /* @__PURE__ */ jsxRuntime.jsx(material.Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(material.CardContent, { children: [
|
|
95
95
|
/* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "h6", gutterBottom: true, children: title }),
|
|
@@ -211,13 +211,16 @@ function BudgetCreateForm({
|
|
|
211
211
|
setError("At least one tag is required");
|
|
212
212
|
return;
|
|
213
213
|
}
|
|
214
|
+
const now = /* @__PURE__ */ new Date();
|
|
214
215
|
const data = {
|
|
216
|
+
user_id: userId,
|
|
215
217
|
name: name.trim(),
|
|
218
|
+
month: now.getMonth() + 1,
|
|
219
|
+
year: now.getFullYear(),
|
|
216
220
|
budget_amount: amount,
|
|
217
|
-
tag_names: tags,
|
|
218
221
|
show_on_dashboard: true
|
|
219
222
|
};
|
|
220
|
-
createBudget.mutate({ userId, data });
|
|
223
|
+
createBudget.mutate({ userId, data, tagNames: tags });
|
|
221
224
|
};
|
|
222
225
|
return /* @__PURE__ */ jsxRuntime.jsxs(material.Paper, { sx: { p: 3 }, children: [
|
|
223
226
|
/* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "h6", gutterBottom: true, children: "Create Budget" }),
|
|
@@ -310,7 +313,7 @@ function BudgetEditForm({
|
|
|
310
313
|
}) {
|
|
311
314
|
const [name, setName] = react.useState(budget.name);
|
|
312
315
|
const [budgetAmount, setBudgetAmount] = react.useState(budget.budget_amount.toString());
|
|
313
|
-
const [tagNames, setTagNames] = react.useState(budget.
|
|
316
|
+
const [tagNames, setTagNames] = react.useState(budget.budget_tags.map((bt) => bt.tag_name).join(", "));
|
|
314
317
|
const [error, setError] = react.useState(null);
|
|
315
318
|
const updateBudget = budgetsDataAccess.useUpdateBudget({
|
|
316
319
|
onSuccess: () => {
|
|
@@ -341,10 +344,9 @@ function BudgetEditForm({
|
|
|
341
344
|
id: budget.id,
|
|
342
345
|
name: name.trim(),
|
|
343
346
|
budget_amount: amount,
|
|
344
|
-
tag_names: tags,
|
|
345
347
|
show_on_dashboard: true
|
|
346
348
|
};
|
|
347
|
-
updateBudget.mutate({ userId, budgetId: budget.id, data });
|
|
349
|
+
updateBudget.mutate({ userId, budgetId: budget.id, data, tagNames: tags });
|
|
348
350
|
};
|
|
349
351
|
const handleClose = () => {
|
|
350
352
|
if (!updateBudget.isPending) {
|
|
@@ -525,10 +527,10 @@ function BudgetProgressCard({
|
|
|
525
527
|
/* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: { display: "flex", justifyContent: "space-between", alignItems: "flex-start", mb: 2 }, children: [
|
|
526
528
|
/* @__PURE__ */ jsxRuntime.jsxs(material.Box, { children: [
|
|
527
529
|
/* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "h6", gutterBottom: true, children: budget.name }),
|
|
528
|
-
budget.
|
|
530
|
+
budget.budget_tags.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
529
531
|
material.Chip,
|
|
530
532
|
{
|
|
531
|
-
label: budget.
|
|
533
|
+
label: budget.budget_tags[0].tag_name,
|
|
532
534
|
size: "small",
|
|
533
535
|
variant: "outlined",
|
|
534
536
|
sx: { mb: 1 }
|
|
@@ -630,8 +632,8 @@ function BudgetProgressList({
|
|
|
630
632
|
const categories = react.useMemo(() => {
|
|
631
633
|
const uniqueCategories = /* @__PURE__ */ new Set();
|
|
632
634
|
budgets.forEach((budget) => {
|
|
633
|
-
budget.
|
|
634
|
-
uniqueCategories.add(
|
|
635
|
+
budget.budget_tags.forEach((bt) => {
|
|
636
|
+
uniqueCategories.add(bt.tag_name);
|
|
635
637
|
});
|
|
636
638
|
});
|
|
637
639
|
return Array.from(uniqueCategories).sort();
|
|
@@ -644,7 +646,7 @@ function BudgetProgressList({
|
|
|
644
646
|
if (statusFilter === "on-track" && percentage > 70) return false;
|
|
645
647
|
if (statusFilter === "warning" && (percentage <= 70 || percentage > 90)) return false;
|
|
646
648
|
if (statusFilter === "over-budget" && percentage <= 90) return false;
|
|
647
|
-
if (categoryFilter !== "all" && !budget.
|
|
649
|
+
if (categoryFilter !== "all" && !budget.budget_tags.some((bt) => bt.tag_name === categoryFilter)) return false;
|
|
648
650
|
return true;
|
|
649
651
|
});
|
|
650
652
|
}, [budgets, spentByBudget, statusFilter, categoryFilter]);
|