{!(item.position && (pinnable || !item.subName)) && !(!item.parentId && Number(item.user?.id) === USER_ID.ad) &&
@@ -217,8 +151,11 @@ export default function ItemInfo ({
{
showActionDropdown &&
<>
-
-
+
+
@@ -317,3 +254,85 @@ function InfoDropdownItem ({ item }) {
)
}
+
+function PaymentInfo ({ item, disableRetry, setDisableRetry }) {
+ const { me } = useMe()
+ const toaster = useToast()
+ const retryCreateItem = useRetryCreateItem({ id: item.id })
+ const waitForQrPayment = useQrPayment()
+ const [disableInfoRetry, setDisableInfoRetry] = useState(disableRetry)
+ if (item.deletedAt) return null
+
+ const disableDualRetry = disableRetry || disableInfoRetry
+ function setDisableDualRetry (value) {
+ setDisableInfoRetry(value)
+ setDisableRetry?.(value)
+ }
+
+ let Component
+ let onClick
+ if (me && item.invoice?.actionState && item.invoice?.actionState !== 'PAID') {
+ if (item.invoice?.actionState === 'FAILED') {
+ Component = () => retry payment
+ onClick = async () => {
+ if (disableDualRetry) return
+ setDisableDualRetry(true)
+ try {
+ const { error } = await retryCreateItem({ variables: { invoiceId: parseInt(item.invoice?.id) } })
+ if (error) throw error
+ } catch (error) {
+ toaster.danger(error.message)
+ } finally {
+ setDisableDualRetry(false)
+ }
+ }
+ } else {
+ Component = () => (
+ pending
+
+ )
+ onClick = () => waitForQrPayment({ id: item.invoice?.id }, null, { cancelOnClose: false }).catch(console.error)
+ }
+ } else {
+ return null
+ }
+
+ return (
+ <>
+ \
+
+
+
+ >
+ )
+}
+
+function EditInfo ({ item, canEdit, setCanEdit, onEdit, editText, editThreshold }) {
+ const router = useRouter()
+
+ if (canEdit) {
+ return (
+ <>
+ \
+ onEdit ? onEdit() : router.push(`/items/${item.id}/edit`)}
+ >
+ {editText || 'edit'}
+ {(!item.invoice?.actionState || item.invoice?.actionState === 'PAID') &&
+ { setCanEdit(false) }}
+ />}
+
+ >
+ )
+ }
+
+ return null
+}
diff --git a/components/item.js b/components/item.js
index 17538f10..331870ce 100644
--- a/components/item.js
+++ b/components/item.js
@@ -87,7 +87,7 @@ function ItemLink ({ url, rel }) {
export default function Item ({
item, rank, belowTitle, right, full, children, itemClassName,
- onQuoteReply, pinnable
+ onQuoteReply, pinnable, setDisableRetry, disableRetry
}) {
const titleRef = useRef()
const router = useRouter()
@@ -139,6 +139,8 @@ export default function Item ({
onQuoteReply={onQuoteReply}
pinnable={pinnable}
extraBadges={Number(item?.user?.id) === USER_ID.ad && AD}
+ setDisableRetry={setDisableRetry}
+ disableRetry={disableRetry}
/>
{belowTitle}
diff --git a/components/notifications.js b/components/notifications.js
index 3092a5b3..65fa72ad 100644
--- a/components/notifications.js
+++ b/components/notifications.js
@@ -38,6 +38,7 @@ import { paidActionCacheMods } from './use-paid-mutation'
import { useRetryCreateItem } from './use-item-submit'
import { payBountyCacheMods } from './pay-bounty'
import { useToast } from './toast'
+import classNames from 'classnames'
function Notification ({ n, fresh }) {
const type = n.__typename
@@ -102,14 +103,14 @@ function NoteHeader ({ color, children, big }) {
)
}
-function NoteItem ({ item }) {
+function NoteItem ({ item, ...props }) {
return (