Skip to content

Commit

Permalink
Merge pull request #131 from Kusitms-29th-ASAP/fix/#130
Browse files Browse the repository at this point in the history
[Fix] 급식표 데이터 변경
  • Loading branch information
yyypearl authored Aug 13, 2024
2 parents 727b7ce + 17b1838 commit 26f45d2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 31 deletions.
9 changes: 1 addition & 8 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,7 @@ export default withPlugins(
},
},
],
[
typescript,
{
typescriptLoaderOptions: {
transpileOnly: false,
},
},
],
[typescript],
],
nextConfig
);
2 changes: 1 addition & 1 deletion src/apis/auth/postKakaoToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export async function postKakaoToken(
): Promise<PostKakaoTokenResponse> {
try {
const response = await axios.post<PostKakaoTokenResponse>(
"https://api.ncp.simproject.kr/api/v1/auth/login/KAKAO",
"https://api.schoolpoint.site/api/v1/auth/login/KAKAO",
{
accessToken: accessToken,
}
Expand Down
2 changes: 1 addition & 1 deletion src/apis/school/getShcool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface GetSchoolResponse {

export async function getSchool(keyword: string): Promise<GetSchoolResponse> {
const response = await axios.get(
`https://api.ncp.simproject.kr/api/v1/schools?keyword=${keyword}`
`https://api.schoolpoint.site/api/v1/schools?keyword=${keyword}`
);
return response.data;
}
Expand Down
2 changes: 1 addition & 1 deletion src/apis/user/postUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import axios from "axios";
export async function postUser(user: PostUserRequest): Promise<TokenResponse> {
try {
const response = await axios.post<TokenResponse>(
"https://api.ncp.simproject.kr/api/v1/users",
"https://api.schoolpoint.site/api/v1/users",
user
);
return response.data;
Expand Down
34 changes: 14 additions & 20 deletions src/components/home/MealTablePopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const MealTablePopup = ({ onClose }: { onClose: () => void }) => {
.then((response) => {
const mealTableData: MealTable[] = response.data.menus;
setMealTable(mealTableData);

console.log(mealTableData);
/* 월 계산 */
let month = mealTableData[0].date.slice(5, 7);
if (month[0] === "0") {
Expand All @@ -58,38 +58,32 @@ const MealTablePopup = ({ onClose }: { onClose: () => void }) => {
const weeklyMealTable: MealTable[][] = [];
let currentWeek: MealTable[] = [];
/* 주차별 시작일 */
let currentWeekStartDay: number | null = null;

mealTableData.forEach((meal) => {
const mealDate = new Date(meal.date);
const mealDay = mealDate.getDate();
const mealDayOfWeek = mealDate.getDay();

/* 이번 주차 시작일 */
if (currentWeekStartDay === null) {
currentWeekStartDay = mealDay;
/* 주차별로 월요일에 새로운 주차를 시작 */
if (mealDayOfWeek === 1 && currentWeek.length > 0) {
weeklyMealTable.push(currentWeek);
currentWeek = [];
}

/* 이번 주차에 있는 날짜인지 확인 */
currentWeek.push(meal);

/* 마지막 날에 현재 주차 데이터를 추가 */
const lastMealDate = new Date(
mealTableData[mealTableData.length - 1].date
);
if (
(currentWeekStartDay !== null &&
mealDay >= currentWeekStartDay &&
mealDay < currentWeekStartDay + 5 &&
mealDayOfWeek !== 0) || // 일요일 제외
currentWeek.length === 0
mealDayOfWeek === 5 ||
mealDate.getTime() === lastMealDate.getTime()
) {
currentWeek.push(meal);
} else {
weeklyMealTable.push(currentWeek);
currentWeek = [meal];
currentWeekStartDay = mealDay;
currentWeek = [];
}
});

if (currentWeek.length > 0) {
weeklyMealTable.push(currentWeek);
}

setWeeklyMealTable(weeklyMealTable);
})
.catch(() => {
Expand Down

0 comments on commit 26f45d2

Please sign in to comment.