Skip to content

Commit

Permalink
Merge pull request #106 from Kusitms-29th-ASAP/fix/#103
Browse files Browse the repository at this point in the history
[Fix] 급식표 날짜 오류 및 서명 localStorage 오류 수정
  • Loading branch information
yyypearl authored May 31, 2024
2 parents 047d307 + 230a43a commit 45a2a85
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/app/mypage/profile/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const Profile = () => {

useEffect(() => {
if (typeof window !== "undefined") {
const storedSignImage = localStorage.getItem("signImage");
const storedSignImage = localStorage?.getItem("signImage");
setSignImage(storedSignImage);
}
}, []);
Expand Down
27 changes: 13 additions & 14 deletions src/app/mypage/profile/signature/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ const Signature = () => {
setIsSignatureEmpty(false);
};

useEffect(() => {
const dataURL = sigPad.current?.toDataURL("image/png");
if (dataURL) {
localStorage.setItem("signImage", dataURL);
}
}, []);

/* dataURL을 File로 반환하는 함수 */
const convertDataUrlToFile = () => {
const dataURL = sigPad.current?.toDataURL("image/png");
Expand All @@ -53,19 +46,25 @@ const Signature = () => {
return;
}

/* 서명 localStorage 저장 */
const dataURL = sigPad.current?.toDataURL("image/png");
if (dataURL) {
localStorage.setItem("signImage", dataURL);
}

/* signature 파일 */
const signImage = convertDataUrlToFile();

router.push("/mypage/profile");

/* signature 파일 post */
Axios.post(`엔드포인트`, signImage)
.then((response) => {
router.push("/mypage/profile");
})
.catch(() => {
console.error("Signature Post Error");
});
// Axios.post(`엔드포인트`, signImage)
// .then((response) => {
// router.push("/mypage/profile");
// })
// .catch(() => {
// console.error("Signature Post Error");
// });
};

return (
Expand Down
1 change: 0 additions & 1 deletion src/app/news/eduOffice/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export default EduOffice;

const Layout = styled.div`
width: 100%;
height: 100%;
overflow-x: hidden;
overflow-y: scroll;
display: flex;
Expand Down
1 change: 0 additions & 1 deletion src/app/news/school/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export default School;

const Layout = styled.div`
width: 100%;
height: 100%;
overflow-x: hidden;
overflow-y: scroll;
display: flex;
Expand Down
3 changes: 1 addition & 2 deletions src/app/school/notification/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use client";

import Tabbar from "@/components/common/Tabbar";
import Topbar from "@/components/common/Topbar";
import LastNotification from "@/components/school/notification/LastNotifications";
import TodayNotification from "@/components/school/notification/TodayNotification";
Expand All @@ -10,7 +9,7 @@ const Notification = () => {
return (
<>
<Container>
<Topbar text="학급알림장" icon={true} link="/school" />
<Topbar text="학급알림장" icon={true} />
</Container>
<TodayNotification />
<LastNotification />
Expand Down
3 changes: 3 additions & 0 deletions src/components/common/ListBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ const StyledListBox = styled.div<ListBoxProps>`
align-items: center;
padding: 12px 0px 12px 12px;
&.none {
background: ${theme.colors.white};
}
&.mint {
border: 1px solid ${theme.colors.b300};
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/common/ListNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ const StyledListNumber = styled.div`
const Number = styled.div`
display: inline-flex;
width: 24px;
height: 25px;
padding: 4px 8px;
justify-content: center;
align-items: center;
border-radius: 8px;
background: rgba(255, 135, 0, 0.15);
background: #ffedd9;
color: ${theme.colors.primary700};
${(props) => props.theme.fonts.caption1_b}
`;
Expand Down
60 changes: 32 additions & 28 deletions src/components/home/MealTablePopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,42 +40,46 @@ const MealTablePopup = ({ onClose }: { onClose: () => void }) => {
const [mealTable, setMealTable] = useState<MealTable[]>([]);
/* 주간별 급식 데이터 */
const [weeklyMealTable, setWeeklyMealTable] = useState<MealTable[][]>([]);
/* 매달 시작 요일 */
const [dayOfWeek, setDayOfWeek] = useState<string>("");

let remainingDays = 0;

useEffect(() => {
Axios.get(`/api/v1/menus/month`)
.then((response) => {
const mealTableData: MealTable[] = response.data.menus;
setMealTable(mealTableData);

const dayNames = ["월", "화", "수", "목", "금", "토", "일"];
const date = new Date(mealTableData[0].date);
const dayOfWeek = dayNames[date.getDay()];
setDayOfWeek(dayOfWeek);

// 첫 번째 주차의 데이터 개수 결정
if (dayOfWeek === "월") {
remainingDays = 5;
} else if (dayOfWeek === "화") {
remainingDays = 4;
} else if (dayOfWeek === "수") {
remainingDays = 3;
} else if (dayOfWeek === "목") {
remainingDays = 2;
} else if (dayOfWeek === "금") {
remainingDays = 1;
}

const weeklyMealTable: MealTable[][] = [];
if (remainingDays > 0) {
weeklyMealTable.push(mealTableData.slice(0, remainingDays));
}

for (let i = remainingDays; i < mealTableData.length; i += 5) {
weeklyMealTable.push(mealTableData.slice(i, i + 5));
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 (
(currentWeekStartDay !== null &&
mealDay >= currentWeekStartDay &&
mealDay < currentWeekStartDay + 5 &&
mealDayOfWeek !== 0) || // 일요일 제외
currentWeek.length === 0
) {
currentWeek.push(meal);
} else {
weeklyMealTable.push(currentWeek);
currentWeek = [meal];
currentWeekStartDay = mealDay;
}
});

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

setWeeklyMealTable(weeklyMealTable);
Expand Down
12 changes: 10 additions & 2 deletions src/components/news/SummaryCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ const SummaryCard = (props: AnnouncementsProps) => {

{summaryType === "detail" &&
highlight?.summaries.map((data, index) => (
<StyledListNumber key={index} index={index + 1} text={data} />
<Background key={index}>
<StyledListNumber key={index} index={index + 1} text={data} />
</Background>
))}
</Sentence>
</StyledCard>
Expand Down Expand Up @@ -216,7 +218,7 @@ const StyledKeyword = styled.div`
align-items: center;
gap: 10px;
border-radius: 6px;
background: rgba(255, 135, 0, 0.15);
background: #ffedd9;
color: ${theme.colors.primary500};
text-align: center;
${(props) => props.theme.fonts.caption1_b};
Expand All @@ -240,3 +242,9 @@ const StyledListNumber = styled(ListNumber)`
background: ${theme.colors.b100};
}
`;

const Background = styled.div`
padding: 8px 12px;
border-radius: 10px;
background: ${theme.colors.b100};
`;

0 comments on commit 45a2a85

Please sign in to comment.