commit 53146dc6c116dcb5eb0f6c30a4c49b0e7dbb7a0b parent d4eda1e1225dfd26fb829bbe6bc55a8d3e3bc419 Author: Florian Dold <florian@dold.me> Date: Wed, 19 Feb 2025 12:49:24 +0100 use shared tsconfig for backoffice UI, fix compiler errors Diffstat:
14 files changed, 28 insertions(+), 60 deletions(-)
diff --git a/packages/merchant-backoffice-ui/src/components/form/InputDuration.tsx b/packages/merchant-backoffice-ui/src/components/form/InputDuration.tsx @@ -18,6 +18,7 @@ * * @author Sebastian Javier Marchano (sebasjm) */ +import { Duration } from "@gnu-taler/taler-util"; import { useTranslationContext } from "@gnu-taler/web-util/browser"; import { formatDuration, intervalToDuration } from "date-fns"; import { ComponentChildren, h, VNode } from "preact"; @@ -25,7 +26,6 @@ import { useState } from "preact/hooks"; import { SimpleModal } from "../modal/index.js"; import { DurationPicker } from "../picker/DurationPicker.js"; import { InputProps, useField } from "./useField.js"; -import { Duration } from "@gnu-taler/taler-util"; export interface Props<T> extends InputProps<T> { expand?: boolean; @@ -86,6 +86,8 @@ export function InputDuration<T>({ return i18n.str`${value}min`; case "xSeconds": return i18n.str`${value}sec`; + default: + throw Error("not reached"); } }, localize: { diff --git a/packages/merchant-backoffice-ui/src/components/picker/DatePicker.tsx b/packages/merchant-backoffice-ui/src/components/picker/DatePicker.tsx @@ -54,6 +54,7 @@ export class DatePicker extends Component<Props, State> { // update the state this.setState({ currentDate: date }); this.passDateToParent(date); + return true; } /** @@ -135,6 +136,7 @@ export class DatePicker extends Component<Props, State> { displayedYear: this.state.currentDate.getFullYear(), }); } + return true; } toggleYearSelector() { diff --git a/packages/merchant-backoffice-ui/src/components/product/InventoryProductForm.tsx b/packages/merchant-backoffice-ui/src/components/product/InventoryProductForm.tsx @@ -13,22 +13,22 @@ You should have received a copy of the GNU General Public License along with GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ +import { TalerMerchantApi } from "@gnu-taler/taler-util"; import { useTranslationContext } from "@gnu-taler/web-util/browser"; import { h, VNode } from "preact"; import { useState } from "preact/hooks"; +import { WithId } from "../../declaration.js"; import { ProductMap } from "../../paths/instance/orders/create/CreatePage.js"; import { FormErrors, FormProvider } from "../form/FormProvider.js"; import { InputNumber } from "../form/InputNumber.js"; import { InputSearchOnList } from "../form/InputSearchOnList.js"; -import { TalerMerchantApi } from "@gnu-taler/taler-util"; -import { WithId } from "../../declaration.js"; type Form = { product: TalerMerchantApi.ProductDetail & WithId; quantity: number; }; -interface Props { +export interface Props { currentProducts: ProductMap; onAddProduct: ( product: TalerMerchantApi.ProductDetail & WithId, diff --git a/packages/merchant-backoffice-ui/src/hooks/instance.ts b/packages/merchant-backoffice-ui/src/hooks/instance.ts @@ -62,11 +62,11 @@ export function useInstanceKYCDetails() { const { state, lib } = useSessionContext(); async function fetcher([token]: [AccessToken]) { - return await lib.instance.getCurrentIntanceKycStatus(token, {}); + return await lib.instance.getCurrentInstanceKycStatus(token, {}); } const { data, error } = useSWR< - TalerMerchantManagementResultByMethod<"getCurrentIntanceKycStatus">, + TalerMerchantManagementResultByMethod<"getCurrentInstanceKycStatus">, TalerHttpError >([state.token, "getCurrentIntanceKycStatus"], fetcher); diff --git a/packages/merchant-backoffice-ui/src/paths/admin/create/CreatePage.tsx b/packages/merchant-backoffice-ui/src/paths/admin/create/CreatePage.tsx @@ -34,11 +34,11 @@ import { FormProvider, } from "../../../components/form/FormProvider.js"; import { Input } from "../../../components/form/Input.js"; +import { InputToggle } from "../../../components/form/InputToggle.js"; import { DefaultInstanceFormFields } from "../../../components/instance/DefaultInstanceFormFields.js"; import { usePreference } from "../../../hooks/preference.js"; import { INSTANCE_ID_REGEX } from "../../../utils/constants.js"; import { undefinedIfEmpty } from "../../../utils/table.js"; -import { InputToggle } from "../../../components/form/InputToggle.js"; export type Entity = TalerMerchantApi.InstanceConfigurationMessage & { auth_token?: string; @@ -46,7 +46,7 @@ export type Entity = TalerMerchantApi.InstanceConfigurationMessage & { // default_wire_transfer_delay: Duration; }; -interface Props { +export interface Props { onCreate: (d: TalerMerchantApi.InstanceConfigurationMessage) => Promise<void>; onBack?: () => void; forceId?: string; diff --git a/packages/merchant-backoffice-ui/src/paths/instance/orders/create/CreatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/orders/create/CreatePage.tsx @@ -26,8 +26,6 @@ import { Duration, TalerMerchantApi, TalerProtocolDuration, - codecForURL, - getURLHostnamePortPath, } from "@gnu-taler/taler-util"; import { useTranslationContext } from "@gnu-taler/web-util/browser"; import { format, isFuture } from "date-fns"; @@ -54,9 +52,8 @@ import { WithId } from "../../../../declaration.js"; import { usePreference } from "../../../../hooks/preference.js"; import { rate } from "../../../../utils/amount.js"; import { undefinedIfEmpty } from "../../../../utils/table.js"; -import { error } from "console"; -interface Props { +export interface Props { onCreate: (d: TalerMerchantApi.PostOrderRequest) => void; onBack?: () => void; instanceConfig: InstanceConfig; diff --git a/packages/merchant-backoffice-ui/src/paths/instance/orders/details/DetailPage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/orders/details/DetailPage.tsx @@ -50,7 +50,7 @@ import { Event, Timeline } from "./Timeline.js"; type Entity = TalerMerchantApi.MerchantOrderStatusResponse; type CT = TalerMerchantApi.ContractTerms; -interface Props { +export interface Props { onBack: () => void; selected: Entity; id: string; diff --git a/packages/merchant-backoffice-ui/src/paths/instance/products/create/Create.stories.tsx b/packages/merchant-backoffice-ui/src/paths/instance/products/create/Create.stories.tsx @@ -19,7 +19,7 @@ * @author Sebastian Javier Marchano (sebasjm) */ -import { h, VNode, FunctionalComponent } from "preact"; +import { FunctionalComponent, h } from "preact"; import { CreatePage as TestedComponent } from "./CreatePage.js"; export default { diff --git a/packages/merchant-backoffice-ui/src/paths/instance/products/create/CreatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/products/create/CreatePage.tsx @@ -30,7 +30,7 @@ type Entity = TalerMerchantApi.ProductAddDetail & { product_id: string; }; -interface Props { +export interface Props { onCreate: (d: Entity) => Promise<void>; onBack?: () => void; } diff --git a/packages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/create/Create.stories.tsx b/packages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/create/Create.stories.tsx @@ -19,7 +19,7 @@ * @author Christian Blättler */ -import { h, VNode, FunctionalComponent } from "preact"; +import { FunctionalComponent, h } from "preact"; import { CreatePage as TestedComponent } from "./CreatePage.js"; export default { diff --git a/packages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/create/CreatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/create/CreatePage.tsx @@ -19,16 +19,16 @@ * @author Christian Blättler */ +import { TalerMerchantApi } from "@gnu-taler/taler-util"; import { useTranslationContext } from "@gnu-taler/web-util/browser"; import { h, VNode } from "preact"; import { AsyncButton } from "../../../../components/exception/AsyncButton.js"; -import { useListener } from "../../../../hooks/listener.js"; import { TokenFamilyForm } from "../../../../components/tokenfamily/TokenFamilyForm.js"; -import { TalerMerchantApi } from "@gnu-taler/taler-util"; +import { useListener } from "../../../../hooks/listener.js"; type Entity = TalerMerchantApi.TokenFamilyCreateRequest; -interface Props { +export interface Props { onCreate: (d: Entity) => Promise<void>; onBack?: () => void; } diff --git a/packages/merchant-backoffice-ui/src/paths/instance/transfers/create/CreatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/transfers/create/CreatePage.tsx @@ -39,7 +39,7 @@ import { undefinedIfEmpty } from "../../../../utils/table.js"; type Entity = TalerMerchantApi.TransferInformation; -interface Props { +export interface Props { onCreate: (d: Entity) => Promise<void>; onBack?: () => void; accounts: string[]; diff --git a/packages/merchant-backoffice-ui/src/paths/instance/update/UpdatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/update/UpdatePage.tsx @@ -38,7 +38,7 @@ export type Entity = Omit<Omit<TalerMerchantApi.InstanceReconfigurationMessage, default_wire_transfer_delay: Duration, } & TalerForm; -interface Props { +export interface Props { onUpdate: (d: TalerMerchantApi.InstanceReconfigurationMessage) => void; selected: TalerMerchantApi.QueryInstancesResponse; isLoading: boolean; diff --git a/packages/merchant-backoffice-ui/tsconfig.json b/packages/merchant-backoffice-ui/tsconfig.json @@ -1,4 +1,5 @@ { + "extends": "../../tsconfig.defaults.json", "compilerOptions": { /* Basic Options */ "target": "ES2020" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */, @@ -7,52 +8,18 @@ "es2020", "dom" ] /* Specify library files to be included in the compilation: */, - // "allowJs": true, /* Allow javascript files to be compiled. */ - // "checkJs": true, /* Report errors in .js files. */ "jsx": "react" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */, "jsxFactory": "h" /* Specify the JSX factory function to use when targeting react JSX emit, e.g. React.createElement or h. */, "jsxFragmentFactory": "Fragment", // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-0.html#custom-jsx-factories - // "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./", /* Concatenate and emit output to single file. */ - // "outDir": "./", /* Redirect output structure to the directory. */ - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "removeComments": true, /* Do not emit comments to output. */ "noEmit": true /* Do not emit outputs. */, - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ - // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - /* Strict Type-Checking Options */ - "strict": true /* Enable all strict type-checking options. */, - // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* Enable strict null checks. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ - /* Additional Checks */ - // "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ /* Module Resolution Options */ - "moduleResolution": "node16" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */, - "esModuleInterop": true /* */, - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ - /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ /* Advanced Options */ "skipLibCheck": true /* Skip type checking of declaration files. */ }, + "references": [ + { + "path": "../taler-util/" + } + ], "include": ["src/**/*", "tests/**/*"] }