diff --git a/api/resolvers/item.js b/api/resolvers/item.js
index e7e958c0..ec2acd7b 100644
--- a/api/resolvers/item.js
+++ b/api/resolvers/item.js
@@ -492,34 +492,27 @@ export default {
return await updateItem(parent, { id, data: { title, text } }, { me, models })
},
- upsertJob: async (parent, { id, sub, title, text, url, maxBid, status }, { me, models }) => {
+ upsertJob: async (parent, { id, sub, title, company, location, remote, text, url, maxBid, status }, { me, models }) => {
if (!me) {
throw new AuthenticationError('you must be logged in to create job')
}
- if (!sub) {
- throw new UserInputError('jobs must have a sub', { argumentName: 'sub' })
- }
-
const fullSub = await models.sub.findUnique({ where: { name: sub } })
if (!fullSub) {
throw new UserInputError('not a valid sub', { argumentName: 'sub' })
}
- const params = { title, text, url }
- for (const param in params) {
- if (!params[param]) {
- throw new UserInputError(`jobs must have ${param}`, { argumentName: param })
- }
- }
-
if (fullSub.baseCost > maxBid) {
throw new UserInputError(`bid must be at least ${fullSub.baseCost}`, { argumentName: 'maxBid' })
}
+ if (!location && !remote) {
+ throw new UserInputError('must specify location or remote', { argumentName: 'location' })
+ }
+
const checkSats = async () => {
// check if the user has the funds to run for the first minute
- const minuteMsats = maxBid * 5 / 216
+ const minuteMsats = maxBid * 1000
const user = await models.user.findUnique({ where: { id: me.id } })
if (user.msats < minuteMsats) {
throw new UserInputError('insufficient funds')
@@ -528,6 +521,9 @@ export default {
const data = {
title,
+ company,
+ location: location.toLowerCase() === 'remote' ? undefined : location,
+ remote,
text,
url,
maxBid,
@@ -878,6 +874,7 @@ function nestComments (flat, parentId) {
export const SELECT =
`SELECT "Item".id, "Item".created_at as "createdAt", "Item".updated_at as "updatedAt", "Item".title,
"Item".text, "Item".url, "Item"."userId", "Item"."parentId", "Item"."pinId", "Item"."maxBid",
+ "Item".company, "Item".location, "Item".remote,
"Item"."subName", "Item".status, ltree2text("Item"."path") AS "path"`
const LEFT_JOIN_SATS_SELECT = 'SELECT i.id, SUM(CASE WHEN "ItemAct".act = \'VOTE\' THEN "ItemAct".sats ELSE 0 END) as sats, SUM(CASE WHEN "ItemAct".act = \'BOOST\' THEN "ItemAct".sats ELSE 0 END) as boost'
diff --git a/api/typeDefs/item.js b/api/typeDefs/item.js
index da5b15bc..edc5d40f 100644
--- a/api/typeDefs/item.js
+++ b/api/typeDefs/item.js
@@ -25,7 +25,7 @@ export default gql`
updateDiscussion(id: ID!, title: String!, text: String): Item!
createComment(text: String!, parentId: ID!): Item!
updateComment(id: ID!, text: String!): Item!
- upsertJob(id: ID, sub: ID!, title: String!, text: String!, url: String!, maxBid: Int!, status: String): Item!
+ upsertJob(id: ID, sub: ID!, title: String!, company: String!, location: String, remote: Boolean, text: String!, url: String!, maxBid: Int!, status: String): Item!
act(id: ID!, sats: Int): ItemActResult!
}
@@ -66,6 +66,9 @@ export default gql`
position: Int
prior: Int
maxBid: Int
+ company: String
+ location: String
+ remote: Boolean
sub: Sub
status: String
}
diff --git a/components/form.js b/components/form.js
index fbc01af2..442cf63f 100644
--- a/components/form.js
+++ b/components/form.js
@@ -201,31 +201,34 @@ export function Input ({ label, groupClassName, ...props }) {
)
}
-export function Checkbox ({ children, label, extra, handleChange, inline, ...props }) {
+export function Checkbox ({ children, label, groupClassName, hiddenLabel, extra, handleChange, inline, ...props }) {
// React treats radios and checkbox inputs differently other input types, select, and textarea.
// Formik does this too! When you specify `type` to useField(), it will
// return the correct bag of props for you
const [field] = useField({ ...props, type: 'checkbox' })
return (
-