Denormalize username to each contract
This commit is contained in:
parent
f6c45a29c2
commit
77e15e3aa8
|
@ -118,7 +118,7 @@ function MyContractBets(props: { contract: Contract; bets: Bet[] }) {
|
||||||
|
|
||||||
<Row className="gap-2 text-gray-500 text-sm">
|
<Row className="gap-2 text-gray-500 text-sm">
|
||||||
<div>
|
<div>
|
||||||
<UserLink displayName={contract.creatorName} />
|
<UserLink username={contract.creatorUsername} />
|
||||||
</div>
|
</div>
|
||||||
{resolution && (
|
{resolution && (
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -21,7 +21,7 @@ export function ContractDetails(props: { contract: Contract }) {
|
||||||
return (
|
return (
|
||||||
<Row className="flex-wrap text-sm text-gray-500">
|
<Row className="flex-wrap text-sm text-gray-500">
|
||||||
<div className="whitespace-nowrap">
|
<div className="whitespace-nowrap">
|
||||||
<UserLink displayName={contract.creatorName} />
|
<UserLink username={contract.creatorUsername} />
|
||||||
</div>
|
</div>
|
||||||
<div className="mx-2">•</div>
|
<div className="mx-2">•</div>
|
||||||
<div className="whitespace-nowrap">
|
<div className="whitespace-nowrap">
|
||||||
|
|
|
@ -4,15 +4,12 @@ import { ContractsList } from './contracts-list'
|
||||||
import { Title } from './title'
|
import { Title } from './title'
|
||||||
import { Row } from './layout/row'
|
import { Row } from './layout/row'
|
||||||
import { formatMoney } from '../lib/util/format'
|
import { formatMoney } from '../lib/util/format'
|
||||||
import { BetsList } from './bets-list'
|
|
||||||
import { Spacer } from './layout/spacer'
|
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import { SEO } from './SEO'
|
import { SEO } from './SEO'
|
||||||
|
|
||||||
export function UserLink(props: { displayName: string; className?: string }) {
|
export function UserLink(props: { username: string; className?: string }) {
|
||||||
const { displayName, className } = props
|
const { username, className } = props
|
||||||
const username = displayName.replace(/\s+/g, '')
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link href={`/${username}`}>
|
<Link href={`/${username}`}>
|
||||||
|
|
|
@ -21,6 +21,7 @@ export type Contract = {
|
||||||
|
|
||||||
creatorId: string
|
creatorId: string
|
||||||
creatorName: string
|
creatorName: string
|
||||||
|
creatorUsername: string
|
||||||
|
|
||||||
question: string
|
question: string
|
||||||
description: string // More info about what the contract is about
|
description: string // More info about what the contract is about
|
||||||
|
@ -42,9 +43,7 @@ export type Contract = {
|
||||||
|
|
||||||
export function path(contract: Contract) {
|
export function path(contract: Contract) {
|
||||||
// For now, derive username from creatorName
|
// For now, derive username from creatorName
|
||||||
// Fix this when users can change their own names
|
return `/${contract.creatorUsername}/${contract.slug}`
|
||||||
const username = contract.creatorName.replace(/\s+/g, '')
|
|
||||||
return `/${username}/${contract.slug}`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function compute(contract: Contract) {
|
export function compute(contract: Contract) {
|
||||||
|
|
|
@ -31,6 +31,7 @@ export async function createContract(
|
||||||
|
|
||||||
creatorId: creator.id,
|
creatorId: creator.id,
|
||||||
creatorName: creator.name,
|
creatorName: creator.name,
|
||||||
|
creatorUsername: creator.username,
|
||||||
|
|
||||||
question: question.trim(),
|
question: question.trim(),
|
||||||
description: description.trim(),
|
description: description.trim(),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user