diff --git a/firestore.rules b/firestore.rules
index 73eafb24..253d57f5 100644
--- a/firestore.rules
+++ b/firestore.rules
@@ -23,6 +23,7 @@ service cloud.firestore {
allow read;
allow update: if request.resource.data.diff(resource.data).affectedKeys()
.hasOnly(['description', 'tags', 'lowercaseTags']);
+ allow update: if isAdmin();
allow delete: if resource.data.creatorId == request.auth.uid;
}
diff --git a/web/components/contract-feed.tsx b/web/components/contract-feed.tsx
index f902ea4e..cf794f74 100644
--- a/web/components/contract-feed.tsx
+++ b/web/components/contract-feed.tsx
@@ -43,6 +43,7 @@ import { fromNow } from '../lib/util/time'
import BetRow from './bet-row'
import { parseTags } from '../../common/util/parse'
import { Avatar } from './avatar'
+import { useAdmin } from '../hooks/use-admin'
function FeedComment(props: {
activityItem: any
@@ -154,21 +155,75 @@ function FeedBet(props: { activityItem: any }) {
)
}
+function EditContract(props: {
+ text: string
+ onSave: (newText: string) => void
+ buttonText: string
+}) {
+ const [text, setText] = useState(props.text)
+ const [editing, setEditing] = useState(false)
+ const onSave = (newText: string) => {
+ setEditing(false)
+ setText(props.text) // Reset to original text
+ props.onSave(newText)
+ }
+
+ return editing ? (
+
+
+ ) : (
+
+
+
+ )
+}
+
export function ContractDescription(props: {
contract: Contract
isCreator: boolean
}) {
const { contract, isCreator } = props
- const [editing, setEditing] = useState(false)
- const editStatement = () => `${dayjs().format('MMM D, h:mma')}: `
- const [description, setDescription] = useState(editStatement())
+ const descriptionTimestamp = () => `${dayjs().format('MMM D, h:mma')}: `
+ const isAdmin = useAdmin()
// Append the new description (after a newline)
- async function saveDescription(e: any) {
- e.preventDefault()
- setEditing(false)
-
- const newDescription = `${contract.description}\n\n${description}`.trim()
+ async function saveDescription(newText: string) {
+ const newDescription = `${contract.description}\n\n${newText}`.trim()
const tags = parseTags(
`${newDescription} ${contract.tags.map((tag) => `#${tag}`).join(' ')}`
)
@@ -178,8 +233,6 @@ export function ContractDescription(props: {
tags,
lowercaseTags,
})
-
- setDescription(editStatement())
}
if (!isCreator && !contract.description.trim()) return null
@@ -188,53 +241,32 @@ export function ContractDescription(props: {
- {isCreator &&
- (editing ? (
-
- ) : (
-
-
-
- ))}
+ {isCreator && (
+
+ )}
+ {isAdmin && (
+ updateContract(contract.id, { question })}
+ buttonText="ADMIN: Edit question"
+ />
+ )}
+ {/* {isAdmin && (
+
+ updateContract(contract.id, { createdTime: Number(time) })
+ }
+ buttonText="ADMIN: Edit createdTime"
+ />
+ )} */}
)
}
diff --git a/web/hooks/use-admin.ts b/web/hooks/use-admin.ts
new file mode 100644
index 00000000..733f73f6
--- /dev/null
+++ b/web/hooks/use-admin.ts
@@ -0,0 +1,12 @@
+import { useUser } from './use-user'
+
+export const useAdmin = () => {
+ const user = useUser()
+ const adminIds = [
+ 'igi2zGXsfxYPgB0DJTXVJVmwCOr2', // Austin
+ '5LZ4LgYuySdL1huCWe7bti02ghx2', // James
+ 'tlmGNz9kjXc2EteizMORes4qvWl2', // Stephen
+ 'IPTOzEqrpkWmEzh6hwvAyY9PqFb2', // Manifold
+ ]
+ return adminIds.includes(user?.id || '')
+}
diff --git a/web/pages/admin.tsx b/web/pages/admin.tsx
index e28e94aa..8094ebf6 100644
--- a/web/pages/admin.tsx
+++ b/web/pages/admin.tsx
@@ -8,6 +8,7 @@ import { useUser } from '../hooks/use-user'
import Custom404 from './404'
import { useContracts } from '../hooks/use-contracts'
import _ from 'lodash'
+import { useAdmin } from '../hooks/use-admin'
function avatarHtml(avatarUrl: string) {
return `