Skip to content

Commit

Permalink
Fix: search filter and pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
klam-12 committed Apr 6, 2024
1 parent 0510f5a commit a5a4096
Show file tree
Hide file tree
Showing 7 changed files with 412 additions and 235 deletions.
63 changes: 19 additions & 44 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions src/components/SearchBar/SearchBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const SearchBar = () =>{
const navigate = useNavigate();
const [searchWord,setSearchWord] = useState(null)

// buggg

const handleSubmit = (e) => {
e.preventDefault();
setSearchWord(searchInputRef.current.value.trim());
Expand All @@ -29,8 +29,6 @@ export const SearchBar = () =>{
window.location.reload();
}

console.log("Navigate")
// Navigate to the route with constructed URL
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/page/homepage/homepage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ export default function HomePage(){
const { isAuthenticated } = useAuth()
const [username, setUsername] = useState(localStorage.getItem("fullname") || null);

const {data: fetchCourses, isSuccess, isLoading, isError } = useQuery(
const {data: fetchCourses, isSuccess, isLoading, isError,refetch } = useQuery(
"fetch10Courses",
() => callApiGetCoursesPagination(1,10),
{
onSuccess: (data) => {
// console.log(data)
console.log(data)
setCourses(data?.metadata?.results)
setInstructors(data?.metadata?.instructors)
setLoading(false)
Expand All @@ -32,11 +32,12 @@ export default function HomePage(){
}
)

// localStorage.getItem('fullname')
useEffect(() => {
console.log(isAuthenticated)
if(!isAuthenticated) {
setUsername(null)
}
refetch()
}, [isAuthenticated])

return(
Expand Down
4 changes: 4 additions & 0 deletions src/page/homepage/homepageStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { useRef } from "react";
import {Button} from "../../components/Button/Button.js"
import {Chip} from "../../components/Chip/Chip.js"
import {CustomRating} from "../../components/Rating/Rating.js"
import { useNavigate } from "react-router-dom";


export const StyleH1 = styled.h1`
margin-left: 25px;
Expand Down Expand Up @@ -165,11 +167,13 @@ export const CourseItem = (props ) => {
const priceCourse = props.price || "0"
const imgCourse = props.image || "/imgs/courses/web.jpg"
const chipLabel = props.chipLabel || false
const navigate = useNavigate()

const formattedPrice = priceCourse.toLocaleString(navigator.language, { minimumFractionDigits: 0 })

const handleCourseClick = () =>{
console.log("Click course");
navigate('/view-lecture');
}

return(
Expand Down
Loading

0 comments on commit a5a4096

Please sign in to comment.