Skip to content

Commit

Permalink
Merge pull request #49 from NewWays-TechForImpactKAIST/44-국회의원-agetex…
Browse files Browse the repository at this point in the history
…t-fix
  • Loading branch information
withSang authored Nov 30, 2023
2 parents 3999b8a + 32776ae commit f6b936f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 39 deletions.
35 changes: 1 addition & 34 deletions src/components/molecules/NationalCouncilReportText/AgeText.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Typography } from "antd";
import { type MetroID } from "static/MapSVGData";

const { Paragraph, Text } = Typography;

Expand Down Expand Up @@ -28,16 +27,6 @@ export interface AgeTextData {
electedCount: number;
firstQuintile: number;
lastQuintile: number;
divArea: {
metroId: number;
firstQuintile: number;
lastQuintile: number;
};
uniArea: {
metroId: number;
firstQuintile: number;
lastQuintile: number;
};
};
}

Expand All @@ -46,14 +35,9 @@ interface Props {
variation?: AgeTextVariation;
/** text에 들어갈 데이터입니다. */
data?: AgeTextData;
getNameFromId: (id: number) => MetroID | undefined;
}

export const AgeText = ({
variation = 1,
data = undefined,
getNameFromId,
}: Props) => {
export const AgeText = ({ variation = 1, data = undefined }: Props) => {
if (!data) return <Paragraph>데이터를 불러오는 중입니다..</Paragraph>;

const {
Expand All @@ -72,23 +56,6 @@ export const AgeText = ({
<Text strong>{ageHistogramParagraph.lastQuintile}</Text>세 이상이에요.
<br />
<br />
참고로 다양성 지표 전국 1위는 전체 인원의 20%가{" "}
<Text strong>{ageHistogramParagraph.divArea.firstQuintile}</Text>{" "}
이하, 20%가{" "}
<Text strong>{ageHistogramParagraph.divArea.lastQuintile}</Text>{" "}
이상인{" "}
<Text strong>
{getNameFromId(ageHistogramParagraph.divArea.metroId)}
</Text>
, 전국 뒤에서 1위는 전체 인원의 20%가{" "}
<Text strong>{ageHistogramParagraph.uniArea.firstQuintile}</Text>
이하, 20%가{" "}
<Text strong>{ageHistogramParagraph.uniArea.lastQuintile}</Text>
이상인{" "}
<Text strong>
{getNameFromId(ageHistogramParagraph.uniArea.metroId)}
</Text>
예요.
</Paragraph>
);
return <Paragraph>존재하지 않는 템플릿입니다.</Paragraph>;
Expand Down
9 changes: 4 additions & 5 deletions src/components/organisms/NationalCouncilReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
type AgeTextData,
type GenderTextData,
type PartyTextData,
AgeText,
} from "@/components/molecules/NationalCouncilReportText";
import {
Histogram,
Expand Down Expand Up @@ -71,7 +72,7 @@ const NationalCouncilReport = ({
const nationalElectionYears = useNationalElectionYears();

const [ageHistogramData, setAgeHistogramData] = useState<BinData[]>();
const [, setAgeTextData] = useState<AgeTextData>();
const [ageTextData, setAgeTextData] = useState<AgeTextData>();

const [genderTextData, setGenderTextData] = useState<GenderTextData>();
const [sgType, setSgType] = useState<"elected" | "candidate">("elected");
Expand All @@ -87,8 +88,6 @@ const NationalCouncilReport = ({
useState<Map<string, string>>();
const [partyTextData, setPartyTextData] = useState<PartyTextData>();

// const getNameFromId = useGetMetroNameFromId(idMap);

// 백엔드로부터 텍스트 데이터를 가져옵니다.
const fetchTextData = () => {
axios
Expand Down Expand Up @@ -153,7 +152,7 @@ const NationalCouncilReport = ({
// 백엔드로부터 그래프 데이터를 가져옵니다.
const fetchGraphData = () => {
axios
.get(`age-hist?ageHistType=elected&year=${sgYear}&method=equal`)
.get(`age-hist/?ageHistType=elected&year=${sgYear}&method=equal`)
.then(response => {
const data = response.data as AgeHistogramDataAPIResponse;
const newAgeHistogramData: BinData[] = [];
Expand Down Expand Up @@ -270,7 +269,7 @@ const NationalCouncilReport = ({
</Flex>
<Title level={3}>연령 다양성</Title>
{ageHistogramData ? <Histogram data={ageHistogramData} /> : null}
{/* <AgeText data={ageTextData} getNameFromId={getNameFromId} /> */}
<AgeText data={ageTextData} />
<Title level={3}>성별 다양성</Title>
{genderPieChartData && genderPieChartColorMap ? (
<PieChart data={genderPieChartData} colorMap={genderPieChartColorMap} />
Expand Down

0 comments on commit f6b936f

Please sign in to comment.