import { type ReactElement, useId } from 'react' import { useListChoices } from '../posts/use-list-choices' import type { DeckColumn } from './model' type Source = Extract type EditorProps = { source: T onChange: (source: Source) => void } export function defaultTwitterSource(kind: Source['kind'] = 'search'): Source { switch (kind) { case 'search': return { platform: 'twitter', kind, query: '', product: 'Latest', following: false, } case 'user': return { platform: 'twitter', kind, target: '' } case 'list': return { platform: 'twitter', kind, target: '' } } } export function TwitterSourceEditor({ source, connectionId, onChange, }: EditorProps & { connectionId: string }) { const id = useId() return ( <> ) } function TwitterSourceFields({ source, connectionId, onChange, }: EditorProps & { connectionId: string }): ReactElement { switch (source.kind) { case 'search': return case 'user': return case 'list': return ( ) } } function TwitterSearchEditor({ source, onChange, }: EditorProps>) { const id = useId() return (

from:、lang:、since: など、Twitterの検索構文を使えます。

) } function TwitterUserEditor({ source, onChange, }: EditorProps>) { const id = useId() return (
) } function TwitterListEditor({ source, connectionId, onChange, }: EditorProps> & { connectionId: string }) { const id = useId() return (
{connectionId && ( onChange({ ...source, target })} /> )}
) } function TwitterListChoices({ connectionId, onSelect, }: { connectionId: string onSelect: (target: string) => void }) { const lists = useListChoices(connectionId) if (lists.isPending) return

リストを取得しています…

if (lists.isError) return (

リストを取得できませんでした。

) return (
{lists.data.length === 0 ? (

リストはありません。URLまたはIDでも指定できます。

) : ( lists.data.map((list) => ( )) )}
) }