Skip to content

Commit 6b7d7ef

Browse files
authored
Bug fixes (#26)
* added loader * fixed popup hook
1 parent 2f7abfb commit 6b7d7ef

File tree

5 files changed

+13
-26
lines changed

5 files changed

+13
-26
lines changed

my-app/src/model.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,23 @@ export const model = {
88
favourites: [],
99
isReady: false,
1010

11-
// sets the current user
1211
setUser(user) {
1312
if (!this.user)
1413
this.user = user;
1514
},
1615

17-
// sets the currently selected course (detail view?) - could be component state
1816
setCurrentCourse(course){
1917
this.currentCourse = course;
2018
},
2119

22-
// keeps track of the current search / the associated promises.
2320
setCurrentSearch(searchResults){
2421
this.currentSearch = searchResults;
2522
},
2623

27-
// sets the course array - for example after loading all courses from the DB
2824
setCourses(courses){
2925
this.courses = courses;
3026
},
3127

32-
// add a single course
3328
async addCourse(course) {
3429
try {
3530
await addCourse(course);

my-app/src/pages/App.jsx

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,40 @@
1-
2-
import React from 'react';
3-
import { SidebarPresenter } from "../presenters/SidebarPresenter.jsx"
4-
import { SearchbarPresenter } from "../presenters/SearchbarPresenter.jsx"
1+
import React, { useState } from 'react';
2+
import { SidebarPresenter } from "../presenters/SidebarPresenter.jsx";
3+
import { SearchbarPresenter } from "../presenters/SearchbarPresenter.jsx";
54
import { ListViewPresenter } from '../presenters/ListViewPresenter.jsx';
5+
import CourseView from '../views/CourseView.jsx';
6+
import {model} from '/src/model.js';
7+
8+
function App() {
9+
const [isPopupOpen, setIsPopupOpen] = useState(false);
610

7-
function App(props) {
811
return (
912
<div className="flex h-screen w-screen">
10-
11-
<div className="flex-auto w-40% h-full bg-gradient-to-t from-[#4f3646] to-[#6747c0]">
12-
<SidebarPresenter model={props.model}/>
13+
<div className="flex-auto w-40% h-full bg-gradient-to-t from-[#4f3646] to-[#6747c0]">
14+
<SidebarPresenter model={model} />
1315
</div>
14-
1516
<div className="w-3/4 h-full flex flex-col">
1617
<div className="bg-blue-400 text-white">
17-
<SearchbarPresenter model={props.model} />
18+
<SearchbarPresenter model={model} />
1819
</div>
19-
2020
<div className="flex-auto border overflow-auto bg-[#121212]">
21-
<ListViewPresenter model={props.model} />
21+
<ListViewPresenter model={model} />
2222
</div>
23-
2423
<button
2524
onClick={() => setIsPopupOpen(true)}
2625
className="px-4 py-2 bg-blue-500 text-white"
2726
>
2827
open
2928
</button>
30-
31-
{/* Popup only overlays the black container */}
3229
{isPopupOpen && (
3330
<div
3431
className="fixed inset-0 bg-transparent flex justify-end"
3532
onClick={() => setIsPopupOpen(false)}
3633
>
37-
{/* Wider modal container */}
3834
<div
3935
className="bg-indigo-400/70 backdrop-blur-sm h-full w-3/4 flex flex-col overflow-auto"
4036
onClick={(e) => e.stopPropagation()}
4137
>
42-
{/* Container for CourseView which fills available space */}
4338
<div className="flex-1">
4439
<CourseView />
4540
</div>
@@ -57,4 +52,4 @@ function App(props) {
5752
);
5853
}
5954

60-
export default App;
55+
export default App;

my-app/src/views/ListView.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { useState } from 'react';
22
import { Quantum } from 'ldrs/react';
33
import 'ldrs/react/Quantum.css';
4-
import FavouritesDropdown from './Components/FavouriteDropdown.jsx';
54

65
function ListView(props) {
76
const coursesToDisplay = props.searchResults.length > 0 ? props.searchResults : props.courses;

my-app/src/views/SidebarView.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// src/views/SidebarView.jsx
21
import React from 'react';
32
import UploadField from "./Components/SideBarComponents/UploadField.jsx";
43
import ToggleField from "./Components/SideBarComponents/ToggleField.jsx";

my-app/src/views/TestAllCoursesView.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// dummy view, that returns text and a component state based counter.
21
export function TestAllCoursesView(props) {
32

43
return (

0 commit comments

Comments
 (0)