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 ? ( +
+