From 695b59fd99ff942ab2f6f14bc6e5ce0b57679ff0 Mon Sep 17 00:00:00 2001
From: David Chee <104849031+SirSaltyy@users.noreply.github.com>
Date: Fri, 20 Sep 2024 14:39:24 -0700
Subject: [PATCH] add managed by manifold to sweepstakes (#2893)
---
.../contract/contract-description.tsx | 57 ++++++++++++-------
.../contract/twomba-contract-page.tsx | 7 ++-
2 files changed, 41 insertions(+), 23 deletions(-)
diff --git a/web/components/contract/contract-description.tsx b/web/components/contract/contract-description.tsx
index 2ae1112181..9107a4b4c5 100644
--- a/web/components/contract/contract-description.tsx
+++ b/web/components/contract/contract-description.tsx
@@ -11,38 +11,51 @@ import { JSONContent } from '@tiptap/core'
import { updateMarket } from 'web/lib/api/api'
import { toast } from 'react-hot-toast'
-export function ContractDescription(props: { contract: Contract }) {
- const { contract } = props
+export function ContractDescription(props: {
+ contract: Contract
+ description: string | JSONContent
+}) {
+ const { contract, description } = props
const isAdmin = useAdmin()
const user = useUser()
const isCreator = user?.id === contract.creatorId
return (
-
- {isCreator || isAdmin ? (
-
- ) : (
-
+ <>
+ {contract.token === 'CASH' && (
+
+ This market is managed and resolved by Manifold.
+
)}
-
+
+ {isCreator || isAdmin ? (
+
+ ) : (
+
+ )}
+
+ >
)
}
-function EditableDescription(props: { contract: Contract }) {
- const { contract } = props
+function EditableDescription(props: {
+ contract: Contract
+ description: string | JSONContent
+}) {
+ const { contract, description } = props
const [editing, setEditing] = useState(false)
const editor = useTextEditor({
max: MAX_DESCRIPTION_LENGTH,
- defaultValue: contract.description,
+ defaultValue: description,
})
- const emptyDescription = editor?.isEmpty
+ const isDescriptionEmpty = JSONEmpty(description)
const [saving, setSaving] = useState(false)
async function saveDescription() {
@@ -80,9 +93,9 @@ function EditableDescription(props: { contract: Contract }) {
>
) : (
<>
- {!emptyDescription && (
+ {!isDescriptionEmpty && (
)}
@@ -95,7 +108,7 @@ function EditableDescription(props: { contract: Contract }) {
editor?.commands.focus('end')
}}
>
- {emptyDescription ? (
+ {isDescriptionEmpty ? (
<>
Add description
>
@@ -113,12 +126,12 @@ function EditableDescription(props: { contract: Contract }) {
export function JSONEmpty(text: string | JSONContent) {
if (!text) return true
if (typeof text === 'string') {
- return text === ''
+ return text.trim() === ''
} else if ('content' in text) {
return !(
- !!text.content &&
+ text.content &&
text.content.length > 0 &&
- (!!text.content[0].content || !!text.content[0].attrs)
+ (text.content[0].content || text.content[0].attrs)
)
}
return true
diff --git a/web/components/contract/twomba-contract-page.tsx b/web/components/contract/twomba-contract-page.tsx
index f271c1ae11..e4db407bda 100644
--- a/web/components/contract/twomba-contract-page.tsx
+++ b/web/components/contract/twomba-contract-page.tsx
@@ -168,6 +168,8 @@ export function TwombaContractPageContent(props: ContractParams) {
liveContract
const { coverImageUrl } = livePlayContract
+ const description = livePlayContract.description
+
const isAdmin = useAdmin()
const isMod = useTrusted()
const isCreator = creatorId === user?.id
@@ -420,7 +422,10 @@ export function TwombaContractPageContent(props: ContractParams) {
userHasBet={!!contractMetrics}
hasReviewed={!!userHasReviewed}
/>
-
+