diff --git a/backend/src/db/seeders/20231127130745-sample-data.js b/backend/src/db/seeders/20231127130745-sample-data.js index 5edbaf1..0e5a8db 100644 --- a/backend/src/db/seeders/20231127130745-sample-data.js +++ b/backend/src/db/seeders/20231127130745-sample-data.js @@ -129,97 +129,188 @@ const CoursesData = [ + + + + "description": "Deep dive into hooks, context, performance optimization, and patterns.", + + + + + + - "status": "archived", + + "status": "published", + + + + + + + // type code here for "relation_one" field + + + + + + + "category": "Web Development", + + + + + + + "price": 79.99, + + + + + + + "duration": 360, + + + + + + + // type code here for "images" field + + + + + + + "published_at": new Date('2025-12-05T09:00:00Z'), + + + + + + + "enrollment_count": 64, + + + + }, + + { + + + + + "title": "UX for Developers", + + + + + + + "description": "Design thinking and practical UX techniques for building better interfaces.", + + + + + + - "status": "archived", + + "status": "published", + + + + + + - // type code here for "relation_one" field - + + // type code here for "relation_one" field diff --git a/backend/src/index.js b/backend/src/index.js index d0a4630..2d51171 100644 --- a/backend/src/index.js +++ b/backend/src/index.js @@ -15,6 +15,7 @@ const authRoutes = require('./routes/auth'); const fileRoutes = require('./routes/file'); const searchRoutes = require('./routes/search'); const pexelsRoutes = require('./routes/pexels'); +const publicRoutes = require('./routes/public'); const openaiRoutes = require('./routes/openai'); @@ -87,6 +88,7 @@ require('./auth/auth'); app.use(bodyParser.json()); app.use('/api/auth', authRoutes); +app.use('/api/public', publicRoutes); app.use('/api/file', fileRoutes); app.use('/api/pexels', pexelsRoutes); app.enable('trust proxy'); diff --git a/backend/src/routes/public.js b/backend/src/routes/public.js new file mode 100644 index 0000000..e256399 --- /dev/null +++ b/backend/src/routes/public.js @@ -0,0 +1,17 @@ +const express = require('express'); +const router = express.Router(); +const CoursesDBApi = require('../db/api/courses'); + +router.get('/courses', async (req, res) => { + try { + const publishedCourses = await CoursesDBApi.findAll({ + where: { status: 'published' }, + }); + res.json(publishedCourses); + } catch (error) { + console.error(error); + res.status(500).send('Internal Server Error'); + } +}); + +module.exports = router; \ No newline at end of file diff --git a/frontend/src/components/Courses/PublicCourseCard.tsx b/frontend/src/components/Courses/PublicCourseCard.tsx new file mode 100644 index 0000000..4a7c493 --- /dev/null +++ b/frontend/src/components/Courses/PublicCourseCard.tsx @@ -0,0 +1,24 @@ +import React from 'react'; +import ImageField from '../ImageField'; +import Link from 'next/link'; + +type Props = { + course: any; +}; + +const PublicCourseCard = ({ course }: Props) => { + return ( +
{course.title}
+ +