Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38b689ffcf | ||
|
|
d5da8f22b2 | ||
|
|
d1fc101a26 | ||
|
|
ee08f35178 |
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,3 +1,8 @@
|
||||
node_modules/
|
||||
*/node_modules/
|
||||
*/build/
|
||||
|
||||
**/node_modules/
|
||||
**/build/
|
||||
.DS_Store
|
||||
.env
|
||||
File diff suppressed because one or more lines are too long
@ -116,7 +116,6 @@ app.use(
|
||||
|
||||
app.use(
|
||||
'/api/courses',
|
||||
passport.authenticate('jwt', { session: false }),
|
||||
coursesRoutes,
|
||||
);
|
||||
|
||||
|
||||
1
frontend/json/runtimeError.json
Normal file
1
frontend/json/runtimeError.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
||||
@ -67,6 +67,11 @@ export const webPagesNavBar = [
|
||||
href: '/about',
|
||||
label: 'about',
|
||||
},
|
||||
{
|
||||
href: '/web_pages/cources',
|
||||
label: 'Cources',
|
||||
},
|
||||
|
||||
];
|
||||
|
||||
export default menuNavBar;
|
||||
|
||||
60
frontend/src/pages/web_pages/cources.tsx
Normal file
60
frontend/src/pages/web_pages/cources.tsx
Normal file
@ -0,0 +1,60 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import type { ReactElement } from 'react';
|
||||
import Head from 'next/head';
|
||||
import LayoutGuest from '../../layouts/Guest';
|
||||
import WebSiteHeader from '../../components/WebPageComponents/Header';
|
||||
import WebSiteFooter from '../../components/WebPageComponents/Footer';
|
||||
import CardBox from '../../components/CardBox';
|
||||
|
||||
interface Course {
|
||||
id: number;
|
||||
title: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export default function CourcesPage() {
|
||||
const [courses, setCourses] = useState<Course[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
fetch('/api/courses')
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
const list = Array.isArray(data)
|
||||
? data
|
||||
: Array.isArray(data.rows)
|
||||
? data.rows
|
||||
: [];
|
||||
setCourses(list);
|
||||
})
|
||||
.catch(err => console.error(err));
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>Cources</title>
|
||||
</Head>
|
||||
<WebSiteHeader projectName="test i18" />
|
||||
<main className="flex-grow bg-white p-8">
|
||||
<h1 className="text-2xl font-bold mb-6">Cources</h1>
|
||||
{courses.length > 0 ? (
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-6">
|
||||
{courses.map(course => (
|
||||
<CardBox key={course.id} className="p-4">
|
||||
<h2 className="text-xl font-semibold">{course.title}</h2>
|
||||
<p className="mt-2 text-gray-600">{course.description}</p>
|
||||
</CardBox>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<p>No courses found.</p>
|
||||
)}
|
||||
</main>
|
||||
<WebSiteFooter projectName="test i18" />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
CourcesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
return <LayoutGuest>{page}</LayoutGuest>;
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user