-
Notifications
You must be signed in to change notification settings - Fork 1
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
13 changed files
with
92,465 additions
and
93,267 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,7 +1,6 @@ | ||
import {inngest} from '#app/inngest/inngest.server' | ||
|
||
import { inngest } from '#app/inngest/inngest.server' | ||
|
||
export const inngestConfig = { | ||
client: inngest, | ||
functions: [], | ||
client: inngest, | ||
functions: [], | ||
} |
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,8 +1,8 @@ | ||
import {EventSchemas, Inngest} from 'inngest' | ||
import { EventSchemas, Inngest } from 'inngest' | ||
|
||
// Create a client to send and receive events | ||
type Events = {} | ||
export const inngest = new Inngest({ | ||
id: 'epic-egghead', | ||
schemas: new EventSchemas().fromRecord<Events>(), | ||
id: 'epic-egghead', | ||
schemas: new EventSchemas().fromRecord<Events>(), | ||
}) |
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,36 +1,67 @@ | ||
import {useLoaderData} from "#node_modules/@remix-run/react"; | ||
import { useLoaderData } from '#node_modules/@remix-run/react' | ||
import { invariantResponse } from '@epic-web/invariant' | ||
import { json, type LoaderFunctionArgs } from '@remix-run/node' | ||
import {courses} from "#app/data/playlists-short" | ||
|
||
import { prisma } from '#app/utils/db.server.ts' | ||
import MuxPlayer from '@mux/mux-player-react' | ||
|
||
export async function loader({ params }: LoaderFunctionArgs) { | ||
console.log({params}) | ||
const course = courses.find(course => course.slug === params.course) | ||
const lesson = course?.lessons.find(lesson => lesson.slug === params.lesson) | ||
console.log({ params }) | ||
|
||
// const lesson = course?.lessons.find(lesson => lesson.slug === params.lesson) | ||
// invariantResponse(lesson, 'Lesson not found', { status: 404 }) | ||
const lesson = await prisma.lesson.findFirst({ | ||
where: { | ||
slug: params.lesson, | ||
}, | ||
include: { | ||
video: true, | ||
course: { | ||
include: { | ||
instructor: true, | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
invariantResponse(lesson, 'Lesson not found', { status: 404 }) | ||
|
||
console.log({ lesson: lesson.video }) | ||
|
||
invariantResponse(lesson, 'Lesson not found', { status: 404 }) | ||
const muxAsset = await fetch( | ||
`https://api.mux.com/video/v1/assets/${lesson.video?.mux_asset_id}`, | ||
{ | ||
headers: { | ||
Authorization: `Basic ${Buffer.from( | ||
`${process.env.MUX_TOKEN_ID}:${process.env.MUX_TOKEN_SECRET}`, | ||
).toString('base64')}`, | ||
'Content-Type': 'application/json', | ||
}, | ||
}, | ||
) | ||
.then(res => res.json()) | ||
.then((data: any) => data?.data) | ||
|
||
return json({ course, lesson }) | ||
return json({ course: lesson.course, lesson, muxAsset }) | ||
} | ||
|
||
export default function LessonRoute() { | ||
const data = useLoaderData<typeof loader>() | ||
const lesson = data.lesson | ||
|
||
return ( | ||
<div className="container mb-48 mt-36 flex flex-col items-center justify-center"> | ||
<div className="relative"> | ||
{lesson.title} by {lesson.instructor} | ||
{lesson.image && ( | ||
<img | ||
src={lesson.image} | ||
alt={lesson.title} | ||
className="h-52 w-52 object-cover" | ||
/> | ||
)} | ||
</div> | ||
</div> | ||
) | ||
} | ||
const { course, lesson, muxAsset } = useLoaderData<typeof loader>() | ||
|
||
console.log(muxAsset) | ||
|
||
return ( | ||
<div className="container mb-48 mt-36 flex flex-col items-center justify-center"> | ||
<div className="relative"> | ||
{lesson.title} by {course?.instructor?.full_name} | ||
{course?.image_url && ( | ||
<img | ||
src={course?.image_url} | ||
alt={lesson.title} | ||
className="h-52 w-52 object-cover" | ||
/> | ||
)} | ||
<MuxPlayer playbackId={muxAsset.playback_ids[0].id} /> | ||
</div> | ||
</div> | ||
) | ||
} |
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,39 +1,52 @@ | ||
import {useLoaderData} from "#node_modules/@remix-run/react"; | ||
import { useLoaderData } from '#node_modules/@remix-run/react' | ||
import { invariantResponse } from '@epic-web/invariant' | ||
import { json, type LoaderFunctionArgs } from '@remix-run/node' | ||
import {Link} from "@remix-run/react"; | ||
import {courses} from "#app/data/playlists-short" | ||
|
||
import { Link } from '@remix-run/react' | ||
import { prisma } from '#app/utils/db.server.ts' | ||
|
||
export async function loader({ params }: LoaderFunctionArgs) { | ||
const course = courses.find(course => course.slug === params.course) | ||
const course = await prisma.course.findFirst({ | ||
where: { | ||
slug: params.course, | ||
}, | ||
include: { | ||
lessons: true, | ||
instructor: true, | ||
}, | ||
}) | ||
|
||
invariantResponse(course, 'Course not found', { status: 404 }) | ||
invariantResponse(course, 'Course not found', { status: 404 }) | ||
|
||
return json({ course }) | ||
return json({ course }) | ||
} | ||
|
||
export default function ProfileRoute() { | ||
const data = useLoaderData<typeof loader>() | ||
const course = data.course | ||
const data = useLoaderData<typeof loader>() | ||
const course = data.course | ||
|
||
console.log(course) | ||
|
||
return ( | ||
<div className="container mb-48 mt-36 flex flex-col items-center justify-center"> | ||
<div className="relative"> | ||
{course.title} by {course.instructor} | ||
<img | ||
src={course.image} | ||
alt={course.title} | ||
className="h-52 w-52 object-cover" | ||
/> | ||
<ul> | ||
{course.lessons.map(lesson => ( | ||
<li key={lesson.id}> | ||
<Link to={`/courses/${course.slug}/${lesson.slug}`}>{lesson.title}</Link> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
</div> | ||
) | ||
} | ||
return ( | ||
<div className="container mb-48 mt-36 flex flex-col items-center justify-center"> | ||
<div className="relative"> | ||
{course.title} by {course.instructor?.full_name} | ||
{course.image_url && ( | ||
<img | ||
src={course.image_url} | ||
alt={course.title} | ||
className="h-52 w-52 object-cover" | ||
/> | ||
)} | ||
<ul> | ||
{course.lessons.map(lesson => ( | ||
<li key={lesson.id}> | ||
<Link to={`/courses/${course.slug}/${lesson.slug}`}> | ||
{lesson.title} | ||
</Link> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
</div> | ||
) | ||
} |
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,51 +1,51 @@ | ||
import {useLoaderData} from "#node_modules/@remix-run/react"; | ||
import { useLoaderData } from '#node_modules/@remix-run/react' | ||
import { json } from '@remix-run/node' | ||
import {Link} from "@remix-run/react"; | ||
import {GeneralErrorBoundary} from "#app/components/error-boundary.tsx"; | ||
import {ErrorList} from "#app/components/forms.tsx"; | ||
import {courses} from "#app/data/playlists-short" | ||
import {cn, useDelayedIsPending} from "#app/utils/misc.tsx"; | ||
import { Link } from '@remix-run/react' | ||
import { GeneralErrorBoundary } from '#app/components/error-boundary.tsx' | ||
import { ErrorList } from '#app/components/forms.tsx' | ||
import { cn, useDelayedIsPending } from '#app/utils/misc.tsx' | ||
import { prisma } from '#app/utils/db.server.ts' | ||
|
||
export async function loader() { | ||
return json({ status: 'idle', courses } as const) | ||
const courses = await prisma.course.findMany() | ||
return json({ status: 'idle', courses } as const) | ||
} | ||
|
||
export default function Index() { | ||
const data = useLoaderData<typeof loader>() | ||
const isPending = useDelayedIsPending({ | ||
formMethod: 'GET', | ||
formAction: '/courses', | ||
}) | ||
const data = useLoaderData<typeof loader>() | ||
const isPending = useDelayedIsPending({ | ||
formMethod: 'GET', | ||
formAction: '/courses', | ||
}) | ||
|
||
|
||
return ( | ||
<div className="container mb-48 mt-36 flex flex-col items-center justify-center gap-6"> | ||
<main> | ||
{data.status === 'idle' ? ( | ||
data.courses.length ? ( | ||
<ul | ||
className={cn( | ||
'flex w-full flex-wrap items-center justify-center gap-4 delay-200', | ||
{ 'opacity-50': isPending }, | ||
)} | ||
> | ||
{data.courses.map(course => ( | ||
<li key={course.id}> | ||
<Link to={`/courses/${course.slug}`}>{course.title}</Link> | ||
</li> | ||
))} | ||
</ul> | ||
) : ( | ||
<p>No users found</p> | ||
) | ||
) : data.status === 'error' ? ( | ||
<ErrorList errors={['There was an error parsing the results']} /> | ||
) : null} | ||
</main> | ||
</div> | ||
) | ||
return ( | ||
<div className="container mb-48 mt-36 flex flex-col items-center justify-center gap-6"> | ||
<main> | ||
{data.status === 'idle' ? ( | ||
data.courses.length ? ( | ||
<ul | ||
className={cn( | ||
'flex w-full flex-wrap items-center justify-center gap-4 delay-200', | ||
{ 'opacity-50': isPending }, | ||
)} | ||
> | ||
{data.courses.map(course => ( | ||
<li key={course.id}> | ||
<Link to={`/courses/${course.slug}`}>{course.title}</Link> | ||
</li> | ||
))} | ||
</ul> | ||
) : ( | ||
<p>No users found</p> | ||
) | ||
) : data.status === 'error' ? ( | ||
<ErrorList errors={['There was an error parsing the results']} /> | ||
) : null} | ||
</main> | ||
</div> | ||
) | ||
} | ||
|
||
export function ErrorBoundary() { | ||
return <GeneralErrorBoundary /> | ||
} | ||
return <GeneralErrorBoundary /> | ||
} |
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,6 +1,6 @@ | ||
import { serve } from "inngest/remix"; | ||
import {inngestConfig} from "#app/inngest/inngest.config.ts"; | ||
import { serve } from 'inngest/remix' | ||
import { inngestConfig } from '#app/inngest/inngest.config.ts' | ||
|
||
const handler = serve(inngestConfig); | ||
const handler = serve(inngestConfig) | ||
|
||
export { handler as action, handler as loader }; | ||
export { handler as action, handler as loader } |
Oops, something went wrong.