-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/bounty paid state #819
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8f86eda
update: when marked as paid bounty updates immediately
tobi-bams 64f5016
update: made mark unpaid update immediately
tobi-bams 79d2cb6
update: ensured bounty paid can be toggled properly between paid and …
tobi-bams 56c0348
update: get update bounty with right status when the ticket page is c…
tobi-bams 974d80f
update: make bounty ticket display in person profile same with bounty…
tobi-bams 8dd479e
update: fix prettier error and return defaults
tobi-bams 47d513c
Merge branch 'master' into fix/bounty-paid-state
tobi-bams 22cc79f
format: run prettier
tobi-bams c13a471
refactor: moved functions away from the onclick function
tobi-bams 4a1736f
fix: run prettier for formatting
tobi-bams File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,7 +91,9 @@ function MobileView(props: CodingBountiesProps) { | |
bounty_expires, | ||
commitment_fee, | ||
org_uuid, | ||
id | ||
id, | ||
localPaid, | ||
setLocalPaid | ||
} = props; | ||
const color = colors['light']; | ||
|
||
|
@@ -100,8 +102,18 @@ function MobileView(props: CodingBountiesProps) { | |
const [keysendStatus, setKeysendStatus] = useState(false); | ||
const [lnInvoice, setLnInvoice] = useState(''); | ||
const [toasts, setToasts]: any = useState([]); | ||
const [updatingPayment, setUpdatingPayment] = useState<boolean>(false); | ||
|
||
let bountyPaid = paid || invoiceStatus || keysendStatus; | ||
|
||
if (localPaid === 'PAID') { | ||
bountyPaid = true; | ||
} | ||
|
||
if (localPaid === 'UNPAID') { | ||
Comment on lines
+111
to
+113
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not do else if here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmmm, that's true. I can't remember why I did it that way. But will push an update with my next PR. Thanks |
||
bountyPaid = false; | ||
} | ||
|
||
const bountyPaid = paid || invoiceStatus || keysendStatus; | ||
const pollMinutes = 1; | ||
|
||
const bountyExpired = !bounty_expires | ||
|
@@ -214,10 +226,12 @@ function MobileView(props: CodingBountiesProps) { | |
} else if (res.msg === SOCKET_MSG.invoice_success && res.invoice === main.lnInvoice) { | ||
addToast(SOCKET_MSG.invoice_success); | ||
setLnInvoice(''); | ||
setLocalPaid('UNKNOWN'); | ||
setInvoiceStatus(true); | ||
} else if (res.msg === SOCKET_MSG.keysend_success && res.invoice === main.lnInvoice) { | ||
addToast(SOCKET_MSG.keysend_success); | ||
if (org_uuid) { | ||
setLocalPaid('UNKNOWN'); | ||
setKeysendStatus(true); | ||
} | ||
} else if (res.msg === SOCKET_MSG.keysend_error && res.invoice === main.lnInvoice) { | ||
|
@@ -230,6 +244,32 @@ function MobileView(props: CodingBountiesProps) { | |
await main.getPeopleBounties(); | ||
}; | ||
|
||
const handleSetAsPaid = async (e: any) => { | ||
e.stopPropagation(); | ||
setUpdatingPayment(true); | ||
await updatePaymentStatus(created || 0); | ||
await setExtrasPropertyAndSaveMultiple('paid', { | ||
award: awardDetails.name | ||
}); | ||
|
||
setTimeout(() => { | ||
setCreatorStep(0); | ||
if (setIsPaidStatusPopOver) setIsPaidStatusPopOver(true); | ||
if (awardDetails?.name !== '') { | ||
setIsPaidStatusBadgeInfo(true); | ||
} | ||
setUpdatingPayment(false); | ||
}, 3000); | ||
}; | ||
|
||
const handleSetAsUnpaid = async (e: any) => { | ||
e.stopPropagation(); | ||
setUpdatingPayment(true); | ||
await updatePaymentStatus(created || 0); | ||
setLocalPaid('UNPAID'); | ||
setUpdatingPayment(false); | ||
}; | ||
|
||
useEffect(() => { | ||
const socket: WebSocket = createSocketInstance(); | ||
|
||
|
@@ -595,7 +635,7 @@ function MobileView(props: CodingBountiesProps) { | |
color: color.borderGreen1 | ||
}} | ||
text={'Mark Unpaid'} | ||
loading={saving === 'paid'} | ||
loading={saving === 'paid' || updatingPayment} | ||
endingImg={'/static/mark_unpaid.svg'} | ||
textStyle={{ | ||
width: '130px', | ||
|
@@ -604,10 +644,7 @@ function MobileView(props: CodingBountiesProps) { | |
fontFamily: 'Barlow', | ||
marginLeft: '30px' | ||
}} | ||
onClick={(e: any) => { | ||
e.stopPropagation(); | ||
updatePaymentStatus(created || 0); | ||
}} | ||
onClick={handleSetAsUnpaid} | ||
/> | ||
) : ( | ||
<IconButton | ||
|
@@ -802,7 +839,7 @@ function MobileView(props: CodingBountiesProps) { | |
marginLeft: '36px' | ||
}} | ||
text={selectedAward === '' ? 'Skip and Mark Paid' : 'Mark Paid'} | ||
loading={isMarkPaidSaved} | ||
loading={isMarkPaidSaved || updatingPayment} | ||
endingImg={'/static/mark_paid.svg'} | ||
textStyle={{ | ||
width: '130px', | ||
|
@@ -815,25 +852,7 @@ function MobileView(props: CodingBountiesProps) { | |
hovercolor={color.button_primary.hover} | ||
activecolor={color.button_primary.active} | ||
shadowcolor={color.button_primary.shadow} | ||
onClick={(e: any) => { | ||
e.stopPropagation(); | ||
updatePaymentStatus(created || 0); | ||
setExtrasPropertyAndSaveMultiple('paid', { | ||
award: awardDetails.name | ||
}); | ||
|
||
setTimeout(() => { | ||
setCreatorStep(0); | ||
}, 3000); | ||
setTimeout(() => { | ||
if (setIsPaidStatusPopOver) setIsPaidStatusPopOver(true); | ||
}, 4000); | ||
setTimeout(() => { | ||
if (awardDetails?.name !== '') { | ||
setIsPaidStatusBadgeInfo(true); | ||
} | ||
}, 5500); | ||
}} | ||
onClick={handleSetAsPaid} | ||
/> | ||
</AwardBottomContainer> | ||
</AwardsContainer> | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure why we have this new res var if its not being used