Skip to content

Commit

Permalink
Feature/#189 마일스톤 api 토큰 전달 (#190)
Browse files Browse the repository at this point in the history
* feat: 마일스톤 api에 토큰넣어서 호출하도록 수정

#189

* feat: config 폴더 최신화

#189
  • Loading branch information
llddang authored Sep 12, 2024
1 parent 8fa002d commit 0188d9e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion backend/src/main/resources/config
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import { MilestoneHistorySortCriteria, SortDirection } from '@/types/milestone';
import MilestoneHistoryStatusLabel from '../MilestoneHistoryStatusLabel';

const MilestoneHistorySection = async () => {
// TODO - auth에 학번 정보 저장하도록 하기
const auth = getAuthFromCookie();

let milestoneHistoriesOfStudent;
try {
milestoneHistoriesOfStudent = await getMilestoneHistoriesOfStudent(
auth.token,
auth.id,
undefined,
undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const MilestoneHistoryTable = async ({ pageNumber }: MilestoneHistoryTableProp)
let milestoneHistories;
try {
milestoneHistories = await getMilestoneHistoriesOfStudent(
auth.token,
auth.id,
undefined,
undefined,
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/app/components/Milestone/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import { MilestoneOverviewScore } from '@/types/milestone';
import { initialMilestoneOverview } from '@/data/milestone';

const getMilestoneScores = async (studentId: number) => {
const auth = getAuthFromCookie();
const startDate = DateTime.now().minus({ years: 1 }).toFormat('yyyy-MM-dd');
const endDate = DateTime.now().toFormat('yyyy-MM-dd');
try {
const milestoneScores = await getMyMilestoneHistory(studentId, startDate, endDate);
const milestoneScores = await getMyMilestoneHistory(auth.token, studentId, startDate, endDate);
return milestoneScores;
} catch (err) {
// TODO: server api error handling
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/lib/api/server.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { mockHackathonPrize } from '@/mocks/hackathon';
import { removeEmptyField } from '../utils/utils';

export async function getMilestoneHistoriesOfStudent(
token: string,
memberId: number,
startDate: string | undefined = undefined,
endDate: string | undefined = undefined,
Expand All @@ -26,6 +27,7 @@ export async function getMilestoneHistoriesOfStudent(
) {
return await server
.get<MilestoneHistoryOfStudentPageableDto>(`/milestones/histories/members/${memberId}`, {
headers: { Authorization: token },
params: removeEmptyField({
start_date: startDate,
end_date: endDate,
Expand Down Expand Up @@ -79,9 +81,10 @@ export async function getValidationStudentId(studentId: string) {
.catch((err) => Promise.reject(err));
}

export async function getMyMilestoneHistory(studentId: number, startDate: string, endDate: string) {
export async function getMyMilestoneHistory(token: string, studentId: number, startDate: string, endDate: string) {
const response = await server
.get<MilestoneScoreDto[]>(`/milestones/histories/scores/members/${studentId}`, {
headers: { Authorization: token },
params: removeEmptyField({
start_date: startDate,
end_date: endDate,
Expand Down

0 comments on commit 0188d9e

Please sign in to comment.