Skip to content
Snippets Groups Projects
Unverified Commit 8bf0f8e5 authored by Joel Jeremy Marquez's avatar Joel Jeremy Marquez Committed by GitHub
Browse files

[TS migration] MobileBudget tsx (#2081)


* MobileBudget tsx

* Release notes

* Fix type error

* Update upcoming-release-notes/2081.md

Co-authored-by: default avatarMatiss Janis Aboltins <matiss@mja.lv>

* SyncRefresh.tsx

* Remove loadCategories

---------

Co-authored-by: default avatarMatiss Janis Aboltins <matiss@mja.lv>
parent bc072350
No related branches found
No related tags found
No related merge requests found
import { type ReactNode, useState } from 'react';
import React, { type ReactNode, useState } from 'react';
type ChildrenProps = {
refreshing: boolean;
......@@ -17,5 +17,5 @@ export function SyncRefresh({ onSync, children }: SyncRefreshProps) {
setSyncing(false);
}
return children({ refreshing: syncing, onRefresh: onSync_ });
return <>{children({ refreshing: syncing, onRefresh: onSync_ })}</>;
}
......@@ -63,7 +63,10 @@ export type QueryDataEntity = {
amount: number;
};
export type UncategorizedEntity = CategoryEntity & {
export type UncategorizedEntity = Pick<
CategoryEntity,
'name' | 'id' | 'hidden'
> & {
/*
When looking at uncategorized and hidden transactions we
need a way to group them. To do this we give them a unique
......@@ -71,10 +74,10 @@ export type UncategorizedEntity = CategoryEntity & {
transctions from our query. For this we use the 3 variables
below.
*/
uncategorized_id: string;
is_off_budget: boolean;
is_transfer: boolean;
has_category: boolean;
uncategorized_id?: string;
is_off_budget?: boolean;
is_transfer?: boolean;
has_category?: boolean;
};
const uncategorizedCategory: UncategorizedEntity = {
......@@ -105,7 +108,10 @@ const offBudgetCategory: UncategorizedEntity = {
has_category: true,
};
type UncategorizedGroupEntity = CategoryGroupEntity & {
type UncategorizedGroupEntity = Pick<
CategoryGroupEntity,
'name' | 'id' | 'hidden'
> & {
categories?: UncategorizedEntity[];
};
......
......@@ -85,7 +85,7 @@ export function createGroupedSpreadsheet({
let groupedAssets = 0;
let groupedDebts = 0;
group.categories.map(item => {
group.categories.forEach(item => {
const monthAssets = filterHiddenItems(item, assets)
.filter(
asset => asset.date === month && asset.category === item.id,
......@@ -99,8 +99,6 @@ export function createGroupedSpreadsheet({
)
.reduce((a, v) => (a = a + v.amount), 0);
groupedDebts += monthDebts;
return null;
});
totalAssets += groupedAssets;
......
......@@ -131,6 +131,23 @@ type FinanceModals = {
name: string;
onSave: (id: string, notes: string) => void;
};
'report-budget-summary': { month: string };
'rollover-budget-summary': {
month: string;
onBudgetAction: (
month: string,
type: string,
args: unknown,
) => Promise<void>;
};
'new-category-group': {
onValidate?: (value: string) => string;
onSubmit: (value: string) => Promise<void>;
};
'new-category': {
onValidate?: (value: string) => string;
onSubmit: (value: string) => Promise<void>;
};
};
export type PushModalAction = {
......
import { CategoryEntity } from './category';
export interface CategoryGroupEntity {
id?: string;
name: string;
......
......@@ -5,13 +5,16 @@ import { Backup } from '../server/backups';
import { RemoteFile } from '../server/cloud-storage';
import { Node as SpreadsheetNode } from '../server/spreadsheet/spreadsheet';
import { Message } from '../server/sync';
import { QueryState } from '../shared/query';
import { Budget } from './budget';
import {
AccountEntity,
CategoryEntity,
CategoryGroupEntity,
GoCardlessToken,
GoCardlessInstitution,
PayeeEntity,
} from './models';
import { EmptyObject } from './util';
......@@ -31,8 +34,6 @@ export interface ServerHandlers {
'transaction-add': (transaction) => Promise<EmptyObject>;
'transaction-add': (transaction) => Promise<EmptyObject>;
'transaction-delete': (transaction) => Promise<EmptyObject>;
'transactions-parse-file': (arg: {
......@@ -47,7 +48,7 @@ export interface ServerHandlers {
payees;
}) => Promise<unknown>;
'transactions-export-query': (arg: { query: queryState }) => Promise<unknown>;
'transactions-export-query': (arg: { query: QueryState }) => Promise<unknown>;
'get-categories': () => Promise<{
grouped: Array<CategoryGroupEntity>;
......@@ -252,10 +253,7 @@ export interface ServerHandlers {
'make-plaid-public-token': (arg: {
bankId;
}) => Promise<
| { error: ''; code: data.error_code; type: data.error_type }
| { linkToken: data.link_token }
>;
}) => Promise<{ error: ''; code; type } | { linkToken }>;
'save-global-prefs': (prefs) => Promise<'ok'>;
......@@ -280,9 +278,9 @@ export interface ServerHandlers {
'get-did-bootstrap': () => Promise<boolean>;
'subscribe-needs-bootstrap': (
args: { url } = {},
) => Promise<
'subscribe-needs-bootstrap': (args: {
url;
}) => Promise<
{ error: string } | { bootstrapped: unknown; hasServer: boolean }
>;
......@@ -318,7 +316,7 @@ export interface ServerHandlers {
'reset-budget-cache': () => Promise<unknown>;
'upload-budget': (arg: { id } = {}) => Promise<{ error?: string }>;
'upload-budget': (arg: { id }) => Promise<{ error?: string }>;
'download-budget': (arg: { fileId; replace? }) => Promise<{ error; id }>;
......
---
category: Maintenance
authors: [joel-jeremy]
---
Refactored MobileBudget component to TypeScript
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment