Figuring out paid publish flow

This commit is contained in:
austinkelsay 2024-08-02 13:51:55 -05:00
parent 0f946bf821
commit 2e415a2524
2 changed files with 8 additions and 4 deletions

View File

@ -65,7 +65,9 @@ export default function Details() {
const { slug } = router.query; const { slug } = router.query;
const fetchEvent = async (slug) => { const fetchEvent = async (slug) => {
console.log('slug:', slug);
const event = await fetchSingleEvent(slug); const event = await fetchSingleEvent(slug);
console.log('event:', event);
if (event) { if (event) {
setEvent(event); setEvent(event);
} }
@ -181,7 +183,7 @@ export default function Details() {
</div> </div>
) : ( ) : (
<div className="w-full flex justify-end"> <div className="w-full flex justify-end">
<ZapDisplay zapAmount={zapAmount} event={parseEvent(event)} /> <ZapDisplay zapAmount={zapAmount} event={processedEvent} />
</div> </div>
)} )}
</div> </div>

View File

@ -57,6 +57,7 @@ export default function Details() {
if (unsignedEvent) { if (unsignedEvent) {
const published = await publishEvent(unsignedEvent, type); const published = await publishEvent(unsignedEvent, type);
console.log('published:', published);
// if successful, delete the draft, redirect to profile // if successful, delete the draft, redirect to profile
if (published) { if (published) {
axios.delete(`/api/drafts/${draft.id}`) axios.delete(`/api/drafts/${draft.id}`)
@ -113,8 +114,6 @@ export default function Details() {
identifier: dTag, identifier: dTag,
}) })
console.log('nAddress:', nAddress);
const userResponse = await axios.get(`/api/users/${user.pubkey}`) const userResponse = await axios.get(`/api/users/${user.pubkey}`)
if (!userResponse.data) { if (!userResponse.data) {
@ -128,7 +127,9 @@ export default function Details() {
price: draft.price || 0, price: draft.price || 0,
noteId: nAddress, noteId: nAddress,
} }
console.log('payload:', payload);
const response = await axios.post(`/api/resources`, payload); const response = await axios.post(`/api/resources`, payload);
console.log('response:', response);
if (response.status !== 201) { if (response.status !== 201) {
showToast('error', 'Error', 'Failed to create resource. Please try again.'); showToast('error', 'Error', 'Failed to create resource. Please try again.');
@ -136,6 +137,7 @@ export default function Details() {
} }
let published; let published;
console.log('type:', type);
if (type === 'resource' || type === 'workshop') { if (type === 'resource' || type === 'workshop') {
published = await publishResource(signedEvent); published = await publishResource(signedEvent);
@ -266,7 +268,7 @@ export default function Details() {
<div className='flex flex-row w-full mt-6 items-center'> <div className='flex flex-row w-full mt-6 items-center'>
<Image <Image
alt="resource thumbnail" alt="resource thumbnail"
src={returnImageProxy(draft.author?.avatar, draft.author?.pubkey)} src={returnImageProxy(draft?.author?.avatar, draft?.author?.pubkey)}
width={50} width={50}
height={50} height={50}
className="rounded-full mr-4" className="rounded-full mr-4"