diff --git a/package.json b/package.json index 6c61a9138..96748dc64 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "db:reset": "prisma migrate reset", "prepare": "husky install", "studio": "prisma studio", - "studio:docker" : "open http://localhost:5555 || start http://localhost:5555" + "studio:docker": "open http://localhost:5555 || start http://localhost:5555" }, "dependencies": { "@auth/prisma-adapter": "^1.0.6", diff --git a/prisma/migrate.ts b/prisma/migrate.ts index 748532595..e69de29bb 100644 --- a/prisma/migrate.ts +++ b/prisma/migrate.ts @@ -1,85 +0,0 @@ -import db from '../src/db/index'; -import fs from 'fs'; -import csv from 'csv-parser'; -import path from 'path'; // Function to convert CSV to JSON and return as an object - -function csvToJson(csvFilePath: string): Promise { - return new Promise((resolve, reject) => { - const results: any[] = []; - - fs.createReadStream(csvFilePath) - .pipe(csv()) - .on('data', (data) => results.push(data)) - .on('end', () => { - resolve(results); - }) - .on('error', (error) => reject(error)); - }); -} - -async function main() { - const data: { - email: string; - phone: string; - id: string; - courseId: string; - name: string; - }[] = await csvToJson(path.join(__dirname, './d.csv')); - const allUsers = await db.user.findMany({}); - const usersMap: any = {}; - allUsers.map((user) => { - if (user && user.id) { - usersMap[user.email || ''] = user?.id; - } - }); - - //@ts-ignore - const updatedData: { - courseId: number; - email: string; - phone: string; - id: string; - name: string; - }[] = data - .map((x) => ({ - email: x.email, - phone: x.phone, - name: x.name, - id: usersMap[x.email] || usersMap[x.phone] || null, - // eslint-disable-next-line - courseId: x.name.includes('1-100') - ? 2 - : // eslint-disable-next-line - x.name.includes('0-100') - ? 3 - : // eslint-disable-next-line - x.name.includes('0-1') - ? 1 - : null, - })) - .filter((x) => x.courseId && x.id); - - console.log(updatedData); - for (let i = 0; i < updatedData.length; i++) { - const itemsToPush: { - userId: string; - courseId: number; - }[] = []; - - for (let j = 0; j <= 100 && i + j < updatedData.length; j++) { - //@ts-ignore - itemsToPush.push({ - userId: updatedData[i + j].id, - courseId: updatedData[i + j].courseId, - }); - } - i += 100; - console.log(itemsToPush); - await db.userPurchases.createMany({ - data: itemsToPush, - skipDuplicates: true, // Skip 'Bobo' - }); - } -} - -main(); diff --git a/src/actions/refresh-db/index.ts b/src/actions/refresh-db/index.ts index ab947099a..ae8210fdd 100644 --- a/src/actions/refresh-db/index.ts +++ b/src/actions/refresh-db/index.ts @@ -55,8 +55,8 @@ export const refreshDb: RefreshDbFn = async () => { .filter((x) => !x.openToEveryone) .map(async (course) => { const courseId = course.appxCourseId.toString(); - - const data = await checkUserEmailForPurchase(email, courseId); + + const data = await checkUserEmailForPurchase(email, courseId); if (data.data === '1') { responses.push(course); diff --git a/src/app/courses/[courseId]/layout.tsx b/src/app/courses/[courseId]/layout.tsx index 6ccf49319..9f0aaa76e 100644 --- a/src/app/courses/[courseId]/layout.tsx +++ b/src/app/courses/[courseId]/layout.tsx @@ -37,6 +37,7 @@ const Layout = async ({ }: { params: { courseId: string }; searchParams: QueryParams; + children: any; }) => { const courseId = params.courseId; const hasAccess = await checkAccess(courseId); diff --git a/src/components/comment/CommentInputForm.tsx b/src/components/comment/CommentInputForm.tsx index 769ea1485..2c8eeabda 100644 --- a/src/components/comment/CommentInputForm.tsx +++ b/src/components/comment/CommentInputForm.tsx @@ -42,7 +42,7 @@ const CommentInputForm = ({ useEffect(() => { const handleKeyDown = (event: KeyboardEvent) => { // Prevent shortcuts from affecting video when typing in the textarea - event.stopPropagation(); + event.stopPropagation(); }; textareaRef.current?.addEventListener('keydown', handleKeyDown);