@pfm-platform/budgets-ui-mui 0.2.0 → 0.2.1

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.d.cts CHANGED
@@ -1,12 +1,12 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Budget } from '@pfm-platform/shared';
2
+ import { BudgetWithRelations } from '@pfm-platform/shared';
3
3
 
4
4
  interface BudgetListProps {
5
5
  userId: string;
6
- /** Date range start */
7
- start_date?: string;
8
- /** Date range end */
9
- end_date?: string;
6
+ /** Budget month (1-12) */
7
+ month?: number;
8
+ /** Budget year */
9
+ year?: number;
10
10
  /** Custom title for the list */
11
11
  title?: string;
12
12
  /** Currency symbol to display */
@@ -18,14 +18,14 @@ interface BudgetListProps {
18
18
  * BudgetList component displays budgets with progress bars.
19
19
  * Shows budget name, amounts, and visual progress indicator.
20
20
  */
21
- declare function BudgetList({ userId, start_date, end_date, title, currencySymbol, maxItems, }: BudgetListProps): react_jsx_runtime.JSX.Element;
21
+ declare function BudgetList({ userId, month, year, title, currencySymbol, maxItems, }: BudgetListProps): react_jsx_runtime.JSX.Element;
22
22
 
23
23
  interface BudgetSummaryProps {
24
24
  userId: string;
25
- /** Date range start */
26
- start_date?: string;
27
- /** Date range end */
28
- end_date?: string;
25
+ /** Budget month (1-12) */
26
+ month?: number;
27
+ /** Budget year */
28
+ year?: number;
29
29
  /** Custom title for the summary */
30
30
  title?: string;
31
31
  /** Currency symbol to display */
@@ -35,7 +35,7 @@ interface BudgetSummaryProps {
35
35
  * BudgetSummary component displays aggregate budget statistics.
36
36
  * Shows total budgets, budget amount, spent, remaining, and overall state.
37
37
  */
38
- declare function BudgetSummary({ userId, start_date, end_date, title, currencySymbol, }: BudgetSummaryProps): react_jsx_runtime.JSX.Element;
38
+ declare function BudgetSummary({ userId, month, year, title, currencySymbol, }: BudgetSummaryProps): react_jsx_runtime.JSX.Element;
39
39
 
40
40
  interface BudgetCreateFormProps {
41
41
  userId: string;
@@ -45,7 +45,7 @@ declare function BudgetCreateForm({ userId, onSuccess, }: BudgetCreateFormProps)
45
45
 
46
46
  interface BudgetEditFormProps {
47
47
  userId: string;
48
- budget: Budget;
48
+ budget: BudgetWithRelations;
49
49
  open: boolean;
50
50
  onClose: () => void;
51
51
  }
@@ -53,13 +53,13 @@ declare function BudgetEditForm({ userId, budget, open, onClose, }: BudgetEditFo
53
53
 
54
54
  interface BudgetDeleteButtonProps {
55
55
  userId: string;
56
- budgetId: number;
56
+ budgetId: string;
57
57
  budgetName: string;
58
58
  }
59
59
  declare function BudgetDeleteButton({ userId, budgetId, budgetName, }: BudgetDeleteButtonProps): react_jsx_runtime.JSX.Element;
60
60
 
61
61
  interface BudgetProgressCardProps {
62
- budget: Budget;
62
+ budget: BudgetWithRelations;
63
63
  /** Current spent amount */
64
64
  currentSpent: number;
65
65
  /** Currency symbol to display */
@@ -92,11 +92,11 @@ interface BudgetProgressCardProps {
92
92
  declare function BudgetProgressCard({ budget, currentSpent, currencySymbol, showTrend, lastPeriodSpent, }: BudgetProgressCardProps): react_jsx_runtime.JSX.Element;
93
93
 
94
94
  interface BudgetProgressListProps {
95
- budgets: Budget[];
95
+ budgets: BudgetWithRelations[];
96
96
  /** Map of budget ID to current spent amount */
97
- spentByBudget: Map<number, number>;
97
+ spentByBudget: Map<string, number>;
98
98
  /** Map of budget ID to last period spent amount (optional) */
99
- lastPeriodSpentByBudget?: Map<number, number>;
99
+ lastPeriodSpentByBudget?: Map<string, number>;
100
100
  /** Currency symbol to display */
101
101
  currencySymbol?: string;
102
102
  /** Show trend indicators */
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Budget } from '@pfm-platform/shared';
2
+ import { BudgetWithRelations } from '@pfm-platform/shared';
3
3
 
4
4
  interface BudgetListProps {
5
5
  userId: string;
6
- /** Date range start */
7
- start_date?: string;
8
- /** Date range end */
9
- end_date?: string;
6
+ /** Budget month (1-12) */
7
+ month?: number;
8
+ /** Budget year */
9
+ year?: number;
10
10
  /** Custom title for the list */
11
11
  title?: string;
12
12
  /** Currency symbol to display */
@@ -18,14 +18,14 @@ interface BudgetListProps {
18
18
  * BudgetList component displays budgets with progress bars.
19
19
  * Shows budget name, amounts, and visual progress indicator.
20
20
  */
21
- declare function BudgetList({ userId, start_date, end_date, title, currencySymbol, maxItems, }: BudgetListProps): react_jsx_runtime.JSX.Element;
21
+ declare function BudgetList({ userId, month, year, title, currencySymbol, maxItems, }: BudgetListProps): react_jsx_runtime.JSX.Element;
22
22
 
23
23
  interface BudgetSummaryProps {
24
24
  userId: string;
25
- /** Date range start */
26
- start_date?: string;
27
- /** Date range end */
28
- end_date?: string;
25
+ /** Budget month (1-12) */
26
+ month?: number;
27
+ /** Budget year */
28
+ year?: number;
29
29
  /** Custom title for the summary */
30
30
  title?: string;
31
31
  /** Currency symbol to display */
@@ -35,7 +35,7 @@ interface BudgetSummaryProps {
35
35
  * BudgetSummary component displays aggregate budget statistics.
36
36
  * Shows total budgets, budget amount, spent, remaining, and overall state.
37
37
  */
38
- declare function BudgetSummary({ userId, start_date, end_date, title, currencySymbol, }: BudgetSummaryProps): react_jsx_runtime.JSX.Element;
38
+ declare function BudgetSummary({ userId, month, year, title, currencySymbol, }: BudgetSummaryProps): react_jsx_runtime.JSX.Element;
39
39
 
40
40
  interface BudgetCreateFormProps {
41
41
  userId: string;
@@ -45,7 +45,7 @@ declare function BudgetCreateForm({ userId, onSuccess, }: BudgetCreateFormProps)
45
45
 
46
46
  interface BudgetEditFormProps {
47
47
  userId: string;
48
- budget: Budget;
48
+ budget: BudgetWithRelations;
49
49
  open: boolean;
50
50
  onClose: () => void;
51
51
  }
@@ -53,13 +53,13 @@ declare function BudgetEditForm({ userId, budget, open, onClose, }: BudgetEditFo
53
53
 
54
54
  interface BudgetDeleteButtonProps {
55
55
  userId: string;
56
- budgetId: number;
56
+ budgetId: string;
57
57
  budgetName: string;
58
58
  }
59
59
  declare function BudgetDeleteButton({ userId, budgetId, budgetName, }: BudgetDeleteButtonProps): react_jsx_runtime.JSX.Element;
60
60
 
61
61
  interface BudgetProgressCardProps {
62
- budget: Budget;
62
+ budget: BudgetWithRelations;
63
63
  /** Current spent amount */
64
64
  currentSpent: number;
65
65
  /** Currency symbol to display */
@@ -92,11 +92,11 @@ interface BudgetProgressCardProps {
92
92
  declare function BudgetProgressCard({ budget, currentSpent, currencySymbol, showTrend, lastPeriodSpent, }: BudgetProgressCardProps): react_jsx_runtime.JSX.Element;
93
93
 
94
94
  interface BudgetProgressListProps {
95
- budgets: Budget[];
95
+ budgets: BudgetWithRelations[];
96
96
  /** Map of budget ID to current spent amount */
97
- spentByBudget: Map<number, number>;
97
+ spentByBudget: Map<string, number>;
98
98
  /** Map of budget ID to last period spent amount (optional) */
99
- lastPeriodSpentByBudget?: Map<number, number>;
99
+ lastPeriodSpentByBudget?: Map<string, number>;
100
100
  /** Currency symbol to display */
101
101
  currencySymbol?: string;
102
102
  /** Show trend indicators */
package/dist/index.js CHANGED
@@ -9,13 +9,13 @@ import { Warning, TrendingUp, TrendingDown, ExpandMore, Info, LocalOffer, Add, C
9
9
  // src/components/BudgetList.tsx
10
10
  function BudgetList({
11
11
  userId,
12
- start_date,
13
- end_date,
12
+ month,
13
+ year,
14
14
  title = "Budgets",
15
15
  currencySymbol = "$",
16
16
  maxItems
17
17
  }) {
18
- const budgets = useBudgetProgress({ userId, start_date, end_date });
18
+ const budgets = useBudgetProgress({ userId, month, year });
19
19
  if (!budgets) {
20
20
  return /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(CardContent, { children: [
21
21
  /* @__PURE__ */ jsx(Typography, { variant: "h6", gutterBottom: true, children: title }),
@@ -78,12 +78,12 @@ function BudgetList({
78
78
  }
79
79
  function BudgetSummary({
80
80
  userId,
81
- start_date,
82
- end_date,
81
+ month,
82
+ year,
83
83
  title = "Budget Summary",
84
84
  currencySymbol = "$"
85
85
  }) {
86
- const summary = useBudgetSummary({ userId, start_date, end_date });
86
+ const summary = useBudgetSummary({ userId, month, year });
87
87
  if (!summary) {
88
88
  return /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(CardContent, { children: [
89
89
  /* @__PURE__ */ jsx(Typography, { variant: "h6", gutterBottom: true, children: title }),
@@ -205,13 +205,16 @@ function BudgetCreateForm({
205
205
  setError("At least one tag is required");
206
206
  return;
207
207
  }
208
+ const now = /* @__PURE__ */ new Date();
208
209
  const data = {
210
+ user_id: userId,
209
211
  name: name.trim(),
212
+ month: now.getMonth() + 1,
213
+ year: now.getFullYear(),
210
214
  budget_amount: amount,
211
- tag_names: tags,
212
215
  show_on_dashboard: true
213
216
  };
214
- createBudget.mutate({ userId, data });
217
+ createBudget.mutate({ userId, data, tagNames: tags });
215
218
  };
216
219
  return /* @__PURE__ */ jsxs(Paper, { sx: { p: 3 }, children: [
217
220
  /* @__PURE__ */ jsx(Typography, { variant: "h6", gutterBottom: true, children: "Create Budget" }),
@@ -304,7 +307,7 @@ function BudgetEditForm({
304
307
  }) {
305
308
  const [name, setName] = useState(budget.name);
306
309
  const [budgetAmount, setBudgetAmount] = useState(budget.budget_amount.toString());
307
- const [tagNames, setTagNames] = useState(budget.tag_names.join(", "));
310
+ const [tagNames, setTagNames] = useState(budget.budget_tags.map((bt) => bt.tag_name).join(", "));
308
311
  const [error, setError] = useState(null);
309
312
  const updateBudget = useUpdateBudget({
310
313
  onSuccess: () => {
@@ -335,10 +338,9 @@ function BudgetEditForm({
335
338
  id: budget.id,
336
339
  name: name.trim(),
337
340
  budget_amount: amount,
338
- tag_names: tags,
339
341
  show_on_dashboard: true
340
342
  };
341
- updateBudget.mutate({ userId, budgetId: budget.id, data });
343
+ updateBudget.mutate({ userId, budgetId: budget.id, data, tagNames: tags });
342
344
  };
343
345
  const handleClose = () => {
344
346
  if (!updateBudget.isPending) {
@@ -519,10 +521,10 @@ function BudgetProgressCard({
519
521
  /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", justifyContent: "space-between", alignItems: "flex-start", mb: 2 }, children: [
520
522
  /* @__PURE__ */ jsxs(Box, { children: [
521
523
  /* @__PURE__ */ jsx(Typography, { variant: "h6", gutterBottom: true, children: budget.name }),
522
- budget.tag_names.length > 0 && /* @__PURE__ */ jsx(
524
+ budget.budget_tags.length > 0 && /* @__PURE__ */ jsx(
523
525
  Chip,
524
526
  {
525
- label: budget.tag_names[0],
527
+ label: budget.budget_tags[0].tag_name,
526
528
  size: "small",
527
529
  variant: "outlined",
528
530
  sx: { mb: 1 }
@@ -624,8 +626,8 @@ function BudgetProgressList({
624
626
  const categories = useMemo(() => {
625
627
  const uniqueCategories = /* @__PURE__ */ new Set();
626
628
  budgets.forEach((budget) => {
627
- budget.tag_names.forEach((tag) => {
628
- uniqueCategories.add(tag);
629
+ budget.budget_tags.forEach((bt) => {
630
+ uniqueCategories.add(bt.tag_name);
629
631
  });
630
632
  });
631
633
  return Array.from(uniqueCategories).sort();
@@ -638,7 +640,7 @@ function BudgetProgressList({
638
640
  if (statusFilter === "on-track" && percentage > 70) return false;
639
641
  if (statusFilter === "warning" && (percentage <= 70 || percentage > 90)) return false;
640
642
  if (statusFilter === "over-budget" && percentage <= 90) return false;
641
- if (categoryFilter !== "all" && !budget.tag_names.includes(categoryFilter)) return false;
643
+ if (categoryFilter !== "all" && !budget.budget_tags.some((bt) => bt.tag_name === categoryFilter)) return false;
642
644
  return true;
643
645
  });
644
646
  }, [budgets, spentByBudget, statusFilter, categoryFilter]);