Max answer length 240 chars
This commit is contained in:
parent
22dd206f12
commit
f88dc56e4b
|
@ -29,3 +29,5 @@ export const getNoneAnswer = (contractId: string, creator: User) => {
|
||||||
text: 'None',
|
text: 'None',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const MAX_ANSWER_LENGTH = 240
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {
|
||||||
} from '../../common/contract'
|
} from '../../common/contract'
|
||||||
import { User } from '../../common/user'
|
import { User } from '../../common/user'
|
||||||
import { getLoanAmount, getNewMultiBetInfo } from '../../common/new-bet'
|
import { getLoanAmount, getNewMultiBetInfo } from '../../common/new-bet'
|
||||||
import { Answer } from '../../common/answer'
|
import { Answer, MAX_ANSWER_LENGTH } from '../../common/answer'
|
||||||
import { getContract, getValues } from './utils'
|
import { getContract, getValues } from './utils'
|
||||||
import { sendNewAnswerEmail } from './emails'
|
import { sendNewAnswerEmail } from './emails'
|
||||||
import { Bet } from '../../common/bet'
|
import { Bet } from '../../common/bet'
|
||||||
|
@ -31,7 +31,7 @@ export const createAnswer = functions.runWith({ minInstances: 1 }).https.onCall(
|
||||||
if (amount <= 0 || isNaN(amount) || !isFinite(amount))
|
if (amount <= 0 || isNaN(amount) || !isFinite(amount))
|
||||||
return { status: 'error', message: 'Invalid amount' }
|
return { status: 'error', message: 'Invalid amount' }
|
||||||
|
|
||||||
if (!text || typeof text !== 'string' || text.length > 10000)
|
if (!text || typeof text !== 'string' || text.length > MAX_ANSWER_LENGTH)
|
||||||
return { status: 'error', message: 'Invalid text' }
|
return { status: 'error', message: 'Invalid text' }
|
||||||
|
|
||||||
// Run as transaction to prevent race conditions.
|
// Run as transaction to prevent race conditions.
|
||||||
|
|
|
@ -22,6 +22,7 @@ import {
|
||||||
} from '../../../common/calculate-dpm'
|
} from '../../../common/calculate-dpm'
|
||||||
import { firebaseLogin } from '../../lib/firebase/users'
|
import { firebaseLogin } from '../../lib/firebase/users'
|
||||||
import { Bet } from '../../../common/bet'
|
import { Bet } from '../../../common/bet'
|
||||||
|
import { MAX_ANSWER_LENGTH } from '../../../common/answer'
|
||||||
|
|
||||||
export function CreateAnswerPanel(props: {
|
export function CreateAnswerPanel(props: {
|
||||||
contract: FullContract<DPM, FreeResponse>
|
contract: FullContract<DPM, FreeResponse>
|
||||||
|
@ -84,7 +85,7 @@ export function CreateAnswerPanel(props: {
|
||||||
className="textarea textarea-bordered w-full resize-none"
|
className="textarea textarea-bordered w-full resize-none"
|
||||||
placeholder="Type your answer..."
|
placeholder="Type your answer..."
|
||||||
rows={1}
|
rows={1}
|
||||||
maxLength={10000}
|
maxLength={MAX_ANSWER_LENGTH}
|
||||||
/>
|
/>
|
||||||
<div />
|
<div />
|
||||||
<Col
|
<Col
|
||||||
|
|
Loading…
Reference in New Issue
Block a user