Skip to content

Commit 90ada8e

Browse files
authored
Merge pull request #59 from wafflestudio/haram
주별뷰 이슈 수정
2 parents 768530a + 588a400 commit 90ada8e

17 files changed

Lines changed: 827 additions & 782 deletions

src/contexts/SearchContext.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ interface SearchContextType {
2020
setSize: Dispatch<SetStateAction<number>>;
2121
fetchSearchResult: (q: string, page: number, size: number) => Promise<void>;
2222
searchResults: SearchResult | null;
23-
emptySearchResults: ()=>void;
23+
emptySearchResults: () => void;
2424
// fetchSearchResult: (q: string, page: number, size: number) => Promise<void>;
2525
searchLoading: boolean;
2626
}
@@ -54,7 +54,7 @@ export const SearchProvider = ({ children }: { children: ReactNode }) => {
5454

5555
const emptySearchResults = () => {
5656
setSearchResults(null);
57-
}
57+
};
5858

5959
// useEffect(() => {
6060
// fetchSearchResult(query, page, size);

src/pages/MyPage.tsx

Lines changed: 59 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ import Modal from "@/widgets/Modal";
1515
import Loading from "@/widgets/Loading";
1616
import defaultProfile from "/assets/defaultProfile.png";
1717

18-
const ProfileCard = ({ onClickInterest } : { onClickInterest: () => void }) => {
18+
const ProfileCard = ({ onClickInterest }: { onClickInterest: () => void }) => {
1919
const { user, updateUsername, setProfileImg } = useAuth();
2020
const { interestCategories } = useUserData();
2121
const { timetables } = useTimetable();
2222
const [profilePreviewUrl, setProfilePreviewUrl] = useState<string>(
23-
(user?.profileImageUrl && user.profileImageUrl !== "")
24-
? user.profileImageUrl
25-
: defaultProfile
26-
);
23+
user?.profileImageUrl && user.profileImageUrl !== ""
24+
? user.profileImageUrl
25+
: defaultProfile,
26+
);
2727
const [imgFile, setImgFile] = useState<File | null>(null);
2828
const [, setIsDefaultProfile] = useState<boolean>(false);
2929
const [username, setUsername] = useState<string>(
@@ -58,13 +58,12 @@ const ProfileCard = ({ onClickInterest } : { onClickInterest: () => void }) => {
5858
};
5959

6060
useEffect(() => {
61-
if (user?.profileImageUrl && user.profileImageUrl.trim() !== "") {
62-
setProfilePreviewUrl(user.profileImageUrl);
63-
} else {
64-
setProfilePreviewUrl(defaultProfile);
65-
}
66-
}, [user?.profileImageUrl]);
67-
61+
if (user?.profileImageUrl && user.profileImageUrl.trim() !== "") {
62+
setProfilePreviewUrl(user.profileImageUrl);
63+
} else {
64+
setProfilePreviewUrl(defaultProfile);
65+
}
66+
}, [user?.profileImageUrl]);
6867
// profile image preview url cleanup (cleanup callback is executed before next effect / component unmount)
6968
useEffect(() => {
7069
return () => {
@@ -137,25 +136,33 @@ const ProfileCard = ({ onClickInterest } : { onClickInterest: () => void }) => {
137136
/>
138137
)}
139138
</div>
140-
<button className={styles.preferenceCol} type='button' onClick={onClickInterest}>
139+
<button
140+
className={styles.preferenceCol}
141+
type="button"
142+
onClick={onClickInterest}
143+
>
141144
<div className={styles.preferenceHeader}>
142-
<FaStar size={24} color="#828282" style={{ marginRight: 12 }}/>
145+
<FaStar size={24} color="#828282" style={{ marginRight: 12 }} />
143146
<span>행사 보기 우선순위</span>
144147
</div>
145-
{(interestCategories && interestCategories.length > 0) ? (
148+
{interestCategories && interestCategories.length > 0 ? (
146149
<div>
147150
<ul className={styles.preferenceChips}>
148-
{interestCategories.map((cat, idx) => (
149-
<li className={`${styles.preferenceChip} ${cat.groupId === 3 && styles.category} ${cat.groupId === 2 && styles.organization}`} key={cat.id}>
150-
{`${idx+1}순위: ${cat.name}`}
151-
</li>
152-
))}
153-
</ul>
154-
</div>
151+
{interestCategories.map((cat, idx) => (
152+
<li
153+
className={`${styles.preferenceChip} ${cat.groupId === 3 && styles.category} ${cat.groupId === 2 && styles.organization}`}
154+
key={cat.id}
155+
>
156+
{`${idx + 1}순위: ${cat.name}`}
157+
</li>
158+
))}
159+
</ul>
160+
</div>
155161
) : (
156-
<span className={styles.notYetText}>클릭해서 우선순위로 확인할 행사를 설정해보세요!</span>
157-
)
158-
}
162+
<span className={styles.notYetText}>
163+
클릭해서 우선순위로 확인할 행사를 설정해보세요!
164+
</span>
165+
)}
159166
</button>
160167
<button
161168
type="button"
@@ -189,35 +196,34 @@ const MyPage = () => {
189196
return (
190197
<div className={styles.main}>
191198
<Navigationbar />
192-
{isLoading ?
193-
(
194-
<Loading />
195-
)
196-
: (
197-
isEditingInterest ? (
198-
<Onboarding isEditing={true} onFinishEdit={()=>setIsEditingInterest(false)} />
199-
) : (
200-
user ? (
201-
<div className={styles.mypageContainer}>
202-
<ProfileCard onClickInterest={() => setIsEditingInterest(()=>true)}/>
203-
<div className={styles.widgetsWrapper}>
204-
<BookmarkWidget />
205-
<MemoWidget />
206-
</div>
207-
</div>
208-
) : (
209-
<div className={styles.notFound}>
210-
<Modal
211-
content="마이페이지 이용을 위해서는 로그인을 해주세요."
212-
leftText="로그인"
213-
rightText="회원가입"
214-
onLeftClick={()=>navigate('/auth/login')}
215-
onRightClick={()=>navigate('/auth/signup')}
216-
onClose={null}
217-
/>
199+
{isLoading ? (
200+
<Loading />
201+
) : isEditingInterest ? (
202+
<Onboarding
203+
isEditing={true}
204+
onFinishEdit={() => setIsEditingInterest(false)}
205+
/>
206+
) : user ? (
207+
<div className={styles.mypageContainer}>
208+
<ProfileCard
209+
onClickInterest={() => setIsEditingInterest(() => true)}
210+
/>
211+
<div className={styles.widgetsWrapper}>
212+
<BookmarkWidget />
213+
<MemoWidget />
218214
</div>
219-
)
220-
)
215+
</div>
216+
) : (
217+
<div className={styles.notFound}>
218+
<Modal
219+
content="마이페이지 이용을 위해서는 로그인을 해주세요."
220+
leftText="로그인"
221+
rightText="회원가입"
222+
onLeftClick={() => navigate("/auth/login")}
223+
onRightClick={() => navigate("/auth/signup")}
224+
onClose={null}
225+
/>
226+
</div>
221227
)}
222228
</div>
223229
);

src/pages/auth/OnBoarding/Onboarding.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ import type { Category } from "@types";
66
import styles from "@styles/Onboarding.module.css";
77
import { useUserData } from "@/contexts/UserDataContext";
88

9-
export default function Onboarding({ isEditing=false, onFinishEdit } : { isEditing?: boolean; onFinishEdit?: () => void }) {
9+
export default function Onboarding({
10+
isEditing = false,
11+
onFinishEdit,
12+
}: {
13+
isEditing?: boolean;
14+
onFinishEdit?: () => void;
15+
}) {
1016
const { refreshUserData, interestCategories } = useUserData();
1117

1218
const [, setSearchParams] = useSearchParams();
@@ -84,7 +90,7 @@ export default function Onboarding({ isEditing=false, onFinishEdit } : { isEditi
8490
};
8591

8692
return (
87-
<div className={`${styles.onbPage} ${isEditing ? styles.inMypage : ''}`}>
93+
<div className={`${styles.onbPage} ${isEditing ? styles.inMypage : ""}`}>
8894
<header className={styles.onbHeader}>
8995
<h1 className={styles.onbTitle}>관심사 설정</h1>
9096
<p className={styles.onbSubtitle}>

src/pages/search/Search.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const SearchView = () => {
2222
setSize,
2323
fetchSearchResult,
2424
searchResults,
25-
searchLoading
25+
searchLoading,
2626
} = useSearch();
2727
const { showDetail, clickedEventId } = useDetail();
2828
const [viewMode, setViewMode] = useState<"List" | "Grid">("Grid");
@@ -103,24 +103,26 @@ const SearchView = () => {
103103
</select>
104104
</div>
105105
</div>
106-
{(!searchResults || searchResults.total===0) ? (
106+
{!searchResults || searchResults.total === 0 ? (
107107
<div className={styles.noResult}>
108108
<span>
109-
{searchLoading ?
110-
<Loading />
111-
:
112-
query ? "검색 결과가 없습니다." : "검색어를 입력해보세요!"}
109+
{searchLoading ? (
110+
<Loading />
111+
) : query ? (
112+
"검색 결과가 없습니다."
113+
) : (
114+
"검색어를 입력해보세요!"
115+
)}
113116
</span>
114117
</div>
115-
) :
116-
viewMode === "List" ? (
118+
) : viewMode === "List" ? (
117119
<Table
118120
theadData={["찜", "제목", "D-day", "카테고리", "날짜", "주체기관"]}
119121
tbodyData={events}
120122
/>
121-
) :
122-
viewMode === "Grid" && <GalleryView events={events} />
123-
}
123+
) : (
124+
viewMode === "Grid" && <GalleryView events={events} />
125+
)}
124126
{searchResults && searchResults.total > 0 && (
125127
<Pagination
126128
page={page}

0 commit comments

Comments
 (0)