Skip to content

Commit ebca38f

Browse files
Merge pull request #85 from sparcs-kaist/feat/MainPage
Redesign Meal Component
2 parents 03b799e + 52d7fcd commit ebca38f

File tree

14 files changed

+50
-486
lines changed

14 files changed

+50
-486
lines changed

src/app/page.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
"use client";
22

33
import SearchBar from "@/components/searchBar";
4-
import ArticleList from "@/components/ArticleList/ArticleList";
54
import { useEffect, useState } from "react";
65
import Link from "next/link";
76
import Image from "next/image";
87
import { ResponsePost } from "@/lib/types/post";
98
import { fetchTopArticles, fetchArticles } from "@/lib/api/board";
109
import { HotPreview, RecentPreview } from "@/containers/ArticleList";
10+
import MealData from "@/components/Meal/MealData";
1111

1212
export default function Home() {
1313
const [inputValue, setInputValue] = useState("");
14-
const [hotArticles, setHotArticles] = useState<ResponsePost[]>([]);
15-
const [recentArticles, setRecentArticles] = useState<ResponsePost[]>([]);
14+
const [, setHotArticles] = useState<ResponsePost[]>([]);
15+
const [, setRecentArticles] = useState<ResponsePost[]>([]);
1616
const [loading, setLoading] = useState(true);
1717

1818
useEffect(() => {
@@ -38,7 +38,7 @@ export default function Home() {
3838
<div className="max-w-[1200px] mx-auto">
3939
<div className="absolute top-0 left-0 w-full h-[400px] bg-gradient-to-b from-[#FFEDD2] to-[#FFFFFF] -z-10"></div>
4040

41-
<div className="h-[220px] w-full flex justify-center items-center">
41+
<div className="h-[110px] w-full flex justify-center items-start pt-4">
4242
<SearchBar
4343
value={inputValue}
4444
onChange={(e: React.ChangeEvent<HTMLInputElement>) => setInputValue(e.target.value)}
@@ -51,23 +51,26 @@ export default function Home() {
5151
<div className="text-center py-8">데이터를 불러오는 중...</div>
5252
) : (
5353
<>
54-
{/* HOT 게시물 */}
54+
{/* 지금 핫한 글 */}
5555
<section className="w-full max-w-[550px] p-4 bg-white rounded-lg shadow-sm">
5656
<Link href="/board/hot" className="flex items-center space-x-2 mb-[10px]">
57-
<h2 className="text-[20px] font-semibold">HOT 게시물</h2>
57+
<h2 className="text-[20px] font-semibold">🔥지금 핫한 글</h2>
5858
<Image src="/Right_Chevron.svg" width={8.84} height={15} alt="arrow" />
5959
</Link>
6060
<HotPreview/>
6161
</section>
6262

63-
{/* 최신 글 */}
63+
{/* 방금 올라온 글 */}
6464
<section className="w-full max-w-[550px] p-4 bg-white rounded-lg shadow-sm">
6565
<Link href="/board/recent" className="flex items-center space-x-2 mb-[10px]">
66-
<h2 className="text-[20px] font-semibold">최신</h2>
66+
<h2 className="text-[20px] font-semibold">🕑방금 올라온</h2>
6767
<Image src="/Right_Chevron.svg" width={8.84} height={15} alt="arrow" />
6868
</Link>
6969
<RecentPreview />
7070
</section>
71+
72+
{/* 오늘의 식단 */}
73+
<MealData />
7174
</>
7275
)}
7376
</main>

src/components/NewAraExtends/Floating/AllergyFilter.tsx renamed to src/components/Meal/AllergyFilter.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ const AllergyFilter = ({ onAllergyChange, initialAllergies = initialAllergens }:
2929

3030
return (
3131
<div className="flex flex-col max-w-[366px] w-[306px] h-auto items-start gap-3 p-4 bg-white rounded-2xl shadow-md">
32-
<h2 className="text-[14px] font-semibold text-black font-inter">
33-
알러지 필터
34-
</h2>
32+
<div className="flex items-center gap-1">
33+
<h2 className="text-[16px] font-semibold text-black font-inter">
34+
⚙️ 알러지 필터
35+
</h2>
36+
</div>
3537
<div className="flex flex-wrap gap-2 w-full">
3638
{allergens.map((allergen) => (
3739
<button
@@ -40,12 +42,13 @@ const AllergyFilter = ({ onAllergyChange, initialAllergies = initialAllergens }:
4042
className={`
4143
flex items-center justify-start
4244
min-w-[85px] h-[24px] px-[8px] py-1
43-
rounded-[12px] text-[12px] font-semibold
45+
rounded-[12px] text-[12px] font-medium
4446
cursor-pointer transition-colors font-inter
47+
bg-white text-black border
4548
${
4649
allergen.selected
47-
? "bg-[#ed3a3a] text-white"
48-
: "bg-white text-[#c62626] border border-[#c62626]"
50+
? "border-ara_red_bright border-2 text-ara_red_dark"
51+
: "border-ara_gray_bright"
4952
}
5053
`}
5154
>

src/components/NewAraExtends/Floating/MealData.tsx renamed to src/components/Meal/MealData.tsx

Lines changed: 15 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import CourseMenuList from "./CourseMenuList";
77
import CafeteriaMenuList from "./CafeteriaMenuList";
88
import { Allergen, Restaurant, CafeteriaMenuItem, CafeteriaRestaurant } from './types';
99
import { initialAllergens } from "./utils";
10+
import { fetchCafeteriaMenu, fetchCourseMenu } from '@/lib/api/meal';
1011

1112
// 식당 ID를 API 응답의 키값으로 매핑
1213
type RestaurantKey = 'fclt' | 'west' | 'east1' | 'east2' | 'emp';
@@ -26,37 +27,6 @@ const mealTimeMap: { [key: string]: "morning_menu" | "lunch_menu" | "dinner_menu
2627
"저녁": "dinner_menu"
2728
};
2829

29-
//functions for api
30-
const fetchCourseMenu = async (date: string) => {
31-
try {
32-
const response = await fetch(`http://localhost:8000/api/meals/${date}/course_menu/`);
33-
if (response.status === 404) {
34-
throw new Error("해당 날짜의 식단 정보가 없습니다.");
35-
}
36-
if (!response.ok) {
37-
throw new Error("메뉴를 불러오는데 실패했습니다.");
38-
}
39-
return await response.json();
40-
} catch (error) {
41-
throw error;
42-
}
43-
};
44-
45-
const fetchCafeteriaMenu = async (date: string) => {
46-
try {
47-
const response = await fetch(`http://localhost:8000/api/meals/${date}/cafeteria_menu/`);
48-
if (response.status === 404) {
49-
throw new Error("해당 날짜의 식단 정보가 없습니다.");
50-
}
51-
if (!response.ok) {
52-
throw new Error("메뉴를 불러오는데 실패했습니다.");
53-
}
54-
return await response.json();
55-
} catch (error) {
56-
throw error;
57-
}
58-
};
59-
6030
export default function MealData() {
6131
// 알러지 필터 상태
6232
const [isAllergyFilterVisible, setIsAllergyFilterVisible] = useState(false);
@@ -90,7 +60,6 @@ export default function MealData() {
9060
const handlePreviousDay = () => {
9161
const prevDate = new Date(currentDate.getTime() - 24 * 60 * 60 * 1000);
9262
setCurrentDate(prevDate);
93-
9463
};
9564

9665
// 드롭다운 상태 관리
@@ -156,7 +125,6 @@ export default function MealData() {
156125
return menuData;
157126
};
158127

159-
160128
//API response 관련 state
161129
const [courseMenuData, setCourseMenuData] = useState<Record<string, Restaurant> | null>(null);
162130
const [cafeteriaMenuData, setCafeteriaMenuData] = useState<Record<string, CafeteriaRestaurant> | null>(null);
@@ -171,7 +139,7 @@ export default function MealData() {
171139
return `${year}-${month}-${day}`;
172140
};
173141

174-
//Load Menu Data
142+
//Load Menu Data - 수정된 부분: 이미 import된 API 함수 사용
175143
const fetchMenuData = useCallback(async (date: Date) => {
176144
setIsLoading(true);
177145
setError(null);
@@ -217,20 +185,13 @@ export default function MealData() {
217185
<div className="flex flex-col gap-0">
218186
<div className="flex items-center justify-between">
219187
{/* 오늘의 학식 */}
220-
<h2 className="font-semibold text-black text-[20px] mr-[8px]">오늘의 학식</h2>
188+
<h2 className="font-semibold text-black text-[20px] mr-[8px]">🍽️ 오늘의 학식</h2>
221189
{/* 알러지 필터 */}
222190
<button
223-
className="flex items-center gap-1 text-[#c62626] text-xs font-semibold mr-auto"
191+
className="flex items-center gap-1 text-gray-500 text-xs font-semibold mr-auto"
224192
onClick={() => setIsAllergyFilterVisible((prev) => !prev)}
225193
>
226-
<span>알러지 필터</span>
227-
<Image
228-
src="/NewAraExtendIcons/filter-icon.svg"
229-
alt="Filter Icon"
230-
width={16}
231-
height={16}
232-
className="w-4 h-4"
233-
/>
194+
<span>알러지 필터 ⚙️</span>
234195
</button>
235196
{isAllergyFilterVisible && (
236197
<div className="absolute top-0 right-full mr-2">
@@ -246,7 +207,7 @@ export default function MealData() {
246207
className="flex items-center gap-[5px]"
247208
onClick={toggleDropdown}
248209
>
249-
<span className="font-semibold text-[#c62626] text-[16px]">
210+
<span className="font-semibold text-black text-[16px]">
250211
{selectedRestaurant}
251212
</span>
252213
<Image
@@ -305,11 +266,15 @@ export default function MealData() {
305266
<button
306267
key={meal}
307268
onClick={() => setSelectedMeal(meal)}
308-
className={`px-3 h-[21px] rounded-[10px] text-[12px] font-semibold ${
309-
meal === selectedMeal
310-
? "bg-[#ed3a3a] text-white"
311-
: "bg-white border border-gray-300 text-black"
312-
}`}
269+
className={`
270+
px-3 h-[21px] rounded-[10px] text-[12px] font-semibold
271+
bg-white text-black border
272+
${
273+
meal === selectedMeal
274+
? "border-ara_red_bright border-1 text-ara_red_dark"
275+
: "border-gray-200"
276+
}
277+
`}
313278
>
314279
{meal}
315280
</button>

src/components/NewAraExtends/Floating/RestaurantSelection.tsx renamed to src/components/Meal/RestaurantSelection.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ export default function RestaurantSelection({
3434
}}
3535
className={`
3636
w-[84px] h-5 rounded-xl px-5 py-[3px]
37-
font-semibold text-[11px] whitespace-nowrap
37+
font-medium text-[11px] whitespace-nowrap
3838
transition-colors duration-200
3939
flex items-center justify-center
40+
bg-white text-black border
4041
${
4142
selectedLocation === restaurant
42-
? "bg-[#ed3a3a] text-white"
43-
: "bg-white text-[#c62626] border-[0.75px] border-solid border-[#c62626]"
43+
? "border-ara_red_bright border-2 text-ara_red_dark"
44+
: "border-ara_gray_bright"
4445
}
4546
`}
4647
>

src/components/NewAraExtends/AraBetaSidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState } from "react";
22
import AraBetaButton from "./Floating/AraBetaButton";
33
import MealExtensionButton from "./Floating/MealExtensionButton";
4-
import MealData from "./Floating/MealData";
4+
import MealData from "@/components/Meal/MealData";
55

66
/*
77
지금 프론트가 마이그레이션 중인 관계로 컴포넌트를 Next로 만들되되,

0 commit comments

Comments
 (0)