Skip to content

Commit

Permalink
feat: add shop button to collect on the secondary marketplace (#318)
Browse files Browse the repository at this point in the history
* Added shop collects button

* Added shop collects button

* Added LensPort marketplace link. Hides shop button when no collects. Reformatting pubId to be cleaner

* Update index.tsx

Remove extra comma
  • Loading branch information
ahomentc authored and sasicodes committed Nov 12, 2022
1 parent bd8486c commit 23eb1ff
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/Watch/CollectVideo/CollectModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ type Props = {
fetchingCollectModule: boolean
collectModule: LenstubeCollectModule
collectNow: () => void
shopCollects: () => void
}

const CollectModal: FC<Props> = ({
showModal,
setShowModal,
video,
collectNow,
shopCollects,
collecting,
collectModule,
fetchingCollectModule
Expand Down Expand Up @@ -176,7 +178,7 @@ const CollectModal: FC<Props> = ({
<span className="text-lg">{collectModule.referralFee} %</span>
</div>
) : null}
<div className="flex justify-end">
<div className="flex justify-end space-x-2">
{isAllowed ? (
collectModule?.followerOnly && !video.profile.isFollowedByMe ? (
<div className="flex-1">
Expand Down Expand Up @@ -208,6 +210,9 @@ const CollectModal: FC<Props> = ({
}
/>
)}
{video?.stats.totalAmountOfCollects > 0 ? (
<Button onClick={() => shopCollects()}>Shop Collects</Button>
) : null}
</div>
</>
) : (
Expand Down
14 changes: 14 additions & 0 deletions src/components/Watch/CollectVideo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Analytics, TRACK } from '@utils/analytics'
import {
ERROR_MESSAGE,
LENSHUB_PROXY_ADDRESS,
LENSPORT_MARKETPLACE_URL,
RELAYER_ENABLED,
SIGN_IN_REQUIRED_MESSAGE
} from '@utils/constants'
Expand Down Expand Up @@ -157,6 +158,18 @@ const CollectVideo: FC<Props> = ({ video, variant = 'primary' }) => {
})
}

const shopCollects = () => {
if (!video) {
return
}
const pubId = video.id ?? video.mirrorOf?.id
const decimalProfileId = parseInt(pubId.split('-')[0], 16)
const decimalPubId = parseInt(pubId.split('-')[1], 16)
const marketplacePublicationId = decimalProfileId + '_' + decimalPubId
const marketplaceUrl = `${LENSPORT_MARKETPLACE_URL}/p/${marketplacePublicationId}`
window.open(marketplaceUrl)
}

const onClickCollect = () => {
if (!selectedChannelId) return toast.error(SIGN_IN_REQUIRED_MESSAGE)
return setShowCollectModal(true)
Expand All @@ -182,6 +195,7 @@ const CollectVideo: FC<Props> = ({ video, variant = 'primary' }) => {
showModal={showCollectModal}
setShowModal={setShowCollectModal}
collectNow={collectNow}
shopCollects={shopCollects}
collecting={loading}
collectModule={collectModule}
fetchingCollectModule={fetchingCollectModule}
Expand Down
1 change: 1 addition & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export const OPENSEA_MARKETPLACE_URL = IS_MAINNET
export const RARIBLE_MARKETPLACE_URL = IS_MAINNET
? 'https://rarible.com'
: 'https://testnet.rarible.com'
export const LENSPORT_MARKETPLACE_URL = 'https://lensport.io'

// misc
export const GIT_DEPLOYED_COMMIT_SHA =
Expand Down

0 comments on commit 23eb1ff

Please sign in to comment.