Skip to content

Commit eccfb75

Browse files
authored
Merge branch 'main' into build
2 parents a402742 + c3266c8 commit eccfb75

26 files changed

Lines changed: 1088 additions & 107 deletions

.DS_Store

0 Bytes
Binary file not shown.

.github/workflows/docker-image.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Docker CI
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v2
19+
20+
- name: Build and start services with Docker Compose (CI Mode)
21+
run: |
22+
CI=true COMMAND="npx serve -s build" docker compose up -d --build
23+
24+
- name: Check running containers
25+
run: docker ps -a
26+
27+
- name: Check for container failures
28+
run: |
29+
docker compose logs --tail=50
30+
if [ "$(docker compose ps --format '{{.State}}' | grep -c exited)" -gt 0 ]; then
31+
echo "A container has exited with an error. Failing the workflow."
32+
exit 1
33+
fi

my-app/package-lock.json

Lines changed: 198 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

my-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"ldrs": "^1.1.6",
1616
"mobx": "^6.13.7",
1717
"mobx-react-lite": "^4.1.0",
18+
"pdfjs-dist": "^5.1.91",
1819
"react": "^19.0.0",
1920
"react-dom": "^19.0.0",
2021
"react-router-dom": "^7.4.0",

my-app/src/assets/project_icon.png

69.8 KB
Loading

my-app/src/model.js

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
1-
// This model is representing our program logic.
2-
// A certain model is bound to a specific session.
3-
41
import { addCourse } from "../firebase";
52

63
export const model = {
74
user: undefined,
85
currentCourse: undefined,
9-
currentSearch: {},
6+
currentSearch: [],
107
courses: [],
8+
favourites: [],
119
isReady: false,
1210

1311
// sets the current user
1412
setUser(user) {
1513
if (!this.user)
1614
this.user = user;
1715
},
18-
16+
1917
// sets the currently selected course (detail view?) - could be component state
2018
setCurrentCourse(course){
2119
this.currentCourse = course;
2220
},
2321

2422
// keeps track of the current search / the associated promises.
25-
setCurrentSearch(search){
26-
this.currentSearch = search;
23+
setCurrentSearch(searchResults){
24+
this.currentSearch = searchResults;
2725
},
2826

2927
// sets the course array - for example after loading all courses from the DB
@@ -32,21 +30,23 @@ export const model = {
3230
},
3331

3432
// add a single course
35-
// addCourse(course){
36-
// this.courses = [...this.courses, course] // update local copy
37-
// addCourse(course); // update firebase
38-
// },
39-
4033
async addCourse(course) {
4134
try {
4235
await addCourse(course);
4336
this.courses = [...this.courses, course];
44-
console.log("Course added successfully.");
4537
} catch (error) {
4638
console.error("Error adding course:", error);
4739
}
4840
},
4941

42+
addFavourite(course) {
43+
this.favourites = [...this.favourites, course];
44+
},
45+
46+
removeFavourite(course) {
47+
this.favourites = (this.favourites || []).filter(fav => fav.code !== course.code);
48+
},
49+
5050
getCourse(courseID) {
5151
return this.courses.find(course => course.code === courseID);
5252
},
@@ -72,6 +72,14 @@ export const model = {
7272
};
7373
this.addCourse(course);
7474
});
75-
}
76-
}
75+
},
7776

77+
searchCourses(query) {
78+
const searchResults = this.courses.filter(course =>
79+
course.code.toLowerCase() === query.toLowerCase() ||
80+
course.name.toLowerCase().includes(query.toLowerCase()) ||
81+
course.description.toLowerCase().includes(query.toLowerCase())
82+
);
83+
this.setCurrentSearch(searchResults);
84+
}
85+
};

0 commit comments

Comments
 (0)