import { useRouter } from 'next/router' import { Select } from './form' import Info from './info' export function SubSelectInitial ({ sub }) { const router = useRouter() sub = sub || router.query.sub || 'pick sub' return { sub } } export default function SubSelect ({ label, sub, setSub, item, ...props }) { const router = useRouter() const SubInfo = () => ( The sub your post will go in ... If it's bitcoin related, put it in the bitcoin sub. If it's nostr related, put it in the nostr sub. If it's tech related, put it in the tech sub. If it's a job, put it in the jobs sub. ) return ( { if (!item) { router.push({ pathname: e.target.value === 'pick sub' ? '/post' : `/~${e.target.value}/post`, query: router.query?.type ? { type: router.query.type } : undefined }) } else { setSub(e.target.value) } }} name='sub' size='sm' defaultValue={props.noForm ? sub : undefined} items={props.noForm ? ['pick sub', 'bitcoin', 'nostr', 'tech', 'jobs'] : item ? ['bitcoin', 'nostr', 'tech'] : ['pick sub', 'bitcoin', 'nostr', 'tech']} label={label && <> {label} >} {...props} /> ) }