From 9c1e5ed86920fbbdc32f77aaa135d7eb28d70463 Mon Sep 17 00:00:00 2001 From: Mike Clark Date: Sun, 1 Oct 2023 21:32:39 +0100 Subject: [PATCH] updating CreateAccount and CreateEncryptionKey to tsx --- .../{CreateAccount.js => CreateAccount.tsx} | 0 ...cryptionKey.js => CreateEncryptionKey.tsx} | 20 +++++++++++++++---- .../modals/{countries.js => countries.ts} | 0 packages/loot-core/src/shared/rules.ts | 2 +- packages/loot-core/src/types/handlers.d.ts | 2 ++ .../loot-core/src/types/server-handlers.d.ts | 4 +++- 6 files changed, 22 insertions(+), 6 deletions(-) rename packages/desktop-client/src/components/modals/{CreateAccount.js => CreateAccount.tsx} (100%) rename packages/desktop-client/src/components/modals/{CreateEncryptionKey.js => CreateEncryptionKey.tsx} (92%) rename packages/desktop-client/src/components/modals/{countries.js => countries.ts} (100%) diff --git a/packages/desktop-client/src/components/modals/CreateAccount.js b/packages/desktop-client/src/components/modals/CreateAccount.tsx similarity index 100% rename from packages/desktop-client/src/components/modals/CreateAccount.js rename to packages/desktop-client/src/components/modals/CreateAccount.tsx diff --git a/packages/desktop-client/src/components/modals/CreateEncryptionKey.js b/packages/desktop-client/src/components/modals/CreateEncryptionKey.tsx similarity index 92% rename from packages/desktop-client/src/components/modals/CreateEncryptionKey.js rename to packages/desktop-client/src/components/modals/CreateEncryptionKey.tsx index 9ead88f342e..ce843520069 100644 --- a/packages/desktop-client/src/components/modals/CreateEncryptionKey.js +++ b/packages/desktop-client/src/components/modals/CreateEncryptionKey.tsx @@ -1,11 +1,13 @@ -import React, { useState } from 'react'; +import React, { type ChangeEvent, useState } from 'react'; import { css } from 'glamor'; import { send } from 'loot-core/src/platform/client/fetch'; import { getCreateKeyError } from 'loot-core/src/shared/errors'; +import { type BoundActions } from '../../hooks/useActions'; import { theme } from '../../style'; +import { type CommonModalProps } from '../../types/modals'; import { ButtonWithLoading } from '../common/Button'; import ExternalLink from '../common/ExternalLink'; import InitialFocus from '../common/InitialFocus'; @@ -15,11 +17,19 @@ import Paragraph from '../common/Paragraph'; import Text from '../common/Text'; import View from '../common/View'; +type CreateEncryptionKeyProps = { + modalProps: CommonModalProps; + actions: BoundActions; + options: { + recreate: boolean; + }; +}; + export default function CreateEncryptionKey({ modalProps, actions, - options = {}, -}) { + options, +}: CreateEncryptionKeyProps) { let [password, setPassword] = useState(''); let [loading, setLoading] = useState(false); let [error, setError] = useState(''); @@ -142,7 +152,9 @@ export default function CreateEncryptionKey({ setPassword(e.target.value)} + onChange={(e: ChangeEvent) => + setPassword(e.target.value) + } /> diff --git a/packages/desktop-client/src/components/modals/countries.js b/packages/desktop-client/src/components/modals/countries.ts similarity index 100% rename from packages/desktop-client/src/components/modals/countries.js rename to packages/desktop-client/src/components/modals/countries.ts diff --git a/packages/loot-core/src/shared/rules.ts b/packages/loot-core/src/shared/rules.ts index d0fa730a44a..bc659d72e3e 100644 --- a/packages/loot-core/src/shared/rules.ts +++ b/packages/loot-core/src/shared/rules.ts @@ -45,7 +45,7 @@ export const FIELD_TYPES = new Map( }), ); -export function mapField(field, opts) { +export function mapField(field, opts = undefined) { opts = opts || {}; switch (field) { diff --git a/packages/loot-core/src/types/handlers.d.ts b/packages/loot-core/src/types/handlers.d.ts index 802e0d3bece..2537c027962 100644 --- a/packages/loot-core/src/types/handlers.d.ts +++ b/packages/loot-core/src/types/handlers.d.ts @@ -1,6 +1,7 @@ import type { BudgetHandlers } from '../server/budget/types/handlers'; import type { FiltersHandlers } from '../server/filters/types/handlers'; import type { NotesHandlers } from '../server/notes/types/handlers'; +import type { RulesHandlers } from '../server/rules/types/handlers'; import type { SchedulesHandlers } from '../server/schedules/types/handlers'; import type { ToolsHandlers } from '../server/tools/types/handlers'; @@ -13,5 +14,6 @@ export interface Handlers BudgetHandlers, FiltersHandlers, NotesHandlers, + RulesHandlers, SchedulesHandlers, ToolsHandlers {} diff --git a/packages/loot-core/src/types/server-handlers.d.ts b/packages/loot-core/src/types/server-handlers.d.ts index 6d673054350..ceaa91df30a 100644 --- a/packages/loot-core/src/types/server-handlers.d.ts +++ b/packages/loot-core/src/types/server-handlers.d.ts @@ -233,7 +233,9 @@ export interface ServerHandlers { 'sync-repair': () => Promise; - 'key-make': (arg: { password }) => Promise; + 'key-make': (arg: { + password; + }) => Promise<{ error?: { reason: string; meta?: unknown } }>; 'key-test': (arg: { fileId;