Skip to content

Commit

Permalink
Merge pull request #333 from CheckMate-sookmyung/fix/#326-api
Browse files Browse the repository at this point in the history
#326 fix: api 수정
  • Loading branch information
misung-dev authored Sep 22, 2024
2 parents 50bb164 + b9244b8 commit f35b6d5
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 141 deletions.
2 changes: 1 addition & 1 deletion src/apis/attendance.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const getAttendanceList = async (eventId) => {

export const updateAttendanceList = async (eventId, body) => {
const { data } = await axiosInstance.put(
`/api/v1/attendance/list/${eventId}`,
`/api/v1/attendance/manage/${eventId}`,
body,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ const AttendanceStudentIdPage = () => {
setIsModalOpen(true);
} else {
const parsedStudent = {
studentName: data.studentName || data[0].studentName,
studentNumber: data.studentNumber || data[0].studentNumber,
studentInfoId: data.studentInfoId || data[0].studentInfoId,
major: data.major || data[0].major,
studentName: data.attendeeName,
studentNumber: data.studentNumber,
studentInfoId: data.attendeeId,
major: data.attendeeAffiliation,
};

setAttendanceCheck(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export default function DashboardAttendeePage() {
const handleDownload = async () => {
try {
const response = await axiosInstance.get(
`/api/v1/attendance/list/${eventId}`,
`/api/v1/attendancelist/${eventId}`,
{ responseType: 'blob' },
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Doughnut } from 'react-chartjs-2';
import { Chart as ChartJS, ArcElement, Tooltip, Legend } from 'chart.js';
import ChartDataLabels from 'chartjs-plugin-datalabels';
import { ATTENDEE_LIST } from './attendee';

ChartJS.register(ArcElement, Tooltip, Legend, ChartDataLabels);

const CompletionChart = ({ attendeeList }) => {
const totalStudents = attendeeList.eventRatioDetailResponseDtos.length;
const totalStudents = attendeeList.eventStatisticDetailResponseDtos.length;
const completedStudents =
ATTENDEE_LIST[0].eventRatioDetailResponseDtos.filter(
attendeeList.eventStatisticDetailResponseDtos.filter(
(student) => student.completion,
).length;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@ import { Sidebar, TopNavigation } from '@/components';
import MajorChart from './MajorChart';
import YearChart from './YearChart';
import CompletionChart from './CompletionChart';
import { ATTENDEE_LIST } from './attendee';
import { eventIDState } from '@/recoil/atoms/state';
import { getEventDetail, getEventStatistic } from '@/apis';
import { useQuery } from '@tanstack/react-query';
import { useRecoilValue } from 'recoil';

const DetailStatisticsPage = () => {
const eventId = useRecoilValue(eventIDState);
const startDate = ATTENDEE_LIST[0].eventDates[0];
const endDate =
ATTENDEE_LIST[0].eventDates[ATTENDEE_LIST[0].eventDates.length - 1];

const {
data: eventDetail,
Expand Down
19 changes: 9 additions & 10 deletions src/pages/DashboardPage/DashboardStatisticPage/MajorChart.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import { Doughnut } from 'react-chartjs-2';
import { Chart as ChartJS, ArcElement, Tooltip, Legend } from 'chart.js';
import ChartDataLabels from 'chartjs-plugin-datalabels';
import { ATTENDEE_LIST } from './attendee';

ChartJS.register(ArcElement, Tooltip, Legend, ChartDataLabels);

const MajorChart = ({ attendeeList }) => {
const majorAttendance = {};
let totalCompletedStudentsByMajor = 0;

attendeeList.eventRatioDetailResponseDtos.forEach((student) => {
// if (student.completion) {
totalCompletedStudentsByMajor++;
if (majorAttendance[student.studentMajor]) {
majorAttendance[student.studentMajor]++;
} else {
majorAttendance[student.studentMajor] = 1;
attendeeList.eventStatisticDetailResponseDtos.forEach((student) => {
if (student.completion) {
totalCompletedStudentsByMajor++;
if (majorAttendance[student.studentMajor]) {
majorAttendance[student.studentMajor]++;
} else {
majorAttendance[student.studentMajor] = 1;
}
}
// }
});

const sortedMajorAttendance = Object.entries(majorAttendance).sort(
Expand Down Expand Up @@ -91,7 +90,7 @@ const MajorChart = ({ attendeeList }) => {

if (label === '기타') {
const etcStudents =
ATTENDEE_LIST[0].eventRatioDetailResponseDtos.length -
attendeeList.eventRatioDetailResponseDtos.length -
totalCompletedStudentsByMajor;
return `${etcStudents}명`;
} else if (majorAttendance[label]) {
Expand Down
19 changes: 9 additions & 10 deletions src/pages/DashboardPage/DashboardStatisticPage/YearChart.jsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import { Doughnut } from 'react-chartjs-2';
import { Chart as ChartJS, ArcElement, Tooltip, Legend } from 'chart.js';
import ChartDataLabels from 'chartjs-plugin-datalabels';
import { ATTENDEE_LIST } from './attendee';

ChartJS.register(ArcElement, Tooltip, Legend, ChartDataLabels);

const YearChart = ({ attendeeList }) => {
const yearAttendance = {};
let totalCompletedStudentsByYear = 0;

attendeeList.eventRatioDetailResponseDtos.forEach((student) => {
// if (student.completion) {
totalCompletedStudentsByYear++;
const year = String(student.studentNumber).substring(0, 2);
if (yearAttendance[year]) {
yearAttendance[year]++;
} else {
yearAttendance[year] = 1;
attendeeList.eventStatisticDetailResponseDtos.forEach((student) => {
if (student.completion) {
totalCompletedStudentsByYear++;
const year = String(student.studentNumber).substring(0, 2);
if (yearAttendance[year]) {
yearAttendance[year]++;
} else {
yearAttendance[year] = 1;
}
}
// }
});

const sortedYearAttendance = Object.entries(yearAttendance).sort(
Expand Down
107 changes: 0 additions & 107 deletions src/pages/DashboardPage/DashboardStatisticPage/attendee.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/services/attendanceService/attendanceService.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getAttendanceCheck = async ({ eventId }, params) => {

export const postAttendanceSign = async ({ eventId, studentInfoId }, body) => {
await axiosInstance.post(
`/api/v1/attendance/sign/${eventId}/${studentInfoId}`,
`/api/v1/attendance/check/sign/${eventId}/${studentInfoId}`,
body,
{
headers: {
Expand Down

0 comments on commit f35b6d5

Please sign in to comment.