()
| 15 | } |
| 16 | |
| 17 | render() { |
| 18 | const queryClient = useQueryClient() |
| 19 | const { isPending, isError, isFetching, data, error } = this.posts() |
| 20 | |
| 21 | return html` |
| 22 | <div> |
| 23 | <h1>Posts</h1> |
| 24 | <div> |
| 25 | ${ |
| 26 | isPending |
| 27 | ? html`<div>Loading...</div>` |
| 28 | : isError |
| 29 | ? html`<span>Error: ${error.message}</span>` |
| 30 | : html` |
| 31 | <div> |
| 32 | ${data.map( |
| 33 | (post) => html` |
| 34 | <p> |
| 35 | <a |
| 36 | href="#${post.id}" |
| 37 | style=${styleMap( |
| 38 | queryClient.getQueryData( |
| 39 | postsQueries.detail(post.id).queryKey, |
| 40 | ) |
| 41 | ? { fontWeight: 'bold', color: 'green' } |
| 42 | : {}, |
| 43 | )} |
| 44 | @click=${(event: Event) => { |
| 45 | event.preventDefault() |
| 46 | this.setPostId(post.id) |
| 47 | }} |
| 48 | > |
| 49 | ${post.title} |
| 50 | </a> |
| 51 | </p> |
| 52 | `, |
| 53 | )} |
| 54 | </div> |
| 55 | <div>${isFetching ? 'Background Updating...' : ' '}</div> |
| 56 | ` |
| 57 | } |
| 58 | </div> |
| 59 | </div> |
| 60 | ` |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | customElements.define('post-list', PostList) |
nothing calls this directly
no test coverage detected