Skip to content

Commit

Permalink
fix: useParams
Browse files Browse the repository at this point in the history
  • Loading branch information
saa00123 committed Sep 8, 2023
1 parent 2c1f963 commit bfe2c66
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
18 changes: 9 additions & 9 deletions front/src/pages/project/Project.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useState, useEffect } from 'react';
import axios from 'axios';
import { NavLink } from 'react-router-dom';
import moveImg from '../../images/login.png';
import Menu from '../../components/frames/Side/Sidebar';
import ProjectPopup from '../../components/Popup/ProjectPopup';
import React, { useState, useEffect } from "react";
import axios from "axios";
import { NavLink } from "react-router-dom";
import moveImg from "../../images/login.png";
import Menu from "../../components/frames/Side/Sidebar";
import ProjectPopup from "../../components/Popup/ProjectPopup";

interface Manager {
id: number;
Expand Down Expand Up @@ -33,7 +33,7 @@ function Project() {
useEffect(() => {
async function fetchData(): Promise<void> {
try {
const response = await axios.get<ProjectData[]>('projects?team-id=1');
const response = await axios.get<ProjectData[]>("projects?team-id=1");
setProjectData(response.data);
console.log(response.data);
} catch (error) {
Expand All @@ -44,7 +44,7 @@ function Project() {
}, []);

const activeStyle = {
background: '#D8F1FF',
background: "#D8F1FF",
};

return (
Expand All @@ -67,7 +67,7 @@ function Project() {
<NavLink
className='flex justify-center items-center ml-auto w-[60px] h-[40px] rounded-[10px] bg-[#4A4A4A] text-white'
style={({ isActive }) => (isActive ? activeStyle : {})}
to='/sprint'
to={`/sprint/${projectData.id}`}
>
<img
className='w-[24px] h-[24px]'
Expand Down
9 changes: 6 additions & 3 deletions front/src/pages/sprint/Sprint.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useEffect } from "react";
import axios from "axios";
import { NavLink } from "react-router-dom";
import { NavLink, useParams } from "react-router-dom";
import moveImg from "../../images/login.png";
import Menu from "../../components/frames/Side/Sidebar";
import MiniChart from "../../images/minichart.png";
Expand Down Expand Up @@ -30,19 +30,22 @@ interface SprintData {

function Sprint() {
const [sprintData, setSprintData] = useState<SprintData[]>();
const { projectId } = useParams<{ projectId: string }>();

useEffect(() => {
async function fetchData(): Promise<void> {
try {
const response = await axios.get<SprintData[]>("sprints?project-id=2");
const response = await axios.get<SprintData[]>(
`sprints?project-id=${projectId}`
);
setSprintData(response.data);
console.log(response.data, response.status);
} catch (error) {
console.log(error);
}
}
fetchData();
}, []);
}, [projectId]);

const activeStyle = {
background: "#D8F1FF",
Expand Down

0 comments on commit bfe2c66

Please sign in to comment.