Skip to content

Commit

Permalink
Fix: 초대 페이지 네비바 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
goeun208 committed Mar 18, 2024
1 parent 5a1b829 commit 1132f28
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 10 deletions.
4 changes: 4 additions & 0 deletions src/components/common/navbar/NavInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ export const NAV_INFO = {
label: '투표',
url: NAV_URL_LIST.VOTE,
},
[NAV_LIST.INVITE]: {
label: '초대',
url: NAV_URL_LIST.INVITE,
},
} as const satisfies Record<(typeof NAV_LIST)[keyof typeof NAV_LIST], NavItemType>;
4 changes: 2 additions & 2 deletions src/components/common/navbar/NavItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ type NavListType = keyof typeof NAV_LIST;
interface NavItemProps {
type: NavListType;
isFocused: boolean;
groupId: number;
groupId: string | null;
}

const NavItem = ({ type, isFocused, groupId }: NavItemProps) => {
const { url, label } = NAV_INFO[type];
return (
<>
{isFocused ? (
{isFocused && groupId !== null ? (
<Link href={`${url}/${groupId}`} className="w-[400px] h-[29px] text-center">
<div className="font-thin font-Pretendard text-main_orange text-b2">{label}</div>
<div className="mt-1.5 w-full h-0.5 bg-main_orange rounded-2xl"></div>
Expand Down
2 changes: 2 additions & 0 deletions src/components/common/navbar/Navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ export const NAV_LIST = {
MAIN: 'MAIN',
PARTICIPANT: 'PARTICIPANT',
VOTE: 'VOTE',
INVITE: 'INVITE',
} as const;
export const NAV_URL_LIST = {
[NAV_LIST.MAIN]: '/main',
[NAV_LIST.PARTICIPANT]: '/participant',
[NAV_LIST.VOTE]: '/vote',
[NAV_LIST.INVITE]: '/invite',
} as const;
5 changes: 1 addition & 4 deletions src/components/common/navbar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { useRecoilValue } from 'recoil';
import { NAV_URL_LIST, NAV_LIST } from './Navigation';
import NavItem from './NavItem';
import { groupIdAtom } from '@/states/groupIdAtom';

interface NavigationBarProps {
focusType: keyof typeof NAV_URL_LIST;
}

const Navbar = ({ focusType }: NavigationBarProps) => {
const group = useRecoilValue(groupIdAtom);
const groupId = group.groupId;
const groupId = sessionStorage.getItem('groupId');

return (
<>
Expand Down
21 changes: 21 additions & 0 deletions src/components/common/navbar/inviteIndex.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { NAV_URL_LIST, NAV_LIST } from './Navigation';
import NavItem from './NavItem';

interface NavigationBarProps {
focusType: keyof typeof NAV_URL_LIST;
}

const InviteNavbar = ({ focusType }: NavigationBarProps) => {
const groupId = sessionStorage.getItem('groupId');

return (
<>
<div className="flex justify-center items-center mt-10 w-full pl-20 pr-2 gap-10 ">
<NavItem type={NAV_LIST.MAIN} isFocused={focusType == NAV_LIST.MAIN} groupId={groupId} />
<NavItem type={NAV_LIST.INVITE} isFocused={focusType == NAV_LIST.INVITE} groupId={groupId} />
<NavItem type={NAV_LIST.VOTE} isFocused={focusType == NAV_LIST.VOTE} groupId={groupId} />
</div>
</>
);
};
export default InviteNavbar;
4 changes: 2 additions & 2 deletions src/components/invite/InviteSpaceInvite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { ParticipationProps } from '@/types/ParticipateType';
import { useEffect, useState } from 'react';
import Header from '../common/header';
import ParticipationList from '../participate/ParticipationList';
import Navbar from '../common/navbar';
import { NAV_LIST } from '../common/navbar/Navigation';
import LoginPopup from './LoginPopup';
import { useSetRecoilState } from 'recoil';
import { groupNameAtom } from '@/states/groupNameAtom';
import api from '@/services/TokenService';
import { useGetGroup } from '@/hooks/useGetGroup';
import InviteNavbar from '../common/navbar/inviteIndex';
// import { useRouter } from 'next/router';

const InviteSpaceInvite = ({ id }: any) => {
Expand Down Expand Up @@ -58,7 +58,7 @@ const InviteSpaceInvite = ({ id }: any) => {
return (
<section>
<Header />
<Navbar focusType={NAV_LIST.PARTICIPANT} />
<InviteNavbar focusType={NAV_LIST.INVITE} />
<div className="max-w-[1200px] mx-auto font-Pretendard">
{partData && <ParticipationList data={partData} mode={false} setMode={undefined} />}
</div>
Expand Down
15 changes: 13 additions & 2 deletions src/pages/vote/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,28 @@ import { useRecoilValue } from 'recoil';
import VoteWaitPage from './wait/[id]';
import VoteDetailPage from './detail/[id]';
import InviteVoteBeforeLogin from '@/components/invite/InviteVoteBeforeLogin';
import NotFound from '../404';

const VotePage = () => {
const token = api.getToken();
const group = useRecoilValue(groupIdAtom);
const response = useGetGroupVote(token, group.groupId);
const { data: response, isLoading, isError } = useGetGroupVote(token, group.groupId);
const [voteData, setVoteData] = useState<any>(null);

useEffect(() => {
if (response.data?.message === '성공') setVoteData(response.data?.data);
if (response?.message === '성공') setVoteData(response?.data);
}, [response]);

if (isLoading) {
console.log('isLoading', isLoading);
return <InviteVoteBeforeLogin />;
}

if (isError) {
console.log('isError', isError);
return <NotFound />;
}

return (
<div>
{token === undefined ? (
Expand Down

0 comments on commit 1132f28

Please sign in to comment.