diff --git a/.env.example b/.env.example index 7f47ba24..4afeb922 100644 --- a/.env.example +++ b/.env.example @@ -24,6 +24,9 @@ GITHUB_SECRET= NEXT_PUBLIC_DISCORD_WEBHOOK_URL = JOB_BOARD_AUTH_SECRET= +FETCHER_URL= +VIZOLV_SECRET= +DISCORD_REDIRECT_URI= COHORT3_DISCORD_ACCESS_KEY = COHORT3_DISCORD_ACCESS_SECRET = diff --git a/next.config.js b/next.config.js index 82b78e87..7256b669 100644 --- a/next.config.js +++ b/next.config.js @@ -1,3 +1,5 @@ +// @ts-check + /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, diff --git a/package.json b/package.json index f26aa8e5..08196f17 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "@radix-ui/react-slot": "^1.1.0", "@radix-ui/react-switch": "^1.1.0", "@radix-ui/react-tooltip": "^1.0.7", + "@t3-oss/env-nextjs": "^0.11.1", "@tabler/icons-react": "^3.14.0", "@types/bcrypt": "^5.0.2", "@types/jsonwebtoken": "^9.0.5", diff --git a/src/actions/comment/index.ts b/src/actions/comment/index.ts index df5a95fa..6728e5b2 100644 --- a/src/actions/comment/index.ts +++ b/src/actions/comment/index.ts @@ -26,6 +26,7 @@ import { createSafeAction } from '@/lib/create-safe-action'; import { CommentType, Prisma } from '@prisma/client'; import { revalidatePath } from 'next/cache'; import { ROLES } from '../types'; +import { env } from '@/env'; export const getComments = async ( q: Prisma.CommentFindManyArgs, @@ -273,7 +274,7 @@ const updateCommentHandler = async ( content: content ?? existingComment.content, approved: existingComment.approved, }; - if (adminPassword === process.env.ADMIN_SECRET) { + if (adminPassword === env.ADMIN_SECRET) { updObj.approved = approved ?? existingComment.approved; } const updatedComment = await prisma.comment.update({ @@ -295,7 +296,7 @@ const approveIntroCommentHandler = async ( const { content_comment_ids, approved, adminPassword, currentPath } = data; if (adminPassword) { - if (adminPassword !== process.env.ADMIN_SECRET) { + if (adminPassword !== env.ADMIN_SECRET) { return { error: 'Unauthorized' }; } } else if (!session || !session.user || session.user.role !== ROLES.ADMIN) { diff --git a/src/actions/event-actions/index.ts b/src/actions/event-actions/index.ts index 45597822..818abb97 100644 --- a/src/actions/event-actions/index.ts +++ b/src/actions/event-actions/index.ts @@ -1,6 +1,7 @@ 'use server'; import prisma from '@/db'; +import { env } from '@/env'; import { authOptions } from '@/lib/auth'; import { Event } from '@prisma/client'; import { getServerSession } from 'next-auth'; @@ -9,7 +10,7 @@ import { revalidatePath } from 'next/cache'; async function isAdmin() { const session = await getServerSession(authOptions); - const adminEmails = process.env.ADMINS?.split(',') || []; + const adminEmails = env.ADMINS?.split(',') || []; return session?.user?.email && adminEmails.includes(session.user.email); } diff --git a/src/actions/refresh-db/index.ts b/src/actions/refresh-db/index.ts index 3404999e..81fa7bbd 100644 --- a/src/actions/refresh-db/index.ts +++ b/src/actions/refresh-db/index.ts @@ -2,6 +2,7 @@ import db from '@/db'; import { cache } from '@/db/Cache'; import { getAllCourses } from '@/db/course'; +import { env } from '@/env'; import { authOptions } from '@/lib/auth'; import { APPX_COURSE_IDS } from '@/utiles/appx'; import { checkUserEmailForPurchase } from '@/utiles/appx-check-mail'; @@ -28,7 +29,7 @@ export async function refreshDbInternal(userId?: string, email?: string) { }; } - if (process.env.LOCAL_CMS_PROVIDER) { + if (env.LOCAL_CMS_PROVIDER) { return { error: false, message: 'Refetched Courses' }; } diff --git a/src/actions/user/index.ts b/src/actions/user/index.ts index d85f351e..d8568ffb 100644 --- a/src/actions/user/index.ts +++ b/src/actions/user/index.ts @@ -1,8 +1,9 @@ 'use server'; import db from '@/db'; +import { env } from '@/env'; export const logoutUser = async (email: string, adminPassword: string) => { - if (adminPassword !== process.env.ADMIN_SECRET) { + if (adminPassword !== env.ADMIN_SECRET) { return { error: 'Unauthorized' }; } diff --git a/src/app/admin/add-course/page.tsx b/src/app/admin/add-course/page.tsx index dace4c5a..d4b6d560 100644 --- a/src/app/admin/add-course/page.tsx +++ b/src/app/admin/add-course/page.tsx @@ -1,12 +1,7 @@ 'use client'; import { Button } from '@/components/ui/button'; -import { - Card, - CardContent, - CardHeader, - CardTitle, -} from '@/components/ui/card'; +import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Form, FormControl, @@ -29,7 +24,7 @@ import { AccordionContent, AccordionItem, AccordionTrigger, -} from "@/components/ui/accordion"; +} from '@/components/ui/accordion'; import { Cuboid, PackagePlus } from 'lucide-react'; import { FaDiscord } from 'react-icons/fa'; @@ -86,24 +81,32 @@ export default function Courses() { return (
- -
+
-

View Content

+

View Content

- + - -
- New course + +
+ + New course
-
-
Create new course for 100xdevs community and let user explore new courses
-
- +
+
+ Create new course for 100xdevs community and let user explore + new courses +
+
+ {/* Create a new course */} Fill in the course details below @@ -121,7 +124,11 @@ export default function Courses() { Title - + @@ -134,7 +141,11 @@ export default function Courses() { Image url - + @@ -144,11 +155,12 @@ export default function Courses() { control={form.control} name="description" render={({ field }: { field: any }) => ( - + Description