import { Checkbox, Form, Input, MarkdownInput, SubmitButton } from './form' import Row from 'react-bootstrap/Row' import Col from 'react-bootstrap/Col' import Image from 'react-bootstrap/Image' import { useEffect, useState } from 'react' import Info from './info' import styles from '@/styles/post.module.css' import { useLazyQuery, gql } from '@apollo/client' import Avatar from './avatar' import { jobSchema } from '@/lib/validate' import { BOOST_MIN, BOOST_MULT, MAX_TITLE_LENGTH, MEDIA_URL } from '@/lib/constants' import { UPSERT_JOB } from '@/fragments/paidAction' import useItemSubmit from './use-item-submit' import { BoostInput } from './adv-post-form' import { numWithUnits, giveOrdinalSuffix } from '@/lib/format' import useDebounceCallback from './use-debounce-callback' import FeeButton from './fee-button' import CancelButton from './cancel-button' // need to recent list items export default function JobForm ({ item, sub }) { const storageKeyPrefix = item ? undefined : `${sub.name}-job` const [logoId, setLogoId] = useState(item?.uploadId) const [getAuctionPosition, { data }] = useLazyQuery(gql` query AuctionPosition($id: ID, $boost: Int) { auctionPosition(sub: "${item?.subName || sub?.name}", id: $id, boost: $boost) }`, { fetchPolicy: 'cache-and-network' }) const getPositionDebounce = useDebounceCallback((...args) => getAuctionPosition(...args), 1000, [getAuctionPosition]) useEffect(() => { if (item?.boost) { getPositionDebounce({ variables: { boost: item.boost, id: item.id } }) } }, [item?.boost]) const extraValues = logoId ? { logo: Number(logoId) } : {} const onSubmit = useItemSubmit(UPSERT_JOB, { item, sub, extraValues }) return ( <>
> ) } export function JobButtonBar ({ itemId, disable, className, children, handleStop, onCancel, hasCancel = true, createText = 'post', editText = 'save', stopText = 'remove' }) { return (