Merge branch 'main' into austin/dc-hackathon
This commit is contained in:
commit
2adba0fb90
|
@ -12,6 +12,7 @@ export type Post = {
|
||||||
// denormalized user fields
|
// denormalized user fields
|
||||||
creatorName: string
|
creatorName: string
|
||||||
creatorUsername: string
|
creatorUsername: string
|
||||||
|
creatorAvatarUrl?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type DateDoc = Post & {
|
export type DateDoc = Post & {
|
||||||
|
|
|
@ -102,6 +102,7 @@ export const createpost = newEndpoint({}, async (req, auth) => {
|
||||||
contractSlug,
|
contractSlug,
|
||||||
creatorName: creator.name,
|
creatorName: creator.name,
|
||||||
creatorUsername: creator.username,
|
creatorUsername: creator.username,
|
||||||
|
creatorAvatarUrl: creator.avatarUrl,
|
||||||
})
|
})
|
||||||
|
|
||||||
await postRef.create(post)
|
await postRef.create(post)
|
||||||
|
|
|
@ -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
|
const API_KEY = process.env.NEXT_PUBLIC_DREAM_KEY
|
||||||
|
|
||||||
function DreamTab(props: {
|
function DreamTab(props: {
|
||||||
|
@ -77,17 +79,13 @@ function DreamTab(props: {
|
||||||
|
|
||||||
async function dream() {
|
async function dream() {
|
||||||
setIsDreaming(true)
|
setIsDreaming(true)
|
||||||
const url = `/api/v0/dream`
|
|
||||||
const data = {
|
const data = {
|
||||||
prompt: input + ', ' + MODIFIERS,
|
prompt: input + ', ' + MODIFIERS,
|
||||||
apiKey: API_KEY,
|
apiKey: API_KEY,
|
||||||
}
|
}
|
||||||
const headers = {
|
const response = await fetch(`/api/v0/dream`, {
|
||||||
'Content-Type': 'application/json',
|
|
||||||
}
|
|
||||||
const response = await fetch(url, {
|
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers,
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
})
|
})
|
||||||
const json = await response.json()
|
const json = await response.json()
|
||||||
|
|
|
@ -230,7 +230,7 @@ export function PinnedItems(props: {
|
||||||
|
|
||||||
return pinned.length > 0 || isEditable ? (
|
return pinned.length > 0 || isEditable ? (
|
||||||
<div>
|
<div>
|
||||||
<Row className="mb-3 items-center justify-between">
|
<Row className=" items-center justify-between">
|
||||||
<SectionHeader label={'Featured'} href={`#`} />
|
<SectionHeader label={'Featured'} href={`#`} />
|
||||||
{isEditable && (
|
{isEditable && (
|
||||||
<Button
|
<Button
|
||||||
|
@ -265,7 +265,7 @@ export function PinnedItems(props: {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{pinned.map((element, index) => (
|
{pinned.map((element, index) => (
|
||||||
<div className="relative my-2">
|
<div className="relative mb-4">
|
||||||
{element}
|
{element}
|
||||||
|
|
||||||
{editMode && <CrossIcon onClick={() => onDeleteClicked(index)} />}
|
{editMode && <CrossIcon onClick={() => onDeleteClicked(index)} />}
|
||||||
|
|
|
@ -29,7 +29,11 @@ export function PostCard(props: {
|
||||||
<Row className="flex grow justify-between">
|
<Row className="flex grow justify-between">
|
||||||
<div className="">
|
<div className="">
|
||||||
<Row className="items-center text-sm ">
|
<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
|
<UserLink
|
||||||
className=" text-gray-400"
|
className=" text-gray-400"
|
||||||
name={post.creatorName}
|
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">
|
<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}
|
{post.title}
|
||||||
</div>
|
</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}
|
{post.subtitle}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -18,7 +18,6 @@ export default async function route(req: NextApiRequest, res: NextApiResponse) {
|
||||||
methods: 'POST',
|
methods: 'POST',
|
||||||
})
|
})
|
||||||
|
|
||||||
// const body = JSON.parse(req.body)
|
|
||||||
// Check that prompt and apiKey are included in the body
|
// Check that prompt and apiKey are included in the body
|
||||||
if (!req.body.prompt) {
|
if (!req.body.prompt) {
|
||||||
res.status(400).json({ message: 'Missing 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 })
|
res.status(200).json({ url })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
res.status(500).json({ message: `Error running code: ${e}` })
|
res.status(500).json({ message: `Error running code: ${e}` })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -275,9 +275,13 @@ function renderSections(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id === 'featured') {
|
if (id === 'featured') {
|
||||||
// For now, only admins can see the featured section, until we all agree its ship-ready
|
return (
|
||||||
if (!isAdmin) return <></>
|
<FeaturedSection
|
||||||
return <FeaturedSection globalConfig={globalConfig} pinned={pinned} />
|
globalConfig={globalConfig}
|
||||||
|
pinned={pinned}
|
||||||
|
isAdmin={isAdmin}
|
||||||
|
/>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const contracts = sectionContracts[id]
|
const contracts = sectionContracts[id]
|
||||||
|
@ -396,8 +400,9 @@ function SearchSection(props: {
|
||||||
function FeaturedSection(props: {
|
function FeaturedSection(props: {
|
||||||
globalConfig: GlobalConfig
|
globalConfig: GlobalConfig
|
||||||
pinned: JSX.Element[]
|
pinned: JSX.Element[]
|
||||||
|
isAdmin: boolean
|
||||||
}) {
|
}) {
|
||||||
const { globalConfig, pinned } = props
|
const { globalConfig, pinned, isAdmin } = props
|
||||||
const posts = useAllPosts()
|
const posts = useAllPosts()
|
||||||
|
|
||||||
async function onSubmit(selectedItems: { itemId: string; type: string }[]) {
|
async function onSubmit(selectedItems: { itemId: string; type: string }[]) {
|
||||||
|
@ -422,7 +427,7 @@ function FeaturedSection(props: {
|
||||||
<Col>
|
<Col>
|
||||||
<PinnedItems
|
<PinnedItems
|
||||||
posts={posts}
|
posts={posts}
|
||||||
isEditable={true}
|
isEditable={isAdmin}
|
||||||
pinned={pinned}
|
pinned={pinned}
|
||||||
onDeleteClicked={onDeleteClicked}
|
onDeleteClicked={onDeleteClicked}
|
||||||
onSubmit={onSubmit}
|
onSubmit={onSubmit}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user