Rm itemType field
This commit is contained in:
parent
46739d116c
commit
1bae261e68
|
@ -67,7 +67,6 @@ export type Contract<T extends AnyContractType = AnyContractType> = {
|
||||||
flaggedByUsernames?: string[]
|
flaggedByUsernames?: string[]
|
||||||
openCommentBounties?: number
|
openCommentBounties?: number
|
||||||
unlistedById?: string
|
unlistedById?: string
|
||||||
itemType: 'contract'
|
|
||||||
} & T
|
} & T
|
||||||
|
|
||||||
export type BinaryContract = Contract & Binary
|
export type BinaryContract = Contract & Binary
|
||||||
|
|
|
@ -78,7 +78,6 @@ export function getNewContract(
|
||||||
liquidityFee: 0,
|
liquidityFee: 0,
|
||||||
platformFee: 0,
|
platformFee: 0,
|
||||||
},
|
},
|
||||||
itemType: 'contract',
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return contract as Contract
|
return contract as Contract
|
||||||
|
|
|
@ -16,8 +16,6 @@ export type Post = {
|
||||||
|
|
||||||
likedByUserIds?: string[]
|
likedByUserIds?: string[]
|
||||||
likedByUserCount?: number
|
likedByUserCount?: number
|
||||||
|
|
||||||
itemType: 'post'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type DateDoc = Post & {
|
export type DateDoc = Post & {
|
||||||
|
|
|
@ -19,7 +19,7 @@ export function ExtraContractActionsRow(props: { contract: Contract }) {
|
||||||
<Row className="gap-1">
|
<Row className="gap-1">
|
||||||
<FollowMarketButton contract={contract} user={user} />
|
<FollowMarketButton contract={contract} user={user} />
|
||||||
|
|
||||||
<LikeItemButton item={contract} user={user} />
|
<LikeItemButton item={contract} user={user} itemType={'contract'} />
|
||||||
|
|
||||||
<Tooltip text="Share" placement="bottom" noTap noFade>
|
<Tooltip text="Share" placement="bottom" noTap noFade>
|
||||||
<IconButton
|
<IconButton
|
||||||
|
|
|
@ -15,8 +15,9 @@ import { Post } from 'common/post'
|
||||||
export function LikeItemButton(props: {
|
export function LikeItemButton(props: {
|
||||||
item: Contract | Post
|
item: Contract | Post
|
||||||
user: User | null | undefined
|
user: User | null | undefined
|
||||||
|
itemType: string
|
||||||
}) {
|
}) {
|
||||||
const { item, user } = props
|
const { item, user, itemType } = props
|
||||||
|
|
||||||
const tips = useItemTipTxns(item.id)
|
const tips = useItemTipTxns(item.id)
|
||||||
|
|
||||||
|
@ -36,7 +37,7 @@ export function LikeItemButton(props: {
|
||||||
if (!user) return firebaseLogin()
|
if (!user) return firebaseLogin()
|
||||||
|
|
||||||
setIsLiking(true)
|
setIsLiking(true)
|
||||||
likeItem(user, item).catch(() => setIsLiking(false))
|
likeItem(user, item, itemType).catch(() => setIsLiking(false))
|
||||||
|
|
||||||
toast(`You tipped ${item.creatorName} ${formatMoney(LIKE_TIP_AMOUNT)}!`)
|
toast(`You tipped ${item.creatorName} ${formatMoney(LIKE_TIP_AMOUNT)}!`)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { useUserLikedContracts } from 'web/hooks/use-likes'
|
||||||
import { SiteLink } from 'web/components/site-link'
|
import { SiteLink } from 'web/components/site-link'
|
||||||
import { Row } from 'web/components/layout/row'
|
import { Row } from 'web/components/layout/row'
|
||||||
import { XIcon } from '@heroicons/react/outline'
|
import { XIcon } from '@heroicons/react/outline'
|
||||||
import { unLikeContract } from 'web/lib/firebase/likes'
|
import { unLikeItem } from 'web/lib/firebase/likes'
|
||||||
import { contractPath } from 'web/lib/firebase/contracts'
|
import { contractPath } from 'web/lib/firebase/contracts'
|
||||||
|
|
||||||
export function UserLikesButton(props: { user: User; className?: string }) {
|
export function UserLikesButton(props: { user: User; className?: string }) {
|
||||||
|
@ -36,7 +36,7 @@ export function UserLikesButton(props: { user: User; className?: string }) {
|
||||||
</SiteLink>
|
</SiteLink>
|
||||||
<XIcon
|
<XIcon
|
||||||
className="ml-2 h-5 w-5 shrink-0 cursor-pointer"
|
className="ml-2 h-5 w-5 shrink-0 cursor-pointer"
|
||||||
onClick={() => unLikeContract(user.id, likedContract.id)}
|
onClick={() => unLikeItem(user.id, likedContract.id)}
|
||||||
/>
|
/>
|
||||||
</Row>
|
</Row>
|
||||||
))}
|
))}
|
||||||
|
|
|
@ -18,7 +18,11 @@ export const unLikeItem = async (userId: string, itemId: string) => {
|
||||||
return await deleteDoc(ref)
|
return await deleteDoc(ref)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const likeItem = async (user: User, item: Contract | Post) => {
|
export const likeItem = async (
|
||||||
|
user: User,
|
||||||
|
item: Contract | Post,
|
||||||
|
itemType: string
|
||||||
|
) => {
|
||||||
if (user.balance < LIKE_TIP_AMOUNT) {
|
if (user.balance < LIKE_TIP_AMOUNT) {
|
||||||
toast('You do not have enough M$ to like this market!')
|
toast('You do not have enough M$ to like this market!')
|
||||||
return
|
return
|
||||||
|
@ -34,7 +38,7 @@ export const likeItem = async (user: User, item: Contract | Post) => {
|
||||||
token: 'M$',
|
token: 'M$',
|
||||||
category: 'TIP',
|
category: 'TIP',
|
||||||
data: { contractId: item.id },
|
data: { contractId: item.id },
|
||||||
description: `${user.name} liked ${item.itemType} ${item.id} for M$ ${LIKE_TIP_AMOUNT} to ${item.creatorId} `,
|
description: `${user.name} liked ${itemType}${item.id} for M$ ${LIKE_TIP_AMOUNT} to ${item.creatorId} `,
|
||||||
})
|
})
|
||||||
console.log('result', result)
|
console.log('result', result)
|
||||||
}
|
}
|
||||||
|
@ -45,7 +49,7 @@ export const likeItem = async (user: User, item: Contract | Post) => {
|
||||||
id: ref.id,
|
id: ref.id,
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
createdTime: Date.now(),
|
createdTime: Date.now(),
|
||||||
type: item.itemType,
|
type: itemType,
|
||||||
tipTxnId: result.txn.id,
|
tipTxnId: result.txn.id,
|
||||||
} as Like)
|
} as Like)
|
||||||
track('like', {
|
track('like', {
|
||||||
|
|
|
@ -94,7 +94,7 @@ export default function PostPage(props: {
|
||||||
</div>
|
</div>
|
||||||
</Col>
|
</Col>
|
||||||
<Row className="items-center">
|
<Row className="items-center">
|
||||||
<LikeItemButton item={post} user={user} />
|
<LikeItemButton item={post} user={user} itemType={'post'} />
|
||||||
|
|
||||||
<Col className="px-2">
|
<Col className="px-2">
|
||||||
<Button
|
<Button
|
||||||
|
|
Loading…
Reference in New Issue
Block a user