* add poll expires at column to Item table * update upsertPoll mutation for pollExpiresAt param * use pollExpiresAt to show time left for poll * correctly pluralize days for timeLeft * correctly update pollExpiresAt when item is updated to remove poll expiration * add DateTimePicker and DateTimeInput components to select datetimes * update pollExpiresAt to be nullable and more than 1 day in the future * hide time left text if poll has no expiration * initialize pollExpiresAt with current value or default of 25 hours in the future we add a one hour time buffer so that the user doesn't get a validation error for pollExpiresAt if they post their poll within an hour from creation. there's still a chance they'll hit the validation error but they should see the error message toast * add DateTimeInput into the options part of the poll form add right padding to make room for the "clear" button. allow field to be cleared (i.e. null pollExpiresAt) to allow non-ending polls. --------- Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
182 lines
2.7 KiB
JavaScript
182 lines
2.7 KiB
JavaScript
import { gql } from '@apollo/client'
|
|
import { COMMENTS } from './comments'
|
|
|
|
export const ITEM_FIELDS = gql`
|
|
fragment ItemFields on Item {
|
|
id
|
|
parentId
|
|
createdAt
|
|
deletedAt
|
|
title
|
|
url
|
|
user {
|
|
id
|
|
name
|
|
optional {
|
|
streak
|
|
}
|
|
meMute
|
|
}
|
|
sub {
|
|
name
|
|
userId
|
|
moderated
|
|
meMuteSub
|
|
nsfw
|
|
}
|
|
otsHash
|
|
position
|
|
sats
|
|
meAnonSats @client
|
|
boost
|
|
bounty
|
|
bountyPaidTo
|
|
noteId
|
|
path
|
|
upvotes
|
|
meSats
|
|
meDontLikeSats
|
|
meBookmark
|
|
meSubscription
|
|
meForward
|
|
outlawed
|
|
freebie
|
|
bio
|
|
ncomments
|
|
commentSats
|
|
lastCommentAt
|
|
maxBid
|
|
isJob
|
|
company
|
|
location
|
|
remote
|
|
subName
|
|
pollCost
|
|
pollExpiresAt
|
|
status
|
|
uploadId
|
|
mine
|
|
imgproxyUrls
|
|
}`
|
|
|
|
export const ITEM_FULL_FIELDS = gql`
|
|
${ITEM_FIELDS}
|
|
fragment ItemFullFields on Item {
|
|
...ItemFields
|
|
text
|
|
root {
|
|
id
|
|
title
|
|
bounty
|
|
bountyPaidTo
|
|
subName
|
|
user {
|
|
id
|
|
name
|
|
optional {
|
|
streak
|
|
}
|
|
}
|
|
sub {
|
|
name
|
|
userId
|
|
moderated
|
|
meMuteSub
|
|
}
|
|
}
|
|
forwards {
|
|
userId
|
|
pct
|
|
user {
|
|
name
|
|
}
|
|
}
|
|
}`
|
|
|
|
export const ITEM_OTS_FIELDS = gql`
|
|
fragment ItemOtsFields on Item {
|
|
id
|
|
title
|
|
text
|
|
url
|
|
parentOtsHash
|
|
otsHash
|
|
deletedAt
|
|
}`
|
|
|
|
export const ITEM_OTS = gql`
|
|
${ITEM_OTS_FIELDS}
|
|
|
|
query Item($id: ID!) {
|
|
item(id: $id) {
|
|
...ItemOtsFields
|
|
}
|
|
}`
|
|
|
|
export const POLL_FIELDS = gql`
|
|
fragment PollFields on Item {
|
|
poll {
|
|
meVoted
|
|
count
|
|
options {
|
|
id
|
|
option
|
|
count
|
|
meVoted
|
|
}
|
|
}
|
|
}`
|
|
|
|
export const ITEM = gql`
|
|
${ITEM_FULL_FIELDS}
|
|
${POLL_FIELDS}
|
|
|
|
query Item($id: ID!) {
|
|
item(id: $id) {
|
|
...ItemFullFields
|
|
...PollFields
|
|
}
|
|
}`
|
|
|
|
export const ITEM_FULL = gql`
|
|
${ITEM_FULL_FIELDS}
|
|
${POLL_FIELDS}
|
|
${COMMENTS}
|
|
query Item($id: ID!, $sort: String) {
|
|
item(id: $id) {
|
|
...ItemFullFields
|
|
prior
|
|
...PollFields
|
|
comments(sort: $sort) {
|
|
...CommentsRecursive
|
|
}
|
|
}
|
|
}`
|
|
|
|
export const RELATED_ITEMS = gql`
|
|
${ITEM_FIELDS}
|
|
query Related($title: String, $id: ID, $cursor: String, $limit: Limit) {
|
|
related(title: $title, id: $id, cursor: $cursor, limit: $limit) {
|
|
cursor
|
|
items {
|
|
...ItemFields
|
|
}
|
|
}
|
|
}
|
|
`
|
|
|
|
export const RELATED_ITEMS_WITH_ITEM = gql`
|
|
${ITEM_FIELDS}
|
|
query Related($title: String, $id: ID!, $cursor: String, $limit: Limit) {
|
|
item(id: $id) {
|
|
...ItemFields
|
|
}
|
|
related(title: $title, id: $id, cursor: $cursor, limit: $limit) {
|
|
cursor
|
|
items {
|
|
...ItemFields
|
|
}
|
|
}
|
|
}
|
|
`
|