From 1a79e2b526fa60a02c63e831d92bb1d015f2aef7 Mon Sep 17 00:00:00 2001 From: Yury Saukou Date: Wed, 18 Dec 2024 11:34:11 +0400 Subject: [PATCH] modals and selection typings --- .../useRecordsSelect/useRecordsSelect.d.ts | 7 ++++--- .../lib/claiming/components/index.d.ts | 1 + .../DelayClaimsModal/DelayClaimsModal.d.ts | 20 ++++++++++++++++++ .../modals/DelayClaimsModal/index.d.ts | 1 + .../SendClaimsModal/SendClaimsModal.d.ts | 19 +++++++++++++++++ .../modals/SendClaimsModal/index.d.ts | 1 + .../lib/claiming/components/modals/index.d.ts | 2 ++ acq-components/lib/claiming/hooks/index.d.ts | 3 ++- .../claiming/hooks/useClaimsDelay/index.d.ts | 1 + .../hooks/useClaimsDelay/useClaimsDelay.d.ts | 14 +++++++++++++ .../claiming/hooks/useClaimsSend/index.d.ts | 2 +- .../hooks/useClaimsSend/useClaimsSend.d.ts | 7 +++++-- acq-components/lib/claiming/index.d.ts | 1 + .../utils/getClaimingIntervalFromDate.d.ts | 3 +++ acq-components/lib/claiming/utils/index.d.ts | 1 + .../usePiecesStatusBatchUpdate.d.ts | 21 +++++++++++++++++++ final-form/index.d.ts | 2 +- final-form/lib/stripesFinalForm.d.ts | 2 ++ 18 files changed, 100 insertions(+), 8 deletions(-) create mode 100644 acq-components/lib/claiming/components/modals/DelayClaimsModal/DelayClaimsModal.d.ts create mode 100644 acq-components/lib/claiming/components/modals/DelayClaimsModal/index.d.ts create mode 100644 acq-components/lib/claiming/components/modals/SendClaimsModal/SendClaimsModal.d.ts create mode 100644 acq-components/lib/claiming/components/modals/SendClaimsModal/index.d.ts create mode 100644 acq-components/lib/claiming/components/modals/index.d.ts create mode 100644 acq-components/lib/claiming/hooks/useClaimsDelay/index.d.ts create mode 100644 acq-components/lib/claiming/hooks/useClaimsDelay/useClaimsDelay.d.ts create mode 100644 acq-components/lib/claiming/utils/getClaimingIntervalFromDate.d.ts create mode 100644 acq-components/lib/claiming/utils/index.d.ts create mode 100644 acq-components/lib/hooks/usePiecesStatusBatchUpdate/usePiecesStatusBatchUpdate.d.ts diff --git a/acq-components/lib/FindRecords/hooks/useRecordsSelect/useRecordsSelect.d.ts b/acq-components/lib/FindRecords/hooks/useRecordsSelect/useRecordsSelect.d.ts index ebe6c12..01ecfbf 100644 --- a/acq-components/lib/FindRecords/hooks/useRecordsSelect/useRecordsSelect.d.ts +++ b/acq-components/lib/FindRecords/hooks/useRecordsSelect/useRecordsSelect.d.ts @@ -1,10 +1,11 @@ interface useRecordsSelectReturn { allRecordsSelected: boolean; - selectedRecordsMap: Record; + isRecordSelected: ({ item: T }); + resetSelectedRecords: () => void; selectedRecordsLength: number; - toggleSelectAll: () => void; + selectedRecordsMap: Record; selectRecord: (record: T) => void; - isRecordSelected: ({ item: T }); + toggleSelectAll: () => void; } export declare function useRecordsSelect({ records }: { records: T[] }): useRecordsSelectReturn; diff --git a/acq-components/lib/claiming/components/index.d.ts b/acq-components/lib/claiming/components/index.d.ts index 7c64335..2393817 100644 --- a/acq-components/lib/claiming/components/index.d.ts +++ b/acq-components/lib/claiming/components/index.d.ts @@ -1 +1,2 @@ export * from './menu-items'; +export * from './modals'; diff --git a/acq-components/lib/claiming/components/modals/DelayClaimsModal/DelayClaimsModal.d.ts b/acq-components/lib/claiming/components/modals/DelayClaimsModal/DelayClaimsModal.d.ts new file mode 100644 index 0000000..f85b14f --- /dev/null +++ b/acq-components/lib/claiming/components/modals/DelayClaimsModal/DelayClaimsModal.d.ts @@ -0,0 +1,20 @@ +import React from 'react'; +import { + FormProps, + FormRenderProps, +} from 'react-final-form'; + + +interface DelayClaimsModalOwnProps { + claimsCount: number; + disabled: boolean; + onCancel: () => void; + open: boolean; +} + +type DelayClaimsModalProps> = + DelayClaimsModalOwnProps & + Pick, 'onSubmit'> & + Partial>; + +export declare const DelayClaimsModal: >(props: DelayClaimsModalProps) => React.JSX.Element; diff --git a/acq-components/lib/claiming/components/modals/DelayClaimsModal/index.d.ts b/acq-components/lib/claiming/components/modals/DelayClaimsModal/index.d.ts new file mode 100644 index 0000000..8eee29a --- /dev/null +++ b/acq-components/lib/claiming/components/modals/DelayClaimsModal/index.d.ts @@ -0,0 +1 @@ +export { DelayClaimsModal } from './DelayClaimsModal'; diff --git a/acq-components/lib/claiming/components/modals/SendClaimsModal/SendClaimsModal.d.ts b/acq-components/lib/claiming/components/modals/SendClaimsModal/SendClaimsModal.d.ts new file mode 100644 index 0000000..ba1cc3f --- /dev/null +++ b/acq-components/lib/claiming/components/modals/SendClaimsModal/SendClaimsModal.d.ts @@ -0,0 +1,19 @@ +import React from 'react'; +import { + FormProps, + FormRenderProps, +} from 'react-final-form'; + +interface SendClaimsModalOwnProps { + claimsCount: number; + disabled: boolean; + onCancel: () => void; + open: boolean; +} + +type SendClaimsModalProps> = + SendClaimsModalOwnProps & + Pick, 'onSubmit'> & + Partial>; + +export declare const SendClaimsModal: >(props: SendClaimsModalProps) => React.JSX.Element; diff --git a/acq-components/lib/claiming/components/modals/SendClaimsModal/index.d.ts b/acq-components/lib/claiming/components/modals/SendClaimsModal/index.d.ts new file mode 100644 index 0000000..75e258b --- /dev/null +++ b/acq-components/lib/claiming/components/modals/SendClaimsModal/index.d.ts @@ -0,0 +1 @@ +export { SendClaimsModal } from './SendClaimsModal'; diff --git a/acq-components/lib/claiming/components/modals/index.d.ts b/acq-components/lib/claiming/components/modals/index.d.ts new file mode 100644 index 0000000..d030454 --- /dev/null +++ b/acq-components/lib/claiming/components/modals/index.d.ts @@ -0,0 +1,2 @@ +export { DelayClaimsModal } from './DelayClaimsModal'; +export { SendClaimsModal } from './SendClaimsModal'; diff --git a/acq-components/lib/claiming/hooks/index.d.ts b/acq-components/lib/claiming/hooks/index.d.ts index d9d4766..7bdca91 100644 --- a/acq-components/lib/claiming/hooks/index.d.ts +++ b/acq-components/lib/claiming/hooks/index.d.ts @@ -1 +1,2 @@ -export { useClaimsSend } from './useClaimsSend'; +export { useClaimsDelay } from './useClaimsDelay'; +export { ClaimingPieceResult, useClaimsSend } from './useClaimsSend'; diff --git a/acq-components/lib/claiming/hooks/useClaimsDelay/index.d.ts b/acq-components/lib/claiming/hooks/useClaimsDelay/index.d.ts new file mode 100644 index 0000000..0be7a56 --- /dev/null +++ b/acq-components/lib/claiming/hooks/useClaimsDelay/index.d.ts @@ -0,0 +1 @@ +export { useClaimsDelay } from './useClaimsDelay'; diff --git a/acq-components/lib/claiming/hooks/useClaimsDelay/useClaimsDelay.d.ts b/acq-components/lib/claiming/hooks/useClaimsDelay/useClaimsDelay.d.ts new file mode 100644 index 0000000..63aea18 --- /dev/null +++ b/acq-components/lib/claiming/hooks/useClaimsDelay/useClaimsDelay.d.ts @@ -0,0 +1,14 @@ +import { usePiecesStatusBatchUpdate } from '../../../hooks'; + +interface useClaimsDelayReturn { + isLoading: boolean; + delayClaims: ({ + claimingInterval, + pieceIds, + }: { + claimingInterval: number, + pieceIds: string[], + }) => Promise>; +} + +export declare function useClaimsDelay(): useClaimsDelayReturn; diff --git a/acq-components/lib/claiming/hooks/useClaimsSend/index.d.ts b/acq-components/lib/claiming/hooks/useClaimsSend/index.d.ts index d9d4766..dfba283 100644 --- a/acq-components/lib/claiming/hooks/useClaimsSend/index.d.ts +++ b/acq-components/lib/claiming/hooks/useClaimsSend/index.d.ts @@ -1 +1 @@ -export { useClaimsSend } from './useClaimsSend'; +export { ClaimingPieceResult, useClaimsSend } from './useClaimsSend'; diff --git a/acq-components/lib/claiming/hooks/useClaimsSend/useClaimsSend.d.ts b/acq-components/lib/claiming/hooks/useClaimsSend/useClaimsSend.d.ts index f42f4bd..e5a2c8e 100644 --- a/acq-components/lib/claiming/hooks/useClaimsSend/useClaimsSend.d.ts +++ b/acq-components/lib/claiming/hooks/useClaimsSend/useClaimsSend.d.ts @@ -1,8 +1,11 @@ interface SendClaimsData { claimingPieceIds: string[]; + claimingInterval: number; + internalNote?: string; + externalNote?: string; } -export interface ClaimingResult { +export interface ClaimingPieceResult { pieceId: string; type: 'success' | 'failure'; error?: { @@ -13,7 +16,7 @@ export interface ClaimingResult { } export interface SendClaimsResponse { - claimingPieceResults: ClaimingResult[]; + claimingPieceResults: ClaimingPieceResult[]; totalRecords: number; } diff --git a/acq-components/lib/claiming/index.d.ts b/acq-components/lib/claiming/index.d.ts index f76fd6f..c55977d 100644 --- a/acq-components/lib/claiming/index.d.ts +++ b/acq-components/lib/claiming/index.d.ts @@ -1,2 +1,3 @@ export * from './components'; export * from './hooks'; +export * from './utils'; diff --git a/acq-components/lib/claiming/utils/getClaimingIntervalFromDate.d.ts b/acq-components/lib/claiming/utils/getClaimingIntervalFromDate.d.ts new file mode 100644 index 0000000..3f8e1fe --- /dev/null +++ b/acq-components/lib/claiming/utils/getClaimingIntervalFromDate.d.ts @@ -0,0 +1,3 @@ +import dayjs from 'dayjs'; + +export declare function getClaimingIntervalFromDate(date: dayjs.ConfigType): number; diff --git a/acq-components/lib/claiming/utils/index.d.ts b/acq-components/lib/claiming/utils/index.d.ts new file mode 100644 index 0000000..6d40c1d --- /dev/null +++ b/acq-components/lib/claiming/utils/index.d.ts @@ -0,0 +1 @@ +export { getClaimingIntervalFromDate } from './getClaimingIntervalFromDate'; diff --git a/acq-components/lib/hooks/usePiecesStatusBatchUpdate/usePiecesStatusBatchUpdate.d.ts b/acq-components/lib/hooks/usePiecesStatusBatchUpdate/usePiecesStatusBatchUpdate.d.ts new file mode 100644 index 0000000..9007895 --- /dev/null +++ b/acq-components/lib/hooks/usePiecesStatusBatchUpdate/usePiecesStatusBatchUpdate.d.ts @@ -0,0 +1,21 @@ +export interface UpdatePiecesStatusData { + pieceIds: string[], + receivingStatus: ACQ.Piece.ReceivingStatus, + claimingInterval?: number, +} + +interface UpdatePiecesStatusErrorResponse { + errors: Array<{ + message: string; + code?: string; + }> +} + +export type UpdatePiecesStatusResponse = null | UpdatePiecesStatusErrorResponse; + +interface usePiecesStatusBatchUpdateReturn { + isLoading: boolean; + updatePiecesStatus: ({ data }: { data: UpdatePiecesStatusData }) => Promise; +} + +export declare function usePiecesStatusBatchUpdate(): usePiecesStatusBatchUpdateReturn; diff --git a/final-form/index.d.ts b/final-form/index.d.ts index 08cae63..3272aa7 100644 --- a/final-form/index.d.ts +++ b/final-form/index.d.ts @@ -1,2 +1,2 @@ // targeted to stripes-final-form v7.0.0 -export { default } from './lib/stripesFinalForm'; +export { default, FormProps, FormRenderProps } from './lib/stripesFinalForm'; diff --git a/final-form/lib/stripesFinalForm.d.ts b/final-form/lib/stripesFinalForm.d.ts index 0b5f435..e610058 100644 --- a/final-form/lib/stripesFinalForm.d.ts +++ b/final-form/lib/stripesFinalForm.d.ts @@ -29,3 +29,5 @@ export default function stripesFinalForm< ): ( Component: ComponentType & ComponentProps> ) => ComponentType, extractedProps>>; + +export type { FormProps, FormRenderProps } from 'react-final-form';