-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
66 changed files
with
2,994 additions
and
1,597 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import DashboardPage from "@/components/pages/DashboardPage"; | ||
import { Metadata } from "next"; | ||
|
||
export const metadata: Metadata = { | ||
title: "Dashboard", | ||
}; | ||
|
||
const Dashboard = () => <DashboardPage />; | ||
|
||
export default Dashboard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { getCurrentUserOrRedirect } from "@/lib/sessions"; | ||
|
||
type Props = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
export default async function Layout({ children }: Props) { | ||
await getCurrentUserOrRedirect(); | ||
|
||
return <>{children}</>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import StudioPage from "@/components/pages/StudioPage"; | ||
import replicateClient from "@/core/clients/replicate"; | ||
import db from "@/core/db"; | ||
import { getCurrentSessionRedirect } from "@/lib/sessions"; | ||
import { Metadata } from "next"; | ||
import { notFound } from "next/navigation"; | ||
|
||
const PROJECTS_PER_PAGE = 9; | ||
|
||
export const metadata: Metadata = { | ||
title: "My Studio", | ||
}; | ||
|
||
const Studio = async ({ params }: { params: { id: string } }) => { | ||
const session = await getCurrentSessionRedirect(); | ||
const projectId = params.id; | ||
|
||
const project = await db.project.findFirst({ | ||
where: { | ||
id: projectId, | ||
userId: session.userId, | ||
modelStatus: "succeeded", | ||
}, | ||
include: { | ||
_count: { | ||
select: { shots: true }, | ||
}, | ||
shots: { | ||
orderBy: { createdAt: "desc" }, | ||
take: PROJECTS_PER_PAGE, | ||
skip: 0, | ||
}, | ||
}, | ||
orderBy: { createdAt: "desc" }, | ||
}); | ||
|
||
if (!project) { | ||
notFound(); | ||
} | ||
|
||
const { data: model } = await replicateClient.get( | ||
`https://api.replicate.com/v1/models/${process.env.REPLICATE_USERNAME}/${project.id}/versions/${project.modelVersionId}` | ||
); | ||
|
||
const hasImageInputAvailable = Boolean( | ||
model.openapi_schema?.components?.schemas?.Input?.properties?.image?.title | ||
); | ||
|
||
return ( | ||
<StudioPage | ||
project={project} | ||
hasImageInputAvailable={hasImageInputAvailable} | ||
/> | ||
); | ||
}; | ||
|
||
export default Studio; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import FaqPage from "@/components/pages/FaqPage"; | ||
import { Metadata } from "next"; | ||
|
||
export const metadata: Metadata = { | ||
title: "FAQ", | ||
}; | ||
|
||
const Faq = () => <FaqPage />; | ||
|
||
export default Faq; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import GalleryPage from "@/components/pages/GalleryPage"; | ||
import db from "@/core/db"; | ||
import { Metadata } from "next"; | ||
|
||
export const metadata: Metadata = { | ||
title: "Gallery", | ||
}; | ||
|
||
const Gallery = async ({ params }: { params: { userId: string } }) => { | ||
const userId = params.userId; | ||
|
||
const shots = await db.shot.findMany({ | ||
select: { outputUrl: true, blurhash: true }, | ||
orderBy: { createdAt: "desc" }, | ||
where: { | ||
outputUrl: { not: { equals: null } }, | ||
bookmarked: true, | ||
Project: { | ||
userId: { | ||
equals: userId, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
return <GalleryPage shots={shots} />; | ||
}; | ||
|
||
export default Gallery; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import HowItWorksPage from "@/components/pages/HowItWorksPage"; | ||
import { Metadata } from "next"; | ||
|
||
export const metadata: Metadata = { | ||
title: "AI Avatar: how it works", | ||
}; | ||
|
||
const HowItWorks = () => <HowItWorksPage />; | ||
|
||
export default HowItWorks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import LoginPage from "@/components/pages/LoginPage"; | ||
import { getCurrentUser } from "@/lib/sessions"; | ||
import { redirect } from "next/navigation"; | ||
|
||
const Login = async () => { | ||
const user = await getCurrentUser(); | ||
|
||
if (user) { | ||
redirect("/dashboard"); | ||
} | ||
|
||
return <LoginPage />; | ||
}; | ||
|
||
export default Login; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import PromptDetailPage, { | ||
TPrompt, | ||
} from "@/components/pages/prompts/PromptDetailPage"; | ||
import { prompts } from "@/core/utils/prompts"; | ||
|
||
export function generateStaticParams() { | ||
return prompts.map((prompt) => ({ | ||
slug: prompt.slug, | ||
})); | ||
} | ||
|
||
export async function generateMetadata({ | ||
params, | ||
}: { | ||
params: { slug: string }; | ||
}) { | ||
const slug = params?.slug as string; | ||
const prompt = prompts.find((prompt) => prompt.slug === slug)!; | ||
|
||
return { | ||
title: `Free prompt ${prompt.label} - Photoshot`, | ||
description: | ||
"Our free AI prompt covers a wide range of themes and topics to help you create a unique avatar. Use theme with our Studio or your Stable Diffusion or Dreambooth models.", | ||
}; | ||
} | ||
|
||
const PromptDetail = async ({ params }: { params: { slug: string } }) => { | ||
const slug = params?.slug as string; | ||
const promptIndex = prompts.findIndex((prompt) => prompt.slug === slug)!; | ||
const prompt = prompts[promptIndex]; | ||
|
||
const morePrompts: TPrompt[] = []; | ||
|
||
for (let i = promptIndex + 1; i < promptIndex + 6; i++) { | ||
if (i > prompts.length - 1) { | ||
morePrompts.push(prompts[Math.abs(i - prompts.length)]); | ||
} else { | ||
morePrompts.push(prompts[i]); | ||
} | ||
} | ||
|
||
return <PromptDetailPage morePrompts={morePrompts} prompt={prompt} />; | ||
}; | ||
|
||
export default PromptDetail; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import PromptsListPage from "@/components/pages/prompts/PromptsListPage"; | ||
import { Metadata } from "next"; | ||
|
||
export const metadata: Metadata = { | ||
title: "AI Prompts Inspiration", | ||
description: | ||
"Our free AI prompt covers a wide range of themes and topics to help you create a unique avatar. Use theme with our Studio or your Stable Diffusion or Dreambooth models.", | ||
}; | ||
|
||
const PromptsList = () => <PromptsListPage />; | ||
|
||
export default PromptsList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import TermsPage from "@/components/pages/TermsPage"; | ||
import { Metadata } from "next"; | ||
|
||
export const metadata: Metadata = { | ||
title: "Photoshot Privacy Policy", | ||
}; | ||
|
||
const Terms = () => <TermsPage />; | ||
|
||
export default Terms; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/app/api/checkout/check/[ppi]/[sessionId]/studio/route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import db from "@/core/db"; | ||
import { stripe } from "@/lib/stripe"; | ||
import { NextResponse } from "next/server"; | ||
|
||
export async function GET( | ||
req: Request, | ||
{ params }: { params: { ppi: string; sessionId: string } } | ||
) { | ||
const sessionId = params.sessionId; | ||
const ppi = params.ppi; | ||
|
||
const session = await stripe.checkout.sessions.retrieve(sessionId); | ||
|
||
if ( | ||
session.payment_status === "paid" && | ||
session.metadata?.projectId === ppi | ||
) { | ||
await db.project.update({ | ||
where: { id: ppi }, | ||
data: { stripePaymentId: session.id }, | ||
}); | ||
|
||
return NextResponse.json( | ||
{ | ||
success: true, | ||
}, | ||
{ status: 200 } | ||
); | ||
} | ||
|
||
return NextResponse.json( | ||
{ | ||
success: false, | ||
}, | ||
{ status: 400 } | ||
); | ||
} |
Oops, something went wrong.
54937e3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
photoshot – ./
photoshot-casasorbier.vercel.app
photoshot-git-main-casasorbier.vercel.app
www.photoshot.app
photoshot.app
photoshot.vercel.app