From 18d8b0e2ffc0829819386e5f9bd627b2ff3ab9f5 Mon Sep 17 00:00:00 2001 From: Hyeon Ji Kim Date: Fri, 9 Feb 2024 20:11:16 +0900 Subject: [PATCH 1/4] fix showcase page --- src/app/recruit/[id]/panel/ApplyDefaultButton.tsx | 2 +- src/app/recruit/[id]/panel/ApplyDrawerButton.tsx | 2 +- src/app/recruit/[id]/panel/ApplyMenuButton.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/recruit/[id]/panel/ApplyDefaultButton.tsx b/src/app/recruit/[id]/panel/ApplyDefaultButton.tsx index 5e73e4cf5..a460a68ce 100644 --- a/src/app/recruit/[id]/panel/ApplyDefaultButton.tsx +++ b/src/app/recruit/[id]/panel/ApplyDefaultButton.tsx @@ -21,7 +21,7 @@ const ApplyDefaultButton = ({ disabled={disabled} > - 지원하기 + {disabled ? '마감' : '지원하기'} ) diff --git a/src/app/recruit/[id]/panel/ApplyDrawerButton.tsx b/src/app/recruit/[id]/panel/ApplyDrawerButton.tsx index 9be912861..8c9098f31 100644 --- a/src/app/recruit/[id]/panel/ApplyDrawerButton.tsx +++ b/src/app/recruit/[id]/panel/ApplyDrawerButton.tsx @@ -64,7 +64,7 @@ const ApplyDrawerButton = ({ }} > - 지원하기 + {disabled ? '마감' : '지원하기'} diff --git a/src/app/recruit/[id]/panel/ApplyMenuButton.tsx b/src/app/recruit/[id]/panel/ApplyMenuButton.tsx index 0db9c7221..1c8d68502 100644 --- a/src/app/recruit/[id]/panel/ApplyMenuButton.tsx +++ b/src/app/recruit/[id]/panel/ApplyMenuButton.tsx @@ -52,7 +52,7 @@ const ApplyMenuButton = ({ sx={sx} > - 지원하기 + {disabled ? '마감' : '지원하기'} Date: Tue, 13 Feb 2024 00:54:20 +0900 Subject: [PATCH 2/4] add query string --- src/app/panel/MainPage.tsx | 33 +++++++++++++++--------- src/app/panel/layout-panel/Header.tsx | 15 ++++++++--- src/app/panel/main-page/MainCard.tsx | 2 +- src/app/panel/main-page/SearchOption.tsx | 2 +- src/app/panel/main-page/SelectType.tsx | 4 +-- 5 files changed, 37 insertions(+), 19 deletions(-) diff --git a/src/app/panel/MainPage.tsx b/src/app/panel/MainPage.tsx index 0871d737e..fa6cc459f 100644 --- a/src/app/panel/MainPage.tsx +++ b/src/app/panel/MainPage.tsx @@ -22,7 +22,6 @@ import PushAlertBanner from './PushAlertBanner' import MainBanner from '@/app/panel/main-page/MainBanner' import Tutorial from '@/components/Tutorial' import { MainPageTutorial } from '@/components/tutorialContent/MainPageTutorial' -import useHeaderStore from '@/states/useHeaderStore' import NoDataDolphin from '@/components/NoDataDolphin' import { cardStyle, @@ -61,12 +60,12 @@ export interface IDetailOption { const MainPage = ({ initData }: { initData: IPagination }) => { const searchParams = useSearchParams() const keyword = searchParams.get('keyword') ?? '' - const searchType = searchParams.get('type') === 'STUDY' ? 'STUDY' : 'PROJECT' + const searchType = + searchParams.get('type') === 'PROJECT' ? 'PROJECT' : 'STUDY' + console.log('searchType', searchType) const router = useRouter() const [page, setPage] = useState(1) - const [type, setType] = useState( - keyword !== '' ? searchType : undefined, - ) //'STUDY' + const [type, setType] = useState(searchType) //'STUDY' const [openOption, setOpenOption] = useState(false) const [sort, setSort] = useState(undefined) //'latest' const [detailOption, setDetailOption] = useState({ @@ -85,15 +84,13 @@ const MainPage = ({ initData }: { initData: IPagination }) => { const [prevScrollHeight, setPrevScrollHeight] = useState( undefined, ) - const { headerTitle, setHeaderTitle } = useHeaderStore() const [init, setInit] = useState(true) useEffect(() => { if (keyword !== '') { - setHeaderTitle(keyword + ' 검색 결과') setType(searchType) setInit(false) - } else setHeaderTitle('') + } }, [keyword, searchType]) /* page가 1이면 서버가 가져온 데이터(initData)로 렌더링 */ @@ -118,7 +115,12 @@ const MainPage = ({ initData }: { initData: IPagination }) => { }&tag=${detailOption.tag}` const isInit = - page == 1 && !type && !sort && detailOption.isInit && keyword == '' && init + page == 1 && + type === 'STUDY' && + !sort && + detailOption.isInit && + keyword == '' && + init const { data: favoriteData } = useSWR( isInit && isLogin @@ -186,6 +188,7 @@ const MainPage = ({ initData }: { initData: IPagination }) => { (newData?.last || initData?.last) ?? true, //isEnd page, ) + const handleType = useCallback( (value: ProjectType) => { setType(value) @@ -201,7 +204,7 @@ const MainPage = ({ initData }: { initData: IPagination }) => { tag: '', }) setSort('latest') - router.push('/') + router.replace(`?type=${value}`) }, [router], ) @@ -251,7 +254,10 @@ const MainPage = ({ initData }: { initData: IPagination }) => { justifyContent={'space-between'} my={'0.75rem'} > - {headerTitle} + + {keyword} + 검색 결과 + )} @@ -337,7 +343,10 @@ const MainPage = ({ initData }: { initData: IPagination }) => { justifyContent={'space-between'} mb={'0.75rem'} > - {headerTitle} + + {keyword} + 검색 결과 + )} diff --git a/src/app/panel/layout-panel/Header.tsx b/src/app/panel/layout-panel/Header.tsx index 3b08ea9f2..e14bdc47b 100644 --- a/src/app/panel/layout-panel/Header.tsx +++ b/src/app/panel/layout-panel/Header.tsx @@ -39,12 +39,15 @@ const Header = ({ pathname }: { pathname?: string }) => { const [title, setTitle] = useState('') const searchParams = useSearchParams() const keyword = searchParams.get('keyword') ?? '' + const type = searchParams.get('type') ?? 'STUDY' + console.log('type', type) const regex = /^\/recruit\/\d+\/edit$/ useEffect(() => { if (!pathname) return setTitle('') if (pathname === '/') { - setTitle('메인') + if (keyword !== '') setTitle('검색 결과') + else setTitle('메인') } else if (pathname.startsWith('/login')) { setTitle('로그인') } else if (pathname === '/recruit/write') { @@ -67,7 +70,9 @@ const Header = ({ pathname }: { pathname?: string }) => { // 타이틀만 보여주고 싶은 경우 (뒤로 가기 버튼이 보이지 않았으면 하는 경우) const onlyTitle = - title === '마이페이지' || title === '나의 팀' || title === '로그인' + pathname?.startsWith('/my-page') || + pathname?.startsWith('/team-list') || + pathname?.startsWith('/login') return ( @@ -89,7 +94,11 @@ const Header = ({ pathname }: { pathname?: string }) => { ) : ( router.back()} + onClick={() => { + if (pathname === '/' && keyword !== '') { + router.replace(`?type=${type}`) + } else router.back() + }} sx={{ visibility: onlyTitle ? 'hidden' : 'visible', }} diff --git a/src/app/panel/main-page/MainCard.tsx b/src/app/panel/main-page/MainCard.tsx index b7051a260..cb29e7a47 100644 --- a/src/app/panel/main-page/MainCard.tsx +++ b/src/app/panel/main-page/MainCard.tsx @@ -177,7 +177,7 @@ const MainCard = ({ mt={1} direction={'row'} sx={{ - height: `${1.5 * tagMaxLine + 0.5}rem`, + height: `${1.5 * tagMaxLine + 0.25}rem`, overflow: 'auto', flexWrap: 'wrap', '&::-webkit-scrollbar': { diff --git a/src/app/panel/main-page/SearchOption.tsx b/src/app/panel/main-page/SearchOption.tsx index 2e81a53f4..d61b88ab2 100644 --- a/src/app/panel/main-page/SearchOption.tsx +++ b/src/app/panel/main-page/SearchOption.tsx @@ -13,7 +13,7 @@ const SearchOption = ({ openOption: boolean setOpenOption: any setDetailOption: any - type: ProjectType | undefined + type: ProjectType }) => { const { isPc } = useMedia() const typeTitle = type === 'PROJECT' ? '프로젝트' : '스터디' diff --git a/src/app/panel/main-page/SelectType.tsx b/src/app/panel/main-page/SelectType.tsx index 71df952b0..fd178ae47 100644 --- a/src/app/panel/main-page/SelectType.tsx +++ b/src/app/panel/main-page/SelectType.tsx @@ -5,7 +5,7 @@ const SelectType = ({ type, setType, }: { - type: ProjectType | undefined + type: ProjectType setType: (value: ProjectType) => void }) => { { @@ -14,7 +14,7 @@ const SelectType = ({ return ( { setType('STUDY') From 1a973118a75b34d728d956a2e7abadf9a20c3b14 Mon Sep 17 00:00:00 2001 From: hyeon81 Date: Tue, 13 Feb 2024 01:09:39 +0900 Subject: [PATCH 3/4] remove console.log --- src/app/panel/layout-panel/Header.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/panel/layout-panel/Header.tsx b/src/app/panel/layout-panel/Header.tsx index e14bdc47b..e82a62c9e 100644 --- a/src/app/panel/layout-panel/Header.tsx +++ b/src/app/panel/layout-panel/Header.tsx @@ -40,7 +40,6 @@ const Header = ({ pathname }: { pathname?: string }) => { const searchParams = useSearchParams() const keyword = searchParams.get('keyword') ?? '' const type = searchParams.get('type') ?? 'STUDY' - console.log('type', type) const regex = /^\/recruit\/\d+\/edit$/ useEffect(() => { From 3d0c5a85bf98f60dec210b6fb6fd1ec2e7374583 Mon Sep 17 00:00:00 2001 From: Hyeon Ji Kim Date: Tue, 13 Feb 2024 16:02:59 +0900 Subject: [PATCH 4/4] fix type --- src/app/panel/MainPage.tsx | 1 - src/app/panel/main-page/MainPanel.tsx | 2 +- src/types/IPostDetail.ts | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/app/panel/MainPage.tsx b/src/app/panel/MainPage.tsx index fa6cc459f..f5e672007 100644 --- a/src/app/panel/MainPage.tsx +++ b/src/app/panel/MainPage.tsx @@ -62,7 +62,6 @@ const MainPage = ({ initData }: { initData: IPagination }) => { const keyword = searchParams.get('keyword') ?? '' const searchType = searchParams.get('type') === 'PROJECT' ? 'PROJECT' : 'STUDY' - console.log('searchType', searchType) const router = useRouter() const [page, setPage] = useState(1) const [type, setType] = useState(searchType) //'STUDY' diff --git a/src/app/panel/main-page/MainPanel.tsx b/src/app/panel/main-page/MainPanel.tsx index 9cdc73480..77b3dec87 100644 --- a/src/app/panel/main-page/MainPanel.tsx +++ b/src/app/panel/main-page/MainPanel.tsx @@ -9,7 +9,7 @@ interface ISearchOptionPanel { openOption: boolean setOpenOption: (value: boolean) => void handleOption: (value: IDetailOption) => void - type: ProjectType | undefined + type: ProjectType sort: ProjectSort | undefined handleSort: (value: ProjectSort) => void isPc?: boolean diff --git a/src/types/IPostDetail.ts b/src/types/IPostDetail.ts index a219652f2..b78b19565 100644 --- a/src/types/IPostDetail.ts +++ b/src/types/IPostDetail.ts @@ -20,7 +20,7 @@ export interface IMainCard { tagList: ITag[] favorite?: boolean recruit_id: number - type: ProjectType | undefined + type: ProjectType href?: string onFavorite?: () => void sx?: SxProps