From 23c43f73090db805be83eb144e77fbfa735b2b9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Wed, 13 Nov 2024 16:47:09 +0100 Subject: [PATCH] Use BasePostWithEmbeddedAuthor --- packages/fields/src/fields/author/author-view.tsx | 4 ++-- packages/fields/src/fields/author/index.tsx | 4 ++-- packages/fields/src/types.ts | 10 +++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/fields/src/fields/author/author-view.tsx b/packages/fields/src/fields/author/author-view.tsx index 51e0a1ca59b75..8232350af5193 100644 --- a/packages/fields/src/fields/author/author-view.tsx +++ b/packages/fields/src/fields/author/author-view.tsx @@ -17,9 +17,9 @@ import type { User } from '@wordpress/core-data'; /** * Internal dependencies */ -import type { BasePost } from '../../types'; +import type { BasePostWithEmbeddedAuthor } from '../../types'; -function AuthorView( { item }: { item: BasePost } ) { +function AuthorView( { item }: { item: BasePostWithEmbeddedAuthor } ) { const { text, imageUrl } = useSelect( ( select ) => { const { getEntityRecord } = select( coreStore ); diff --git a/packages/fields/src/fields/author/index.tsx b/packages/fields/src/fields/author/index.tsx index 6e5a43d44426d..22f9409e05155 100644 --- a/packages/fields/src/fields/author/index.tsx +++ b/packages/fields/src/fields/author/index.tsx @@ -7,10 +7,10 @@ import { __ } from '@wordpress/i18n'; /** * Internal dependencies */ -import type { BasePost } from '../../types'; +import type { BasePostWithEmbeddedAuthor } from '../../types'; import AuthorView from './author-view'; -const authorField: Field< BasePost > = { +const authorField: Field< BasePostWithEmbeddedAuthor > = { label: __( 'Author' ), id: 'author', type: 'integer', diff --git a/packages/fields/src/types.ts b/packages/fields/src/types.ts index be0391c7c865b..e457ec699554c 100644 --- a/packages/fields/src/types.ts +++ b/packages/fields/src/types.ts @@ -25,10 +25,11 @@ interface Links { interface Author { name: string; + avatar_urls: Record< string, string >; } -interface Embedded { - author?: Author[]; +interface EmbeddedAuthor { + author: Author[]; } export interface BasePost extends CommonPost { @@ -48,7 +49,10 @@ export interface BasePost extends CommonPost { date?: string; modified?: string; author?: number; - _embedded?: Embedded; +} + +export interface BasePostWithEmbeddedAuthor extends BasePost { + _embedded: EmbeddedAuthor; } export interface Template extends CommonPost {