import { DateTimeInput, Form, Input, MarkdownInput, VariableInput } from '@/components/form' import { useApolloClient } from '@apollo/client' import Countdown from './countdown' import AdvPostForm, { AdvPostInitial } from './adv-post-form' import { MAX_POLL_CHOICE_LENGTH, MAX_POLL_NUM_CHOICES, MAX_TITLE_LENGTH } from '@/lib/constants' import { datePivot } from '@/lib/time' import { pollSchema } from '@/lib/validate' import { SubSelectInitial } from './sub-select' import { normalizeForwards } from '@/lib/form' import { useMe } from './me' import { ItemButtonBar } from './post' import { UPSERT_POLL } from '@/fragments/paidAction' import useItemSubmit from './use-item-submit' export function PollForm ({ item, sub, editThreshold, children }) { const client = useApolloClient() const me = useMe() const schema = pollSchema({ client, me, existingBoost: item?.boost }) const onSubmit = useItemSubmit(UPSERT_POLL, { item, sub }) const initialOptions = item?.poll?.options.map(i => i.option) const storageKeyPrefix = item ? undefined : 'poll' return (
{children} text optional} name='text' minRows={2} /> : null} maxLength={MAX_POLL_CHOICE_LENGTH} /> ) }