feat: ship creator journey v2 and profile updates
This commit is contained in:
@@ -34,12 +34,21 @@ export default function ArtworkShareButton({ artwork, shareUrl, size = 'default'
|
||||
|
||||
const { share } = useWebShare({ onFallback: openModal })
|
||||
|
||||
const handleClick = () => {
|
||||
share({
|
||||
const handleClick = async () => {
|
||||
const result = await share({
|
||||
title: artwork?.title || 'Artwork',
|
||||
text: artwork?.description?.substring(0, 120) || '',
|
||||
url: shareUrl || artwork?.canonical_url || window.location.href,
|
||||
})
|
||||
if (result?.shared && result?.native && artwork?.id) {
|
||||
const csrfToken = document.head.querySelector('meta[name="csrf-token"]')?.content
|
||||
fetch(`/api/artworks/${artwork.id}/share`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-TOKEN': csrfToken || '' },
|
||||
credentials: 'same-origin',
|
||||
body: JSON.stringify({ platform: 'native' }),
|
||||
}).catch(() => {})
|
||||
}
|
||||
}
|
||||
|
||||
const isSmall = size === 'small'
|
||||
|
||||
Reference in New Issue
Block a user