A local-first personal finance app
Maintenance: Convert FixEncryptionKey, Loading, AnimatedLoading components to TypeScript (#1784)
Michael Clarkeb54487d8ef3
diff --git a/packages/desktop-client/src/components/common/Modal.tsx b/packages/desktop-client/src/components/common/Modal.tsxindex 2bab19bc7f..a03bdd004b 100644--- a/packages/desktop-client/src/components/common/Modal.tsx+++ b/packages/desktop-client/src/components/common/Modal.tsx@@ -18,7 +18,7 @@ import Text from './Text';import View from './View';export type ModalProps = {- title: string;+ title?: string;isCurrent?: boolean;isHidden?: boolean;children: ReactNode | (() => ReactNode);diff --git a/packages/desktop-client/src/components/modals/FixEncryptionKey.js b/packages/desktop-client/src/components/modals/FixEncryptionKey.tsxsimilarity index 92%rename from packages/desktop-client/src/components/modals/FixEncryptionKey.jsrename to packages/desktop-client/src/components/modals/FixEncryptionKey.tsxindex 57e52e37ed..d327898f92 100644--- a/packages/desktop-client/src/components/modals/FixEncryptionKey.js+++ b/packages/desktop-client/src/components/modals/FixEncryptionKey.tsx@@ -1,9 +1,12 @@import React, { useState } from 'react';+import { type FinanceModals } from 'loot-core/src/client/state-types/modals';import { send } from 'loot-core/src/platform/client/fetch';import { getTestKeyError } from 'loot-core/src/shared/errors';+import { type BoundActions } from '../../hooks/useActions';import { theme } from '../../style';+import { type CommonModalProps } from '../../types/modals';import Button, { ButtonWithLoading } from '../common/Button';import ExternalLink from '../common/ExternalLink';import InitialFocus from '../common/InitialFocus';@@ -13,11 +16,17 @@ import Paragraph from '../common/Paragraph';import Text from '../common/Text';import View from '../common/View';+type FixEncryptionKeyProps = {+ modalProps: CommonModalProps;+ actions: BoundActions;+ options: FinanceModals['fix-encryption-key'];+};+export default function FixEncryptionKey({modalProps,actions,options = {},-}) {+}: FixEncryptionKeyProps) {let { hasExistingKey, cloudFileId, onSuccess } = options;let [password, setPassword] = useState('');diff --git a/packages/desktop-client/src/icons/AnimatedLoading.js b/packages/desktop-client/src/icons/AnimatedLoading.tsxsimilarity index 73%rename from packages/desktop-client/src/icons/AnimatedLoading.jsrename to packages/desktop-client/src/icons/AnimatedLoading.tsxindex 803c86f1c6..a153265a40 100644--- a/packages/desktop-client/src/icons/AnimatedLoading.js+++ b/packages/desktop-client/src/icons/AnimatedLoading.tsx@@ -1,15 +1,15 @@-import React from 'react';+import React, { type SVGProps } from 'react';-import { css } from 'glamor';+import { css, keyframes } from 'glamor';import Loading from './Loading';-const rotation = css.keyframes({+const rotation = keyframes({'0%': { transform: 'rotate(-90deg)' },'100%': { transform: 'rotate(666deg)' },});-function AnimatedLoading(props) {+function AnimatedLoading(props: SVGProps<SVGSVGElement>) {return (<spanclassName={`${css({diff --git a/packages/desktop-client/src/icons/Loading.js b/packages/desktop-client/src/icons/Loading.tsxsimilarity index 88%rename from packages/desktop-client/src/icons/Loading.jsrename to packages/desktop-client/src/icons/Loading.tsxindex 332f6cebc5..5b19843ad4 100644--- a/packages/desktop-client/src/icons/Loading.js+++ b/packages/desktop-client/src/icons/Loading.tsx@@ -1,6 +1,6 @@-import React, { useState } from 'react';+import React, { type SVGProps, useState } from 'react';-const SvgLoading = props => {+const SvgLoading = (props: SVGProps<SVGSVGElement>) => {let { color = 'currentColor' } = props;let [gradientId] = useState('gradient-' + Math.random());diff --git a/packages/loot-core/src/client/state-types/queries.d.ts b/packages/loot-core/src/client/state-types/queries.d.tsindex bad2b1904e..829c903821 100644--- a/packages/loot-core/src/client/state-types/queries.d.ts+++ b/packages/loot-core/src/client/state-types/queries.d.ts@@ -8,7 +8,7 @@ export type QueriesState = {updatedAccounts: string[];accounts: AccountEntity[];categories: Awaited<ReturnType<Handlers['get-categories']>>;- payees: unknown[];+ payees: Awaited<ReturnType<Handlers['payees-get']>>;earliestTransaction: unknown | null;};@@ -51,7 +51,7 @@ type LoadCategoriesAction = {type LoadPayeesAction = {type: typeof constants.LOAD_PAYEES;- payees: unknown[];+ payees: State['payees'];};export type QueriesActions =diff --git a/packages/loot-core/src/types/server-handlers.d.ts b/packages/loot-core/src/types/server-handlers.d.tsindex e7c3e7ba0c..8266072216 100644--- a/packages/loot-core/src/types/server-handlers.d.ts+++ b/packages/loot-core/src/types/server-handlers.d.ts@@ -5,7 +5,7 @@ import { Backup } from '../server/backups';import { RemoteFile } from '../server/cloud-storage';import { Message } from '../server/sync';-import { AccountEntity } from './models';+import { AccountEntity, PayeeEntity } from './models';import { EmptyObject } from './util';export interface ServerHandlers {@@ -95,7 +95,7 @@ export interface ServerHandlers {'payee-create': (arg: { name }) => Promise<unknown>;- 'payees-get': () => Promise<unknown[]>;+ 'payees-get': () => Promise<PayeeEntity[]>;'payees-get-rule-counts': () => Promise<unknown>;diff --git a/upcoming-release-notes/1784.md b/upcoming-release-notes/1784.mdnew file mode 100644index 0000000000..530c9a07ec--- /dev/null+++ b/upcoming-release-notes/1784.md@@ -0,0 +1,6 @@+---+category: Maintenance+authors: [MikesGlitch]+---++Convert FixEncryptionKey, Loading, AnimatedLoading components to TypeScript and update get-payee query type.