From 5c6e75afa8ceb9c375e7af78691c03e1c07d216c Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Mon, 12 Sep 2022 09:39:23 -0700 Subject: [PATCH] Revert "WIP: When there's no matching question, create a new contract" This reverts commit efae1bf715dfe02b88169d181a22d6f0fe7ad480. --- web/components/editor/mention-list.tsx | 51 ++------------------------ 1 file changed, 4 insertions(+), 47 deletions(-) diff --git a/web/components/editor/mention-list.tsx b/web/components/editor/mention-list.tsx index 4852e93f..bda9d2fc 100644 --- a/web/components/editor/mention-list.tsx +++ b/web/components/editor/mention-list.tsx @@ -1,19 +1,13 @@ import { SuggestionProps } from '@tiptap/suggestion' import clsx from 'clsx' import { Contract } from 'common/contract' -import { FIXED_ANTE } from 'common/economy' -import { formatMoney } from 'common/util/format' import { forwardRef, useEffect, useImperativeHandle, useState } from 'react' -import { useUser } from 'web/hooks/use-user' import { contractPath } from 'web/lib/firebase/contracts' import { Avatar } from '../avatar' -import { Col } from '../layout/col' -import { Row } from '../layout/row' // copied from https://tiptap.dev/api/nodes/mention#usage const M = forwardRef((props: SuggestionProps, ref) => { - const { items: contracts, command, query } = props - const user = useUser() + const { items: contracts, command } = props const [selectedIndex, setSelectedIndex] = useState(0) useEffect(() => setSelectedIndex(0), [contracts]) @@ -24,24 +18,9 @@ const M = forwardRef((props: SuggestionProps, ref) => { command({ id: contract.id, label: contractPath(contract) } as any) } - const createOptions = [ - { - text: `Create yes/no`, - // TODO: Get these commmands to work - onClick: () => command({ id: 'new', label: 'new' } as any), - }, - { - text: `Create free response`, - onClick: () => command({ id: 'new', label: 'new' } as any), - }, - ] - - const choiceLength = - contracts.length > 0 ? contracts.length : createOptions.length - const onUp = () => - setSelectedIndex((i) => (i + choiceLength - 1) % choiceLength) - const onDown = () => setSelectedIndex((i) => (i + 1) % choiceLength) + setSelectedIndex((i) => (i + contracts.length - 1) % contracts.length) + const onDown = () => setSelectedIndex((i) => (i + 1) % contracts.length) const onEnter = () => submitUser(selectedIndex) useImperativeHandle(ref, () => ({ @@ -65,29 +44,7 @@ const M = forwardRef((props: SuggestionProps, ref) => { return (
{!contracts.length ? ( - - -
{query}
-
- - {createOptions.map((option, i) => ( - - ))} - + No results... ) : ( contracts.map((contract, i) => (