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 ( <>
remote} name='remote' hiddenLabel groupClassName={styles.inlineCheckGroup} /> how to apply url or email address} name='url' required clear /> boost
  1. Boost ranks jobs higher based on the amount
  2. The minimum boost is {numWithUnits(BOOST_MIN, { abbreviate: false })}
  3. Boost must be divisible by {numWithUnits(BOOST_MULT, { abbreviate: false })}
  4. 100% of boost goes to the territory founder and top stackers as rewards
} hint={{data?.auctionPosition ? `your job will rank ${giveOrdinalSuffix(data.auctionPosition)}` : 'higher boost ranks your job higher'}} onChange={(_, e) => getPositionDebounce({ variables: { boost: Number(e.target.value), id: item?.id } })} /> ) } export function JobButtonBar ({ itemId, disable, className, children, handleStop, onCancel, hasCancel = true, createText = 'post', editText = 'save', stopText = 'remove' }) { return (
{itemId && {stopText}} {children}
{hasCancel && }
) }