Date doc: Remove photo as first-class feature
This commit is contained in:
parent
14c008234a
commit
13dad9a10c
|
@ -12,7 +12,6 @@ export type Post = {
|
||||||
export type DateDoc = Post & {
|
export type DateDoc = Post & {
|
||||||
bounty: number
|
bounty: number
|
||||||
birthday: number
|
birthday: number
|
||||||
photoUrl: string
|
|
||||||
type: 'date-doc'
|
type: 'date-doc'
|
||||||
contractSlug: string
|
contractSlug: string
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,6 @@ const postSchema = z.object({
|
||||||
// Date doc fields:
|
// Date doc fields:
|
||||||
bounty: z.number().optional(),
|
bounty: z.number().optional(),
|
||||||
birthday: z.number().optional(),
|
birthday: z.number().optional(),
|
||||||
photoUrl: z.string().optional(),
|
|
||||||
type: z.string().optional(),
|
type: z.string().optional(),
|
||||||
question: z.string().optional(),
|
question: z.string().optional(),
|
||||||
})
|
})
|
||||||
|
|
|
@ -85,7 +85,7 @@ export function DateDocPost(props: {
|
||||||
link?: boolean
|
link?: boolean
|
||||||
}) {
|
}) {
|
||||||
const { dateDoc, creator, link } = props
|
const { dateDoc, creator, link } = props
|
||||||
const { content, birthday, photoUrl, contractSlug } = dateDoc
|
const { content, birthday, contractSlug } = dateDoc
|
||||||
const { name, username } = creator
|
const { name, username } = creator
|
||||||
|
|
||||||
const user = useUser()
|
const user = useUser()
|
||||||
|
@ -133,11 +133,6 @@ export function DateDocPost(props: {
|
||||||
</Button>
|
</Button>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
<img
|
|
||||||
className="w-full max-w-lg rounded-lg object-cover"
|
|
||||||
src={photoUrl}
|
|
||||||
alt={name}
|
|
||||||
/>
|
|
||||||
</Col>
|
</Col>
|
||||||
</SiteLink>
|
</SiteLink>
|
||||||
{user && user.id === creator.id ? (
|
{user && user.id === creator.id ? (
|
||||||
|
|
|
@ -13,8 +13,6 @@ import { Button } from 'web/components/button'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import { MINUTE_MS } from 'common/util/time'
|
import { MINUTE_MS } from 'common/util/time'
|
||||||
import { Col } from 'web/components/layout/col'
|
import { Col } from 'web/components/layout/col'
|
||||||
import { uploadImage } from 'web/lib/firebase/storage'
|
|
||||||
import { LoadingIndicator } from 'web/components/loading-indicator'
|
|
||||||
import { MAX_QUESTION_LENGTH } from 'common/contract'
|
import { MAX_QUESTION_LENGTH } from 'common/contract'
|
||||||
|
|
||||||
export default function CreateDateDocPage() {
|
export default function CreateDateDocPage() {
|
||||||
|
@ -26,8 +24,6 @@ export default function CreateDateDocPage() {
|
||||||
|
|
||||||
const title = `${user?.name}'s Date Doc`
|
const title = `${user?.name}'s Date Doc`
|
||||||
const [birthday, setBirthday] = useState<undefined | string>(undefined)
|
const [birthday, setBirthday] = useState<undefined | string>(undefined)
|
||||||
const [photoUrl, setPhotoUrl] = useState('')
|
|
||||||
const [avatarLoading, setAvatarLoading] = useState(false)
|
|
||||||
const [question, setQuestion] = useState(
|
const [question, setQuestion] = useState(
|
||||||
'Will I find a partner in the next 3 months?'
|
'Will I find a partner in the next 3 months?'
|
||||||
)
|
)
|
||||||
|
@ -40,30 +36,7 @@ export default function CreateDateDocPage() {
|
||||||
|
|
||||||
const birthdayTime = birthday ? dayjs(birthday).valueOf() : undefined
|
const birthdayTime = birthday ? dayjs(birthday).valueOf() : undefined
|
||||||
const isValid =
|
const isValid =
|
||||||
user &&
|
user && birthday && editor && editor.isEmpty === false && question
|
||||||
birthday &&
|
|
||||||
photoUrl &&
|
|
||||||
editor &&
|
|
||||||
editor.isEmpty === false &&
|
|
||||||
question
|
|
||||||
|
|
||||||
const fileHandler = async (event: any) => {
|
|
||||||
if (!user) return
|
|
||||||
|
|
||||||
const file = event.target.files[0]
|
|
||||||
|
|
||||||
setAvatarLoading(true)
|
|
||||||
|
|
||||||
await uploadImage(user.username, file)
|
|
||||||
.then(async (url) => {
|
|
||||||
setPhotoUrl(url)
|
|
||||||
setAvatarLoading(false)
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
setAvatarLoading(false)
|
|
||||||
setPhotoUrl('')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async function saveDateDoc() {
|
async function saveDateDoc() {
|
||||||
if (!user || !editor || !birthdayTime) return
|
if (!user || !editor || !birthdayTime) return
|
||||||
|
@ -76,7 +49,6 @@ export default function CreateDateDocPage() {
|
||||||
content: editor.getJSON(),
|
content: editor.getJSON(),
|
||||||
bounty: 0,
|
bounty: 0,
|
||||||
birthday: birthdayTime,
|
birthday: birthdayTime,
|
||||||
photoUrl,
|
|
||||||
type: 'date-doc',
|
type: 'date-doc',
|
||||||
question,
|
question,
|
||||||
}
|
}
|
||||||
|
@ -122,33 +94,6 @@ export default function CreateDateDocPage() {
|
||||||
/>
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
|
|
||||||
<Col className="gap-4">
|
|
||||||
<div className="">Photo</div>
|
|
||||||
<Row className="items-center gap-4">
|
|
||||||
{avatarLoading ? (
|
|
||||||
<LoadingIndicator />
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
{photoUrl && (
|
|
||||||
<img
|
|
||||||
src={photoUrl}
|
|
||||||
width={80}
|
|
||||||
height={80}
|
|
||||||
className="flex h-[80px] w-[80px] items-center justify-center rounded-lg bg-gray-400 object-cover"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<input
|
|
||||||
className="text-sm text-gray-500"
|
|
||||||
type="file"
|
|
||||||
name="file"
|
|
||||||
accept="image/*"
|
|
||||||
onChange={fileHandler}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Row>
|
|
||||||
</Col>
|
|
||||||
|
|
||||||
<Col className="gap-4">
|
<Col className="gap-4">
|
||||||
<div className="">
|
<div className="">
|
||||||
Tell us about you! What are you looking for?
|
Tell us about you! What are you looking for?
|
||||||
|
|
Loading…
Reference in New Issue
Block a user