Skip to content

Commit

Permalink
modals and selection typings
Browse files Browse the repository at this point in the history
  • Loading branch information
usavkov-epam committed Dec 18, 2024
1 parent 235eaef commit 1a79e2b
Show file tree
Hide file tree
Showing 18 changed files with 100 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
interface useRecordsSelectReturn<T> {
allRecordsSelected: boolean;
selectedRecordsMap: Record<string, T>;
isRecordSelected: ({ item: T });
resetSelectedRecords: () => void;
selectedRecordsLength: number;
toggleSelectAll: () => void;
selectedRecordsMap: Record<string, T>;
selectRecord: (record: T) => void;
isRecordSelected: ({ item: T });
toggleSelectAll: () => void;
}

export declare function useRecordsSelect<T = unknown & { id: string }>({ records }: { records: T[] }): useRecordsSelectReturn<T>;
1 change: 1 addition & 0 deletions acq-components/lib/claiming/components/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './menu-items';
export * from './modals';
Original file line number Diff line number Diff line change
@@ -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<FormValues = Record<string, unknown>> =
DelayClaimsModalOwnProps &
Pick<FormProps<FormValues>, 'onSubmit'> &
Partial<FormRenderProps<FormValues>>;

export declare const DelayClaimsModal: <FormValues = Record<string, unknown>>(props: DelayClaimsModalProps<FormValues>) => React.JSX.Element;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { DelayClaimsModal } from './DelayClaimsModal';
Original file line number Diff line number Diff line change
@@ -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<FormValues = Record<string, unknown>> =
SendClaimsModalOwnProps &
Pick<FormProps<FormValues>, 'onSubmit'> &
Partial<FormRenderProps<FormValues>>;

export declare const SendClaimsModal: <FormValues = Record<string, unknown>>(props: SendClaimsModalProps<FormValues>) => React.JSX.Element;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { SendClaimsModal } from './SendClaimsModal';
2 changes: 2 additions & 0 deletions acq-components/lib/claiming/components/modals/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { DelayClaimsModal } from './DelayClaimsModal';
export { SendClaimsModal } from './SendClaimsModal';
3 changes: 2 additions & 1 deletion acq-components/lib/claiming/hooks/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { useClaimsSend } from './useClaimsSend';
export { useClaimsDelay } from './useClaimsDelay';
export { ClaimingPieceResult, useClaimsSend } from './useClaimsSend';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { useClaimsDelay } from './useClaimsDelay';
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { usePiecesStatusBatchUpdate } from '../../../hooks';

interface useClaimsDelayReturn {
isLoading: boolean;
delayClaims: ({
claimingInterval,
pieceIds,
}: {
claimingInterval: number,
pieceIds: string[],
}) => Promise<ReturnType<typeof usePiecesStatusBatchUpdate>>;
}

export declare function useClaimsDelay(): useClaimsDelayReturn;
2 changes: 1 addition & 1 deletion acq-components/lib/claiming/hooks/useClaimsSend/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { useClaimsSend } from './useClaimsSend';
export { ClaimingPieceResult, useClaimsSend } from './useClaimsSend';
Original file line number Diff line number Diff line change
@@ -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?: {
Expand All @@ -13,7 +16,7 @@ export interface ClaimingResult {
}

export interface SendClaimsResponse {
claimingPieceResults: ClaimingResult[];
claimingPieceResults: ClaimingPieceResult[];
totalRecords: number;
}

Expand Down
1 change: 1 addition & 0 deletions acq-components/lib/claiming/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './components';
export * from './hooks';
export * from './utils';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import dayjs from 'dayjs';

export declare function getClaimingIntervalFromDate(date: dayjs.ConfigType): number;
1 change: 1 addition & 0 deletions acq-components/lib/claiming/utils/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { getClaimingIntervalFromDate } from './getClaimingIntervalFromDate';
Original file line number Diff line number Diff line change
@@ -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<UpdatePiecesStatusResponse>;
}

export declare function usePiecesStatusBatchUpdate(): usePiecesStatusBatchUpdateReturn;
2 changes: 1 addition & 1 deletion final-form/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// targeted to stripes-final-form v7.0.0
export { default } from './lib/stripesFinalForm';
export { default, FormProps, FormRenderProps } from './lib/stripesFinalForm';
2 changes: 2 additions & 0 deletions final-form/lib/stripesFinalForm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ export default function stripesFinalForm<
): (
Component: ComponentType<FormRenderProps<FormValues> & ComponentProps>
) => ComponentType<ComponentProps & Pick<FormProps<FormValues>, extractedProps>>;

export type { FormProps, FormRenderProps } from 'react-final-form';

0 comments on commit 1a79e2b

Please sign in to comment.