From 7064d322434078305d9c1032ae64a80103ad0594 Mon Sep 17 00:00:00 2001 From: Mike Clark Date: Wed, 11 Oct 2023 21:16:58 +0100 Subject: [PATCH 1/4] fixencryptionkey modal to typescript --- .../desktop-client/src/components/common/Modal.tsx | 2 +- .../{FixEncryptionKey.js => FixEncryptionKey.tsx} | 11 ++++++++++- .../loot-core/src/client/state-types/queries.d.ts | 4 ++-- packages/loot-core/src/types/server-handlers.d.ts | 10 +++++++++- 4 files changed, 22 insertions(+), 5 deletions(-) rename packages/desktop-client/src/components/modals/{FixEncryptionKey.js => FixEncryptionKey.tsx} (92%) diff --git a/packages/desktop-client/src/components/common/Modal.tsx b/packages/desktop-client/src/components/common/Modal.tsx index 2bab19bc7f5..a03bdd004b3 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.tsx similarity index 92% rename from packages/desktop-client/src/components/modals/FixEncryptionKey.js rename to packages/desktop-client/src/components/modals/FixEncryptionKey.tsx index 57e52e37edf..d327898f928 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/loot-core/src/client/state-types/queries.d.ts b/packages/loot-core/src/client/state-types/queries.d.ts index bad2b1904e0..829c9038218 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>; - payees: unknown[]; + payees: Awaited>; 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.ts index e7c3e7ba0ca..27cfa51aa03 100644 --- a/packages/loot-core/src/types/server-handlers.d.ts +++ b/packages/loot-core/src/types/server-handlers.d.ts @@ -95,7 +95,15 @@ export interface ServerHandlers { 'payee-create': (arg: { name }) => Promise; - 'payees-get': () => Promise; + 'payees-get': () => Promise< + { + id: string; + name: string; + category?: string | null; + tombstone?: number; + transfer_acc?: string | null; + }[] + >; 'payees-get-rule-counts': () => Promise; From d65af922161a425b5881d05b291e7a9d5327c3c3 Mon Sep 17 00:00:00 2001 From: Mike Clark Date: Wed, 11 Oct 2023 21:20:29 +0100 Subject: [PATCH 2/4] add release notes --- upcoming-release-notes/1784.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 upcoming-release-notes/1784.md diff --git a/upcoming-release-notes/1784.md b/upcoming-release-notes/1784.md new file mode 100644 index 00000000000..63fcb104ef0 --- /dev/null +++ b/upcoming-release-notes/1784.md @@ -0,0 +1,6 @@ +--- +category: Maintenance +authors: [MikesGlitch] +--- + +Convert FixEncryptionKey component to TypeScript and update get-payee query type. From cad2c5852f9e14ce0f0303427b94316dcb3f3368 Mon Sep 17 00:00:00 2001 From: Mike Clark Date: Wed, 11 Oct 2023 21:48:39 +0100 Subject: [PATCH 3/4] converting loading components to typescript --- .../src/icons/{AnimatedLoading.js => AnimatedLoading.tsx} | 8 ++++---- .../desktop-client/src/icons/{Loading.js => Loading.tsx} | 4 ++-- upcoming-release-notes/1784.md | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) rename packages/desktop-client/src/icons/{AnimatedLoading.js => AnimatedLoading.tsx} (73%) rename packages/desktop-client/src/icons/{Loading.js => Loading.tsx} (88%) diff --git a/packages/desktop-client/src/icons/AnimatedLoading.js b/packages/desktop-client/src/icons/AnimatedLoading.tsx similarity index 73% rename from packages/desktop-client/src/icons/AnimatedLoading.js rename to packages/desktop-client/src/icons/AnimatedLoading.tsx index 803c86f1c6f..a153265a405 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) { return ( { +const SvgLoading = (props: SVGProps) => { let { color = 'currentColor' } = props; let [gradientId] = useState('gradient-' + Math.random()); diff --git a/upcoming-release-notes/1784.md b/upcoming-release-notes/1784.md index 63fcb104ef0..530c9a07ec3 100644 --- a/upcoming-release-notes/1784.md +++ b/upcoming-release-notes/1784.md @@ -3,4 +3,4 @@ category: Maintenance authors: [MikesGlitch] --- -Convert FixEncryptionKey component to TypeScript and update get-payee query type. +Convert FixEncryptionKey, Loading, AnimatedLoading components to TypeScript and update get-payee query type. From 3b9f541a5eac50d36c305de8ac6a07fec046d0d0 Mon Sep 17 00:00:00 2001 From: Mike Clark Date: Wed, 11 Oct 2023 22:00:00 +0100 Subject: [PATCH 4/4] updatign to payee entity since it's a select * --- packages/loot-core/src/types/server-handlers.d.ts | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/packages/loot-core/src/types/server-handlers.d.ts b/packages/loot-core/src/types/server-handlers.d.ts index 27cfa51aa03..82660722163 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,15 +95,7 @@ export interface ServerHandlers { 'payee-create': (arg: { name }) => Promise; - 'payees-get': () => Promise< - { - id: string; - name: string; - category?: string | null; - tombstone?: number; - transfer_acc?: string | null; - }[] - >; + 'payees-get': () => Promise; 'payees-get-rule-counts': () => Promise;