Skip to content

Commit

Permalink
Add: year parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
happycastle114 committed Nov 30, 2023
1 parent 9f8d8cb commit fd57889
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const PartyText = ({
if (variation === 1)
return (
<Paragraph>
<Text strong>{sgYear}</Text>지방선거에서는{" "}
<Text strong>{sgYear}</Text>총선에서는{" "}
<Text strong>{currentCandidate.length}</Text>개 정당에서 후보자가,{" "}
<Text strong>{currentElected.length}</Text>개 정당에서 당선자가{" "}
나왔어요.
Expand All @@ -101,8 +101,8 @@ export const PartyText = ({
<Text>
지난 선거에서는 <Text strong>{prevElected.length}</Text>{" "}
정당에서만 당선자가 나왔던 걸 생각하면, 이번엔 진짜 다양한 목소리가{" "}
들린다는 거죠! 여러분의 광역의회에서 다양성의 바람이 솔솔~ 역대급
변화가 느껴지지 않나요?
들린다는 거죠! 여러분의 국회에서 다양성의 바람이 솔솔~ 역대급 변화가
느껴지지 않나요?
</Text>
) : (
// 소수정당 당성자 수가 줄었다면 아래 텍스트 표시
Expand Down
12 changes: 8 additions & 4 deletions src/components/organisms/LocalCouncilReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ const LocalCouncilReport = ({
if (sgType === "candidate") {
axios
.get(
`localCouncil/template-data/${metroId}/${localId}?year=${sgYear}&year=${sgYear}&factor=party`,
`localCouncil/template-data/${metroId}/${localId}?year=${sgYear}&factor=party`,
)
.then(response => {
const data = response.data as PartyTextData;
Expand All @@ -212,7 +212,7 @@ const LocalCouncilReport = ({
});
axios
.get(
`localCouncil/template-data/${metroId}/${localId}?year=${sgYear}&year=${sgYear}&factor=gender`,
`localCouncil/template-data/${metroId}/${localId}?year=${sgYear}&factor=gender`,
)
.then(response => {
const data = response.data as GenderTextData;
Expand All @@ -232,7 +232,9 @@ const LocalCouncilReport = ({
});
} else {
axios
.get(`localCouncil/chart-data/${metroId}/${localId}?factor=party`)
.get(
`localCouncil/chart-data/${metroId}/${localId}?factor=party&year=${sgYear}`,
)
.then(response => {
const data = response.data.data as PartyPieChartDataAPIResponse;
const newPartyPieChartData: PieChartData[] = [];
Expand All @@ -248,7 +250,9 @@ const LocalCouncilReport = ({
throw new Error("네트워크 문제가 발생했습니다. 다시 시도해주세요.");
});
axios
.get(`localCouncil/chart-data/${metroId}/${localId}?factor=gender`)
.get(
`localCouncil/chart-data/${metroId}/${localId}?factor=gender&year=${sgYear}`,
)
.then(response => {
const data = response.data.data as GenderPieChartDataAPIResponse;
const newGenderPieChartData: PieChartData[] = [];
Expand Down
20 changes: 7 additions & 13 deletions src/components/organisms/MetroCouncilReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,29 +85,23 @@ const MetroCouncilReport = ({ metroName, metroMap, onLoaded }: Props) => {
// 백엔드로부터 텍스트 데이터를 가져옵니다.
const fetchTextData = () => {
axios
.get(
`metroCouncil/template-data/${metroId}?year=${sgYear}&year=${sgYear}&factor=age`,
)
.get(`metroCouncil/template-data/${metroId}?year=${sgYear}&factor=age`)
.then(response => {
setAgeTextData(response.data as AgeTextData);
})
.catch(() => {
throw new Error("네트워크 문제가 발생했습니다. 다시 시도해주세요.");
});
axios
.get(
`metroCouncil/template-data/${metroId}?year=${sgYear}&year=${sgYear}&factor=gender`,
)
.get(`metroCouncil/template-data/${metroId}?year=${sgYear}&factor=gender`)
.then(response => {
setGenderTextData(response.data as GenderTextData);
})
.catch(() => {
throw new Error("네트워크 문제가 발생했습니다. 다시 시도해주세요.");
});
axios
.get(
`metroCouncil/template-data/${metroId}?year=${sgYear}&year=${sgYear}&factor=party`,
)
.get(`metroCouncil/template-data/${metroId}?year=${sgYear}&factor=party`)
.then(response => {
setPartyTextData(response.data as PartyTextData);
})
Expand Down Expand Up @@ -185,7 +179,7 @@ const MetroCouncilReport = ({ metroName, metroMap, onLoaded }: Props) => {
if (sgType === "candidate") {
axios
.get(
`metroCouncil/template-data/${metroId}?year=${sgYear}&year=${sgYear}&factor=party`,
`metroCouncil/template-data/${metroId}?year=${sgYear}&factor=party`,
)
.then(response => {
const data = response.data as PartyTextData;
Expand All @@ -203,7 +197,7 @@ const MetroCouncilReport = ({ metroName, metroMap, onLoaded }: Props) => {
});
axios
.get(
`metroCouncil/template-data/${metroId}?year=${sgYear}&year=${sgYear}&factor=gender`,
`metroCouncil/template-data/${metroId}?year=${sgYear}&factor=gender`,
)
.then(response => {
const data = response.data as GenderTextData;
Expand All @@ -223,7 +217,7 @@ const MetroCouncilReport = ({ metroName, metroMap, onLoaded }: Props) => {
});
} else {
axios
.get(`metroCouncil/chart-data/${metroId}?factor=party`)
.get(`metroCouncil/chart-data/${metroId}?factor=party&year=${sgYear}`)
.then(response => {
const data = response.data.data as PartyPieChartDataAPIResponse;
const newPartyPieChartData: PieChartData[] = [];
Expand All @@ -239,7 +233,7 @@ const MetroCouncilReport = ({ metroName, metroMap, onLoaded }: Props) => {
throw new Error("네트워크 문제가 발생했습니다. 다시 시도해주세요.");
});
axios
.get(`metroCouncil/chart-data/${metroId}?factor=gender`)
.get(`metroCouncil/chart-data/${metroId}?factor=gender&year=${sgYear}`)
.then(response => {
const data = response.data.data as GenderPieChartDataAPIResponse;
const newGenderPieChartData: PieChartData[] = [];
Expand Down
6 changes: 3 additions & 3 deletions src/components/organisms/NationalCouncilReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,23 @@ const NationalCouncilReport = ({
// 백엔드로부터 텍스트 데이터를 가져옵니다.
const fetchTextData = () => {
axios
.get(`nationalCouncil/template-data?factor=age`)
.get(`nationalCouncil/template-data?factor=age&year=${sgYear}`)
.then(response => {
setAgeTextData(response.data as AgeTextData);
})
.catch(() => {
throw new Error("네트워크 문제가 발생했습니다. 다시 시도해주세요.");
});
axios
.get(`nationalCouncil/template-data?factor=gender`)
.get(`nationalCouncil/template-data?factor=gender&year=${sgYear}`)
.then(response => {
setGenderTextData(response.data as GenderTextData);
})
.catch(() => {
throw new Error("네트워크 문제가 발생했습니다. 다시 시도해주세요.");
});
axios
.get(`nationalCouncil/template-data?factor=party`)
.get(`nationalCouncil/template-data?factor=party&year=${sgYear}`)
.then(response => {
setPartyTextData(response.data as PartyTextData);
})
Expand Down

0 comments on commit fd57889

Please sign in to comment.