Skip to content

Commit 9c0fd3f

Browse files
committed
fix types
1 parent 20f2b11 commit 9c0fd3f

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

projects/packages/forms/src/dashboard/components/response-actions/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ import {
2020
* Types
2121
*/
2222
import type { FormResponse } from '../../../types';
23+
import type { Registry } from '../../inbox/dataviews/types';
2324

2425
type ResponseNavigationProps = {
25-
onActionComplete?: ( FormResponse ) => void;
26+
onActionComplete?: ( response: FormResponse ) => void;
2627
response: FormResponse;
2728
};
2829

@@ -37,7 +38,7 @@ const ResponseActions = ( {
3738
const [ isDeleting, setIsDeleting ] = useState( false );
3839
const [ isTogglingReadStatus, setIsTogglingReadStatus ] = useState( false );
3940

40-
const registry = useRegistry();
41+
const registry = useRegistry() as unknown as Registry;
4142

4243
const handleMarkAsSpam = useCallback( async () => {
4344
onActionComplete?.( response );

projects/packages/forms/src/dashboard/inbox/dataviews/types.tsx

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { FormResponse } from '../../../types';
12
import type { StoreDescriptor } from '@wordpress/data';
23

34
/**
@@ -14,7 +15,7 @@ export type QueryParams = {
1415
/**
1516
* Store actions
1617
*/
17-
type Registry = {
18+
export type Registry = {
1819
dispatch: ( store: StoreDescriptor ) => {
1920
// Notices store actions
2021
createSuccessNotice: (
@@ -35,14 +36,14 @@ type Registry = {
3536
deleteEntityRecord: (
3637
kind: string,
3738
name: string,
38-
recordId: string,
39+
recordId: number,
3940
query: Record< string, unknown >,
4041
options?: { throwOnError?: boolean }
4142
) => Promise< void >;
4243
editEntityRecord: (
4344
kind: string,
4445
name: string,
45-
recordId: string,
46+
recordId: number,
4647
edits: Record< string, unknown >
4748
) => Promise< void >;
4849

@@ -56,7 +57,7 @@ type Registry = {
5657
doBulkAction: ( ids: string[], action: string ) => void;
5758
invalidateFilters: () => void;
5859
invalidateCounts: () => void;
59-
markRecordsAsInvalid: ( ids: string[] ) => void;
60+
markRecordsAsInvalid: ( ids: number[] ) => void;
6061
};
6162
select: ( store: StoreDescriptor ) => {
6263
// Dashboard store select actions
@@ -66,25 +67,18 @@ type Registry = {
6667
getEntityRecord: (
6768
kind: string,
6869
name: string,
69-
recordId: string
70+
recordId: number
7071
) => Record< string, unknown > | undefined;
7172
};
7273
};
7374

74-
type Item = {
75-
id: string;
76-
status: string;
77-
edit_form_url: string;
78-
is_unread: boolean;
79-
};
80-
8175
export type Action = {
8276
id: string;
8377
isPrimary: boolean;
8478
icon: React.ReactNode;
8579
label: string;
8680
modalHeader?: string;
87-
isEligible?: ( item: Item ) => boolean;
81+
isEligible?: ( item: FormResponse ) => boolean;
8882
supportsBulk?: boolean;
89-
callback?: ( items: Item[], { registry }: { registry: Registry } ) => Promise< void >;
83+
callback?: ( items: FormResponse[], { registry }: { registry: Registry } ) => Promise< void >;
9084
};

projects/packages/forms/src/types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ export interface FormResponse {
114114
is_unread: boolean;
115115
/** The fields of the response. */
116116
fields: Record< string, unknown >;
117+
/** The URL to edit the form that the response was submitted to. */
118+
edit_form_url: string;
117119
}
118120

119121
/**

0 commit comments

Comments
 (0)