WIP forward

This commit is contained in:
keyan 2022-04-18 15:19:07 -05:00
parent ae916ecb97
commit 2b594109ea
6 changed files with 39 additions and 25 deletions

View File

@ -19,10 +19,7 @@ export default gql`
}
extend type Mutation {
createLink(title: String!, url: String, boost: Int): Item!
updateLink(id: ID!, title: String!, url: String): Item!
createDiscussion(title: String!, text: String, boost: Int): Item!
updateDiscussion(id: ID!, title: String!, text: String): Item!
upsertStory(title: String!, text: String, url: String, boost: Int): Item!
createComment(text: String!, parentId: ID!): Item!
updateComment(id: ID!, text: String!): Item!
upsertJob(id: ID, sub: ID!, title: String!, company: String!, location: String, remote: Boolean, text: String!, url: String!, maxBid: Int!, status: String): Item!

View File

@ -6,11 +6,13 @@ import { BOOST_MIN } from '../lib/constants'
export const AdvPostSchema = {
boost: Yup.number().typeError('must be a number')
.min(BOOST_MIN, `must be at least ${BOOST_MIN}`).integer('must be whole')
.min(BOOST_MIN, `must be at least ${BOOST_MIN}`).integer('must be whole'),
forward: Yup.string().required('required').trim()
}
export const AdvPostInitial = {
boost: ''
boost: '',
forward: ''
}
export default function AdvPostForm () {
@ -18,12 +20,20 @@ export default function AdvPostForm () {
<AccordianItem
header={<div style={{ fontWeight: 'bold', fontSize: '92%' }}>options</div>}
body={
<Input
label='boost'
name='boost'
hint={<span className='text-muted'>ranks posts higher temporarily based on the amount</span>}
append={<InputGroup.Text className='text-monospace'>sats</InputGroup.Text>}
/>
<>
<Input
label='boost'
name='boost'
hint={<span className='text-muted'>ranks posts higher temporarily based on the amount</span>}
append={<InputGroup.Text className='text-monospace'>sats</InputGroup.Text>}
/>
<Input
label='forward sats to'
name='forward'
hint={<span className='text-muted'>100% of sats earned will be sent to this user</span>}
prepend=<InputGroup.Text>@</InputGroup.Text>
/>
</>
}
/>
)

View File

@ -20,16 +20,16 @@ export function DiscussionForm ({
const router = useRouter()
const [createDiscussion] = useMutation(
gql`
mutation createDiscussion($title: String!, $text: String, $boost: Int) {
createDiscussion(title: $title, text: $text, boost: $boost) {
mutation createDiscussion($title: String!, $text: String, $boost: Int, $forward: String) {
createDiscussion(title: $title, text: $text, boost: $boost, forward: $forward) {
id
}
}`
)
const [updateDiscussion] = useMutation(
gql`
mutation updateDiscussion($id: ID!, $title: String!, $text: String!) {
updateDiscussion(id: $id, title: $title, text: $text) {
mutation updateDiscussion($id: ID!, $title: String!, $text: String!, $forward: String) {
updateDiscussion(id: $id, title: $title, text: $text, forward: $forward) {
id
}
}`, {

View File

@ -38,8 +38,8 @@ export function LinkForm ({ item, editThreshold }) {
const [createLink] = useMutation(
gql`
mutation createLink($title: String!, $url: String!, $boost: Int) {
createLink(title: $title, url: $url, boost: $boost) {
mutation createLink($title: String!, $url: String!, $boost: Int, $forward: String) {
createLink(title: $title, url: $url, boost: $boost, forward: $forward) {
id
}
}`
@ -47,8 +47,8 @@ export function LinkForm ({ item, editThreshold }) {
const [updateLink] = useMutation(
gql`
mutation updateLink($id: ID!, $title: String!, $url: String!) {
updateLink(id: $id, title: $title, url: $url) {
mutation updateLink($id: ID!, $title: String!, $url: String!, $forward: String) {
updateLink(id: $id, title: $title, url: $url, forward: $forward) {
id
title
url

View File

@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "Item" ADD COLUMN "fwdUserId" INTEGER;
-- AddForeignKey
ALTER TABLE "Item" ADD FOREIGN KEY ("fwdUserId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View File

@ -18,7 +18,8 @@ model User {
email String? @unique
emailVerified DateTime? @map(name: "email_verified")
image String?
items Item[]
items Item[] @relation("UserItems")
fwdItems Item[] @relation("FwdItem")
mentions Mention[]
messages Message[]
actions ItemAct[]
@ -27,7 +28,7 @@ model User {
invites Invite[] @relation(name: "Invites")
invite Invite? @relation(fields: [inviteId], references: [id])
inviteId String?
bio Item? @relation(name: "Item", fields: [bioId], references: [id])
bio Item? @relation(fields: [bioId], references: [id])
bioId Int?
msats Int @default(0)
stackedMsats Int @default(0)
@ -113,8 +114,10 @@ model Item {
title String?
text String?
url String?
user User @relation(fields: [userId], references: [id])
user User @relation("UserItems", fields: [userId], references: [id])
userId Int
fwdUser User? @relation(name: "FwdItem", fields: [fwdUserId], references: [id])
fwdUserId Int?
parent Item? @relation("ParentChildren", fields: [parentId], references: [id])
parentId Int?
children Item[] @relation("ParentChildren")
@ -140,8 +143,7 @@ model Item {
longitude Float?
remote Boolean?
User User[] @relation("Item")
User User[]
@@index([createdAt])
@@index([userId])
@@index([parentId])