Skip to content

Commit

Permalink
fix: url
Browse files Browse the repository at this point in the history
  • Loading branch information
huythai855 committed Aug 6, 2023
1 parent db0b73f commit 2d0e319
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
5 changes: 3 additions & 2 deletions frontend/src/pages/Home/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ function Home() {
const [student, setStudent] = useState({});
const [courses, setCourses] = useState([]);
const [lessons, setLessons] = useState([]);
const urlSearchParams = new URLSearchParams(window.location.search);
const userId = urlSearchParams.get('user_id');

const onChange = date => {
setDate(date);
};

useEffect(() => {
const urlSearchParams = new URLSearchParams(window.location.search);
const userId = urlSearchParams.get('user_id');

// console.log(userId);

axios.get(`http://10.10.143.92:3000/api/course?user_id=${userId}`)
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/pages/Learn/Learn.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,17 @@ function Learn() {
const [courses, setCourses] = useState([]);
const [lessons, setLessons] = useState([]);
const [recommend, setRecommend] = useState([]);
const urlSearchParams = new URLSearchParams(window.location.search);
const userId = urlSearchParams.get('user_id');
// console.log(userId);


const onChange = date => {
setDate(date);
};

useEffect(() => {
const urlSearchParams = new URLSearchParams(window.location.search);
const userId = urlSearchParams.get('user_id');
// console.log(userId);


axios.get(`http://10.10.143.92:3000/api/course?user_id=${userId}`)
.then(response => {
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/pages/Rankings/Rankings.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ function Rankings() {
const {id} = useParams();
let {uid} = useParams();
let rankingNumber = ["1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th"];
const urlSearchParams = new URLSearchParams(window.location.search);
const userId = urlSearchParams.get('user_id');


useEffect(() => {
const urlSearchParams = new URLSearchParams(window.location.search);
const userId = urlSearchParams.get('user_id');

let ord = urlSearchParams.get('ord');
if (ord === null){
ord = "current_level";
Expand Down

0 comments on commit 2d0e319

Please sign in to comment.