Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions apps/web/src/pages/Community/CommunityFeed/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import type { Post, Category } from '@/types/community';
import { getPostsCursor } from '@/api/posts';
import { useNativeBridgeStore } from '@/stores/nativeBridgeStore';
import type { ServerPostType } from '@/api/posts';
import { useCommunityStore } from '@/stores/communityStore';

type RouteType = 'all' | 'free' | 'proof' | 'share' | 'mate' | 'my';

const DEFAULT_PAGE_LIMIT = 10;

const TITLE_MAP: Record<RouteType, string> = {
all: '전체',
free: '자유',
free: '자유 게시판',
proof: '인증샷',
share: '경로 공유',
mate: '러닝메이트 구해요!',
Expand Down Expand Up @@ -45,6 +46,8 @@ export default function CommunityFeed() {
const { type: rawType } = useParams<{ type?: string }>();
const [searchParams] = useSearchParams();

const setActiveNav = useCommunityStore((s) => s.setActiveNav);

const routeType: RouteType =
rawType === 'free' ||
rawType === 'proof' ||
Expand Down Expand Up @@ -185,8 +188,13 @@ export default function CommunityFeed() {
return () => io.disconnect();
}, [canLoadMore, loading, loadMore]);

const handleOnBack = useCallback(() => {
setActiveNav(undefined);
window.history.back();
}, [setActiveNav]);

return (
<CommunityAppLayout title={title} onBack={() => window.history.back()}>
<CommunityAppLayout title={title} onBack={handleOnBack}>
<Page>
<List>
{error && <ErrorText>{error}</ErrorText>}
Expand Down
25 changes: 13 additions & 12 deletions apps/web/src/pages/Community/_components/CommunityNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const PATH_BY_KEY = {
route: '/community/feed/share',
run: '/community/feed/mate',
photo: '/community/feed/proof',
free: '/community/feed/free',
all: '/community',
} as const;

Expand All @@ -23,14 +24,6 @@ export default function CommunityNavigator() {

return (
<Container role="tablist" aria-label="커뮤니티 내비게이션">
<TabButton
role="tab"
aria-selected={active === 'route'}
active={active === 'route'}
onClick={go('route')}
>
경로
</TabButton>
<TabButton
role="tab"
aria-selected={active === 'run'}
Expand All @@ -49,11 +42,19 @@ export default function CommunityNavigator() {
</TabButton>
<TabButton
role="tab"
aria-selected={active === 'all'}
active={active === 'all'}
onClick={go('all')}
aria-selected={active === 'route'}
active={active === 'route'}
onClick={go('route')}
>
경로
</TabButton>
<TabButton
role="tab"
aria-selected={active === 'free'}
active={active === 'free'}
onClick={go('free')}
>
전체보기
자유게시판
</TabButton>
</Container>
);
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/stores/communityStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type Actions = {
};

export const useCommunityStore = create<ActiveState & Actions>()((set) => ({
activeNav: 'home',
activeNav: undefined,
filter: 'ALL',
setActiveNav: (k) => set({ activeNav: k }),
setFilter: (c) => set({ filter: c }),
Expand Down
9 changes: 8 additions & 1 deletion apps/web/src/types/community.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,11 @@ export interface Comment {
authorInfo?: AuthorObj;
}

export type NavKey = 'home' | 'photo' | 'route' | 'run' | 'all';
export type NavKey =
| 'home'
| 'photo'
| 'route'
| 'run'
| 'free'
| 'all'
| undefined;