Merge branch 'main' into austin/dc-hackathon

This commit is contained in:
Austin Chen 2022-10-12 09:57:07 -07:00
commit 2adba0fb90
7 changed files with 25 additions and 16 deletions

View File

@ -12,6 +12,7 @@ export type Post = {
// denormalized user fields
creatorName: string
creatorUsername: string
creatorAvatarUrl?: string
}
export type DateDoc = Post & {

View File

@ -102,6 +102,7 @@ export const createpost = newEndpoint({}, async (req, auth) => {
contractSlug,
creatorName: creator.name,
creatorUsername: creator.username,
creatorAvatarUrl: creator.avatarUrl,
})
await postRef.create(post)

View File

@ -53,6 +53,8 @@ export function ImageModal(props: {
)
}
// Note: this is currently tied to a DreamStudio API key tied to akrolsmir@gmail.com,
// and injected on Vercel.
const API_KEY = process.env.NEXT_PUBLIC_DREAM_KEY
function DreamTab(props: {
@ -77,17 +79,13 @@ function DreamTab(props: {
async function dream() {
setIsDreaming(true)
const url = `/api/v0/dream`
const data = {
prompt: input + ', ' + MODIFIERS,
apiKey: API_KEY,
}
const headers = {
'Content-Type': 'application/json',
}
const response = await fetch(url, {
const response = await fetch(`/api/v0/dream`, {
method: 'POST',
headers,
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
})
const json = await response.json()

View File

@ -230,7 +230,7 @@ export function PinnedItems(props: {
return pinned.length > 0 || isEditable ? (
<div>
<Row className="mb-3 items-center justify-between">
<Row className=" items-center justify-between">
<SectionHeader label={'Featured'} href={`#`} />
{isEditable && (
<Button
@ -265,7 +265,7 @@ export function PinnedItems(props: {
</div>
)}
{pinned.map((element, index) => (
<div className="relative my-2">
<div className="relative mb-4">
{element}
{editMode && <CrossIcon onClick={() => onDeleteClicked(index)} />}

View File

@ -29,7 +29,11 @@ export function PostCard(props: {
<Row className="flex grow justify-between">
<div className="">
<Row className="items-center text-sm ">
<Avatar className="mx-1 h-7 w-7" username={post.creatorUsername} />
<Avatar
className="mx-1 h-7 w-7"
username={post.creatorUsername}
avatarUrl={post.creatorAvatarUrl}
/>
<UserLink
className=" text-gray-400"
name={post.creatorName}
@ -41,7 +45,7 @@ export function PostCard(props: {
<div className=" break-words text-lg font-semibold text-indigo-700 group-hover:underline group-hover:decoration-indigo-400 group-hover:decoration-2">
{post.title}
</div>
<div className="font-small text-md break-words text-indigo-400">
<div className="font-small text-md break-words text-gray-500">
{post.subtitle}
</div>
</div>

View File

@ -18,7 +18,6 @@ export default async function route(req: NextApiRequest, res: NextApiResponse) {
methods: 'POST',
})
// const body = JSON.parse(req.body)
// Check that prompt and apiKey are included in the body
if (!req.body.prompt) {
res.status(400).json({ message: 'Missing prompt' })
@ -59,6 +58,7 @@ export default async function route(req: NextApiRequest, res: NextApiResponse) {
res.status(200).json({ url })
} catch (e) {
console.error(e)
res.status(500).json({ message: `Error running code: ${e}` })
}
}

View File

@ -275,9 +275,13 @@ function renderSections(
}
if (id === 'featured') {
// For now, only admins can see the featured section, until we all agree its ship-ready
if (!isAdmin) return <></>
return <FeaturedSection globalConfig={globalConfig} pinned={pinned} />
return (
<FeaturedSection
globalConfig={globalConfig}
pinned={pinned}
isAdmin={isAdmin}
/>
)
}
const contracts = sectionContracts[id]
@ -396,8 +400,9 @@ function SearchSection(props: {
function FeaturedSection(props: {
globalConfig: GlobalConfig
pinned: JSX.Element[]
isAdmin: boolean
}) {
const { globalConfig, pinned } = props
const { globalConfig, pinned, isAdmin } = props
const posts = useAllPosts()
async function onSubmit(selectedItems: { itemId: string; type: string }[]) {
@ -422,7 +427,7 @@ function FeaturedSection(props: {
<Col>
<PinnedItems
posts={posts}
isEditable={true}
isEditable={isAdmin}
pinned={pinned}
onDeleteClicked={onDeleteClicked}
onSubmit={onSubmit}