-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from hubcio2115/project-dashboard-view
- Loading branch information
Showing
21 changed files
with
740 additions
and
140 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
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
29 changes: 29 additions & 0 deletions
29
apps/web/src/app/api/organizations/[name]/projects/video/[id]/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,29 @@ | ||
import { NextRequest, NextResponse } from "next/server"; | ||
import { isUserInOrganization } from "~/server/api/utils/organizations"; | ||
import { getVideo } from "~/server/api/utils/project"; | ||
import { auth } from "~/server/auth"; | ||
|
||
export async function GET( | ||
req: NextRequest, | ||
{ params }: { params: { id: string; name: string } }, | ||
) { | ||
const session = await auth(); | ||
|
||
const isUserAuthorized = | ||
session?.user && (await isUserInOrganization(session.user.id, params.name)); | ||
|
||
if (!isUserAuthorized) { | ||
return NextResponse.json({ message: "UNAUTHORIZED" }, { status: 401 }); | ||
} | ||
|
||
const [video, err] = await getVideo(params.name, params.id); | ||
|
||
if (err !== null) { | ||
return NextResponse.json( | ||
{ message: "Something went wrong on our end", cause: err }, | ||
{ status: 500 }, | ||
); | ||
} | ||
|
||
return NextResponse.json(video); | ||
} |
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,25 @@ | ||
import { NextRequest, NextResponse } from "next/server"; | ||
import { getChannel } from "~/server/api/utils/project"; | ||
import { auth } from "~/server/auth"; | ||
|
||
export async function GET( | ||
req: NextRequest, | ||
{ params }: { params: { id: string } }, | ||
) { | ||
const session = auth(); | ||
|
||
if (!session) { | ||
return NextResponse.json({ message: "UNAUTHORIZED" }, { status: 401 }); | ||
} | ||
|
||
const [categories, err] = await getChannel(params.id); | ||
|
||
if (err !== null) { | ||
return NextResponse.json( | ||
{ message: "Something went wrong on our end", cause: err }, | ||
{ status: 500 }, | ||
); | ||
} | ||
|
||
return NextResponse.json(categories); | ||
} |
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
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 |
---|---|---|
@@ -1,27 +1,53 @@ | ||
import { | ||
Card, | ||
CardDescription, | ||
CardHeader, | ||
CardTitle, | ||
} from "~/components/ui/card"; | ||
"use client"; | ||
|
||
import Image from "next/image"; | ||
import Link from "next/link"; | ||
import type { Project } from "~/lib/validators/project"; | ||
import { useVideoSuspenseQuery } from "~/lib/queries/useVideoQuery"; | ||
import { useParams } from "next/navigation"; | ||
import { useChannelSuspenseQuery } from "~/lib/queries/useChannelQuery"; | ||
|
||
interface ProjectCardProps { | ||
project: Project; | ||
} | ||
|
||
export default function VideoCard({ project }: ProjectCardProps) { | ||
const { name } = useParams() as { name: string }; | ||
|
||
const { data: video } = useVideoSuspenseQuery(project.videoId!, name); | ||
const { data: channel } = useChannelSuspenseQuery(project.channelId); | ||
|
||
return ( | ||
<Card className="max-w-[460px] hover:cursor-pointer hover:bg-slate-50"> | ||
<CardHeader> | ||
<CardTitle className="h-6 text-base sm:text-2xl"> | ||
{project.title} | ||
</CardTitle> | ||
<div className="max-w-[350px] sm:max-w-96 mx-auto"> | ||
<Link | ||
href={`/dashboard/${name}/project/${project.id}`} | ||
className="flex items-center max-h-min flex-col gap-2" | ||
> | ||
<div className="h-60 w-[320px] sm:w-96 rounded-lg overflow-hidden"> | ||
<Image | ||
className="h-60 w-[320px] sm:w-96" | ||
alt="project thumbnail" | ||
src={video.snippet?.thumbnails?.standard?.url ?? ""} | ||
width={video.snippet?.thumbnails?.standard?.width ?? 320} | ||
height={video.snippet?.thumbnails?.standard?.height ?? 180} | ||
/> | ||
</div> | ||
|
||
<div className="flex w-full gap-2"> | ||
<Image | ||
className="w-10 h-10 rounded-full" | ||
alt="channel thumbnail" | ||
src={channel.snippet?.thumbnails?.default?.url ?? ""} | ||
width={40} | ||
height={40} | ||
/> | ||
|
||
<CardDescription className="h-10 overflow-hidden"> | ||
{project.description} | ||
</CardDescription> | ||
</CardHeader> | ||
</Card> | ||
<div className="flex flex-col gap-1 w-full"> | ||
<p className="font-bold">{project.title}</p> | ||
<p className="text-sm text-slate-500">{channel.snippet?.title}</p> | ||
</div> | ||
</div> | ||
</Link> | ||
</div> | ||
); | ||
} |
33 changes: 33 additions & 0 deletions
33
apps/web/src/components/dashboard/project-grid-skeleton.tsx
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,33 @@ | ||
import { Skeleton } from "../ui/skeleton"; | ||
|
||
export default function ProjectsSkeleton() { | ||
return ( | ||
<> | ||
{(() => { | ||
const projects = []; | ||
for (let i = 0; i < 12; i++) { | ||
projects.push( | ||
<div | ||
key={i} | ||
className="flex items-center flex-col max-w-[350px] sm:max-w-96 mx-auto gap-2" | ||
> | ||
<Skeleton className="h-60 w-[320px] sm:w-96 rounded-lg" /> | ||
|
||
<div className="w-full flex gap-2"> | ||
<Skeleton className="min-w-10 w-10 h-10 rounded-full" /> | ||
|
||
<div className="flex flex-col gap-1 w-full"> | ||
<Skeleton className="w-full h-5" /> | ||
<Skeleton className="w-64 h-5" /> | ||
<Skeleton className="w-32 h-5" /> | ||
</div> | ||
</div> | ||
</div>, | ||
); | ||
} | ||
|
||
return projects; | ||
})()} | ||
</> | ||
); | ||
} |
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
Oops, something went wrong.