Skip to content

Commit

Permalink
Merge branch 'code100x:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
vijaysingh2219 authored Aug 30, 2024
2 parents 71b3486 + 390d08c commit b2727dc
Show file tree
Hide file tree
Showing 41 changed files with 638 additions and 233 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@ yarn-error.log*
*.tsbuildinfo
next-env.d.ts

*storybook.log
*storybook.log

# ignore yarn.lock & package-lock
yarn.lock
package-lock.json
7 changes: 6 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@
npm run format:fix
npm run lint:fix

git add .
git add .

if [ -f "yarn.lock" ] || [ -f "package-lock.json" ]; then
echo "Error: yarn.lock or package-lock.json is present. Please remove them before committing."
exit 1
fi
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts"
},
"scripts": {
"preinstall": "npx only-allow pnpm",
"postinstall": "prisma generate",
"dev": "next dev",
"build": "next build",
Expand Down
250 changes: 250 additions & 0 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions src/app/admin/content/[courseId]/[...moduleId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@ export default async function UpdateCourseContent({
const rest = params.moduleId;
const course = await getCourse(parseInt(courseId, 10));
const fullCourseContent = await getFullCourseContent(parseInt(courseId, 10));

const courseContent = findContentById(
fullCourseContent,
rest.map((x) => parseInt(x, 10)),
);
const contentType =
courseContent?.length === 1 ? courseContent[0]?.type : 'folder';
const contentType = courseContent?.folder
? 'folder'
: courseContent?.value?.type;

if (contentType === 'video') {
return (
<div className="mx-auto max-w-screen-xl justify-between p-4 text-white">
{/* @ts-ignore */}
<UpdateVideoClient content={courseContent[0]} />
<UpdateVideoClient content={courseContent.value} />
</div>
);
}
Expand All @@ -48,11 +50,12 @@ export default async function UpdateCourseContent({
/>
<AdminCourseContent
rest={rest}
//@ts-ignore
courseContent={courseContent?.map((x: any) => ({
// @ts-ignore
courseContent={courseContent?.value?.map((x: any) => ({
title: x?.title || '',
image: x?.thumbnail || '',
id: x?.id || 0,
createdAt: x?.createdAt,
}))}
courseId={parseInt(courseId, 10)}
/>
Expand Down
10 changes: 6 additions & 4 deletions src/app/admin/content/[courseId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ export default async function UpdateCourseContent({
fullCourseContent,
rest.map((x) => parseInt(x, 10)),
);
const contentType =
courseContent?.length === 1 ? courseContent[0]?.type : 'folder';
const contentType = courseContent?.folder
? 'folder'
: courseContent?.value.type;

if (contentType === 'video') {
return (
Expand Down Expand Up @@ -45,11 +46,12 @@ export default async function UpdateCourseContent({
/>
<AdminCourseContent
rest={rest}
//@ts-ignore
courseContent={courseContent?.map((x: any) => ({
// @ts-ignore
courseContent={courseContent?.value.map((x: any) => ({
title: x?.title || '',
image: x?.thumbnail || '',
id: x?.id || 0,
createdAt: x?.createdAt,
}))}
courseId={parseInt(courseId, 10)}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/search/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { cache } from '@/db/Cache';
import db from '@/db';
import { CourseContent } from '@prisma/client';
import Fuse from 'fuse.js';
import { NextResponse } from 'next/server';
import { NextRequest, NextResponse } from 'next/server';

export type TSearchedVideos = {
id: number;
Expand All @@ -21,7 +21,7 @@ const fuzzySearch = (videos: TSearchedVideos[], searchQuery: string) => {
return searchedVideos.map((video) => video.item);
};

export async function GET(request: Request) {
export async function GET(request: NextRequest) {
const { searchParams } = new URL(request.url);
const searchQuery = searchParams.get('q');

Expand Down
3 changes: 0 additions & 3 deletions src/app/courses/[courseId]/[...moduleId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,12 @@ export default async function Course({
fullCourseContent,
rest.map((x) => parseInt(x, 10)),
);
const contentType =
courseContent?.length === 1 ? courseContent[0]?.type : 'folder';
const nextContent = null; //await getNextVideo(Number(rest[rest.length - 1]))

return (
<CourseView
rest={rest}
course={course}
contentType={contentType}
nextContent={nextContent}
courseContent={courseContent}
fullCourseContent={fullCourseContent}
Expand Down
4 changes: 1 addition & 3 deletions src/app/courses/[courseId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ export default async function Course({
const fullCourseContent = await getFullCourseContent(parseInt(courseId, 10));

const courseContent = findContentById(fullCourseContent, []);
const contentType =
courseContent?.length === 1 ? courseContent[0]?.type : 'folder';

const nextContent = null;

return (
<CourseView
rest={[]}
course={course}
contentType={contentType}
nextContent={nextContent}
courseContent={courseContent}
fullCourseContent={fullCourseContent}
Expand Down
2 changes: 1 addition & 1 deletion src/app/questions/[slug]/@question/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const SingleQuestionPage = async ({
<Link href="/questions" className="p-4">
Go Back
</Link>
<div className="mt-3 flex items-center justify-center px-3">
<div className="mt-3 items-center justify-center px-3">
{question && (
<PostCard
post={question}
Expand Down
2 changes: 1 addition & 1 deletion src/app/questions/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export default async function Home({
<NewPostDialog />
<div className="mx-auto md:mx-[15%] md:p-10">
<div className="flex flex-col items-center p-4 dark:text-white">
<div className="flex">
<div className="mb-5 flex">
<Search />
<div className="px-3">
<DropdownMenu>
Expand Down
6 changes: 3 additions & 3 deletions src/components/BreadCrumbComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '@/components/ui/breadcrumb';
import { FullCourseContent } from '@/db/course';
import Link from 'next/link';
import { useMemo } from 'react';
import { Fragment, useMemo } from 'react';

export default function BreadCrumbComponent({
rest,
Expand Down Expand Up @@ -83,7 +83,7 @@ export default function BreadCrumbComponent({
finalRouteArray = [...rest];
}
return (
<>
<Fragment key={breadcrumb.id}>
{index !== array.length - 1 ? (
<>
<BreadcrumbItem>
Expand All @@ -105,7 +105,7 @@ export default function BreadCrumbComponent({
</BreadcrumbPage>
</BreadcrumbItem>
)}
</>
</Fragment>
);
})}
</BreadcrumbList>
Expand Down
16 changes: 9 additions & 7 deletions src/components/CardComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import bgImage from '../../public/Content-Cover.png';

const CardComponent = ({
title,
Expand All @@ -14,12 +14,14 @@ const CardComponent = ({
const [, secondPart] = title.split(' | ');

return (
<div
className="h-[224px] bg-cover bg-center bg-no-repeat px-4 py-4 sm:h-[224px] sm:px-5 sm:py-4 md:h-[180px] lg:h-[224px]"
style={{ backgroundImage: "url('/Content-Cover.png')" }}
>
<div className="flex h-full flex-col items-center justify-center">
<p className="sm:text-md flex-wrap whitespace-normal text-wrap rounded-full border-black bg-gray-400/20 px-3 py-1 text-center text-xs capitalize text-white sm:text-lg">
<div className="flex min-h-[22vh] items-center overflow-clip rounded-t-md">
<img
src={bgImage.src}
alt="background"
className="absolute h-full w-full rounded-t-md"
/>
<div className="relative flex h-full flex-grow flex-col items-center justify-center">
<p className="md:text-md flex-wrap whitespace-normal text-wrap rounded-full border-black bg-gray-400/20 px-3 py-1 text-center text-xs capitalize text-white sm:text-lg lg:text-sm">
100xdevs
</p>
<p className="sm:text-md flex-wrap whitespace-normal text-wrap border-black text-center text-xs capitalize text-white sm:text-lg">
Expand Down
42 changes: 22 additions & 20 deletions src/components/ContentCard.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { CheckCircle2, Play } from 'lucide-react';
import { CheckCircle2 } from 'lucide-react';
import { Bookmark } from '@prisma/client';
import BookmarkButton from './bookmark/BookmarkButton';
import { formatTime } from '@/lib/utils';
import VideoThumbnail from './videothumbnail';
import CardComponent from './CardComponent';
import DonutChart from './DonutChart';

export const ContentCard = ({
title,
Expand All @@ -15,6 +16,7 @@ export const ContentCard = ({
bookmark,
contentId,
contentDuration,
createdAt,
}: {
type: 'folder' | 'video' | 'notion';
contentId?: number;
Expand All @@ -27,26 +29,26 @@ export const ContentCard = ({
hoverExpand?: boolean;
bookmark?: Bookmark | null;
contentDuration?: number;
createdAt: Date;
}) => {
// let image ;
// image = ""
const formattedDate = createdAt?.toLocaleDateString('en-GB', {
day: '2-digit',
month: 'long',
year: 'numeric',
});

return (
<div
onClick={onClick}
className={`relative cursor-pointer rounded-2xl border border-gray-700/50 duration-200 ease-in group${hoverExpand ? ' ' : ''} `}
className={`relative min-h-fit cursor-pointer rounded-2xl border border-gray-700/50 duration-200 ease-in group${hoverExpand ? ' ' : ''} `}
>
{markAsCompleted && (
<div className="absolute right-2 top-2 z-10">
<CheckCircle2 color="green" size={30} fill="lightgreen" />
</div>
)}
{type === 'video' && (
<div className="text-blue-900g absolute bottom-12 right-2 z-10 rounded-md bg-zinc-900 p-1 px-2 font-semibold text-white">
{contentDuration && formatTime(contentDuration)}
</div>
)}
{type !== 'video' && (
<div className="relative overflow-hidden rounded-md">
<div className="relative overflow-hidden">
<CardComponent
title={title}
contentDuration={contentDuration && formatTime(contentDuration)}
Expand All @@ -63,14 +65,12 @@ export const ContentCard = ({
</div>
)}
{type === 'video' && (
<div className="relative overflow-hidden rounded-md">
<div className="relative overflow-hidden">
<VideoThumbnail
title={title}
contentId={contentId ?? 0}
contentDuration={contentDuration && formatTime(contentDuration)}
imageUrl=""
// imageUrl={
// 'https://d2szwvl7yo497w.cloudfront.net/courseThumbnails/video.png'
// }
/>
</div>
)}
Expand All @@ -89,15 +89,17 @@ export const ContentCard = ({
<div className="flex items-center justify-between p-4">
<div className="space-y-2">
<h3 className="text-bold text-lg tracking-normal">{title}</h3>
<h4 className="text-bold text-sm tracking-normal text-[#64748B]">
Posted on: 10 Aug 2024
<h4 className="text-bold text-xs tracking-normal text-[#64748B]">
Posted on: {formattedDate}
</h4>
</div>
<div className="hidden rounded-full border border-gray-700/60 p-4 lg:block">
<div className="rounded-full border border-[#64748b] p-2">
<Play size={15} color="#64748b" />
{type === 'video' && videoProgressPercent && (
<div className="flex items-center justify-center">
<DonutChart
percentage={parseInt(videoProgressPercent.toFixed(0), 10)}
/>
</div>
</div>
)}
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/CourseCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const CourseCard = ({
const router = useRouter();
return (
<div
className={`flex max-w-sm flex-col border border-gray-200 bg-white ${roundedClassName} w-full shadow transition-colors duration-300 ease-in-out hover:bg-[#E2E8F0] dark:border dark:border-gray-700/50 dark:bg-[#020817] hover:dark:bg-[#1E293B]`}
className={`flex max-w-sm cursor-pointer flex-col border border-gray-200 bg-white ${roundedClassName} w-full shadow transition-colors duration-300 ease-in-out hover:bg-[#E2E8F0] dark:border dark:border-gray-700/50 dark:bg-[#020817] hover:dark:bg-[#1E293B]`}
onClick={onClick}
>
<img
Expand Down
Loading

0 comments on commit b2727dc

Please sign in to comment.