Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

다락방 api를 페이지에 연결 #379

Merged
merged 28 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cccae5f
chore:firebaseConfig.js를gitignore에 등록
ss0526100 Aug 18, 2024
536dad6
feat:로그인 후 리다이렉션을 다락방선택페이지로 넘김
ss0526100 Aug 18, 2024
25aa663
feat:useMyDarakbangs구현
ss0526100 Aug 18, 2024
1d63b7d
feat:DarakbangSelect 페이지에서 내 모임을 보여줌
ss0526100 Aug 18, 2024
2ab031f
feat(SelectContentContainer): 쓸데없는 폰트 사이즈 지정을 없앰
ss0526100 Aug 18, 2024
9416787
feat:다락방 만들기 api 연결부분 구현
ss0526100 Aug 18, 2024
f6abcd8
feat:다락방 생성 페이지 이후 모임페이지로 넘어가기 구현
ss0526100 Aug 18, 2024
3f355c6
feat:내 다락방 권한 조회 api 연결
ss0526100 Aug 18, 2024
f6e5292
fix(OptionsPanel):패널을 사용하면서 생길 수 있는 버그 수정
ss0526100 Aug 18, 2024
15700db
fix(queryClient): 토큰 만료시 login이 아닌 home으로 향하게 변경
ss0526100 Aug 18, 2024
bc80192
fix:다락방 참여코드 입력 제목 크기 수정
ss0526100 Aug 18, 2024
8f62509
feat(DarakbangSelectPage):다락방 이동시 메인 페이지로 이동하게 구현
ss0526100 Aug 18, 2024
3dca74c
feat(MainPage): 홈화면에서 다락방 관리/변경 페이지 구현
ss0526100 Aug 18, 2024
0bfff99
feat:다락방 멤버 불러오는 api 연결
ss0526100 Aug 18, 2024
9387fe6
fix:다락방 역할 불러올 시 다락방 id를 쿼리키에 넣지 않는 버그 수정
ss0526100 Aug 18, 2024
b21f536
refactor(useDarakbangMembers):파일 경로 오타 수정
ss0526100 Aug 18, 2024
09f0eb7
feat:다락방 멤버 api를 멤버 관리 페이지에 연결
ss0526100 Aug 18, 2024
a1b13c7
feat:다락방 초대코드 api 연결
ss0526100 Aug 18, 2024
3cb8c3a
feat:다락방 초대페이지에 다락방 초대코드 api 연결
ss0526100 Aug 18, 2024
ca3c4bf
feat:다락방 코드를 가지고 이름을 확인하는 api 구현
ss0526100 Aug 18, 2024
7cb8572
feat(DarakbangInvitationRoute):코드로 다락방 이름 검사 구현
ss0526100 Aug 18, 2024
c0d011d
feat(DarakbangNickNamePage):이전 코드 상태를 활용한다
ss0526100 Aug 18, 2024
cb98c6e
fix(DarakbangNickNamePage):useNavigate로 넘겨주는 상태를 이름이 아닌 코드로 변경
ss0526100 Aug 18, 2024
718543b
feat:다락방 참여 api 연결
ss0526100 Aug 18, 2024
fb416c2
fix(postDarakbangEntrance):초대코드 쿼리파라미터에 넣지 않던 버그 수정
ss0526100 Aug 18, 2024
68d02cd
feat:다락방 닉네임 입력 후 api연결
ss0526100 Aug 18, 2024
69a7d4d
fix(CompleteBottomButtonWrapper): 화면을 벗어나는 버그 수정
ss0526100 Aug 18, 2024
04ce6b5
fix:멤버 초대 페이지 버튼 ui 오류 수정
ss0526100 Aug 18, 2024
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
2 changes: 2 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ dist
.env
.env*
coverage

public/firebaseConfig.js
54 changes: 54 additions & 0 deletions frontend/src/apis/gets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ import {
GetChamyoMine,
GetChat,
GetChattingPreview,
GetDarakbangInviteCode,
GetDarakbangMembers,
GetDarakbangMine,
GetDarakbangNameByCode,
GetMoim,
GetMoims,
GetMyInfo,
GetMyRoleInDarakbang,
GetNotifications,
GetPleases,
GetZzimMine,
Expand Down Expand Up @@ -120,3 +125,52 @@ export const getNotifications = async () => {
const json: GetNotifications = await response.json();
return json.data.notifications;
};

export const getMyDarakbangs = async () => {
const response = await ApiClient.getWithAuth('darakbang/mine');

const json: GetDarakbangMine = await response.json();
return json.data.darakbangResponses;
};

export const getMyRoleInDarakbang = async (darakbangId: number) => {
const response = await ApiClient.getWithAuth(
'darakbang/' + darakbangId + '/role',
);

const json: GetMyRoleInDarakbang = await response.json();
return json.data.role;
};

export const getDarakbangMembers = async (darakbangId: number) => {
const response = await ApiClient.getWithAuth(
'darakbang/' + darakbangId + '/members',
);

const json: GetDarakbangMembers = await response.json();
return json.data.darakbangMemberResponses;
};

export const getDarakbangInviteCode = async (darakbangId: number) => {
const response = await ApiClient.getWithAuth(
'darakbang/' + darakbangId + '/code',
);

const json: GetDarakbangInviteCode = await response.json();
return json.data.code;
};

export const getDarakbangNameByCode = async (code: string) => {
const response = await ApiClient.getWithAuth(
'darakbang/validation?code=' + code,
).catch(() => {
return {
json: () => {
return { data: { name: '' } };
},
};
});

const json: GetDarakbangNameByCode = await response.json();
return json.data.name;
};
25 changes: 25 additions & 0 deletions frontend/src/apis/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,28 @@ export const postNotificationToken = async (currentToken: string) => {
token: currentToken,
});
};

export const postDarakbang = async ({
name,
nickname,
}: {
name: string;
nickname: string;
}) => {
await ApiClient.postWithAuth('darakbang', {
name,
nickname,
});
};

export const postDarakbangEntrance = async ({
code,
nickname,
}: {
code: string;
nickname: string;
}) => {
await ApiClient.postWithAuth('darakbang/entrance?code=' + code, {
nickname,
});
};
36 changes: 36 additions & 0 deletions frontend/src/apis/responseTypes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {
Chat,
ChattingPreview,
Darakbang,
DarakbangRole,
MoimInfo,
Notification,
Participation,
Expand Down Expand Up @@ -71,3 +73,37 @@ export interface GetNotifications {
notifications: Notification[];
};
}

export interface GetDarakbangMine {
data: {
darakbangResponses: Darakbang[];
};
}

export interface GetMyRoleInDarakbang {
data: {
role: DarakbangRole;
};
}

export interface GetDarakbangMembers {
data: {
darakbangMemberResponses: {
memberId: number;
nickname: string;
profile: string;
}[];
};
}

export interface GetDarakbangInviteCode {
data: {
code: string;
};
}

export interface GetDarakbangNameByCode {
data: {
name: string;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const Decorated: Story = {
},
],
width: '200px',
movedWidth: '24px',
movedHeight: '24px',
},
decorators: function (Story) {
const [isStoryOpen, setIsStoryOpen] = useState(false);
Expand Down
14 changes: 12 additions & 2 deletions frontend/src/components/OptionsPanel/OptionsPanel.style.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import { Theme } from './../../common/theme/theme.type';
import { css } from '@emotion/react';

export const panel = (width: string, movedWidth: string) => css`
export const panel = ({
width,
movedHeight,
movedWidth,
}: {
width: string;
movedHeight: string;
movedWidth: string;
}) => css`
position: absolute;
transform: translate(0, ${movedWidth});
transform: translateX(${movedWidth}) translateY(${movedHeight});

overflow: hidden;
display: flex;
flex-direction: column;

width: ${width};

Expand Down
32 changes: 23 additions & 9 deletions frontend/src/components/OptionsPanel/OptionsPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
export interface OptionsPanelOption {
description: string;
onClick: () => void;
hasTopBorder?: boolean;
}

interface OptionsPanelProps {
options: {
description: string;
onClick: () => void;
hasTopBorder?: boolean;
}[];
options: OptionsPanelOption[];
onClose: () => void;
onAfterSelect: () => void;
movedHeight?: string;
movedWidth?: string;
width?: string;
}
Expand All @@ -15,22 +19,32 @@ import { useEffect } from 'react';
import { useTheme } from '@emotion/react';

export default function OptionsPanel(props: OptionsPanelProps) {
const { options, onClose, width, movedWidth } = props;
const { options, onClose, onAfterSelect, width, movedHeight, movedWidth } =
props;
const theme = useTheme();

useEffect(() => {
document.addEventListener('click', onClose);
return () => document.removeEventListener('click', onClose);
}, [onClose]);

console.log(options);
return (
<div css={S.panel(width || '100px', movedWidth || '0px')}>
<div
css={S.panel({
width: width || '100px',
movedHeight: movedHeight || '0px',
movedWidth: movedWidth || '0px',
})}
>
{options.map(({ description, onClick, hasTopBorder }) => {
return (
<div
key={description}
onClick={onClick}
onClick={(e) => {
e.stopPropagation();
onClick();
onAfterSelect();
}}
css={S.option({ theme, hasTopBorder })}
>
<span css={theme.typography.b1}>{description}</span>
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/constants/queryKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ const QUERY_KEYS = {
please: 'please',
pleases: 'pleases',
notifications: 'notifications',
myDarakbangs: 'myDarakbangs',
myRoleInDarakbang: 'myRoleInDarakbang',
darakbangMembers: 'darakbangMembers',
darakbangInviteCode: 'darakbangInviteCode',
darakbangNameByCode: 'darakbangNameByCode',
};

export default QUERY_KEYS;
17 changes: 17 additions & 0 deletions frontend/src/hooks/mutaions/useCreateDarakbang.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';

import QUERY_KEYS from '@_constants/queryKeys';
import { postDarakbang } from '@_apis/posts';

export default function useCreateDarakbang(onSuccess?: () => void) {
const queryClient = useQueryClient();

return useMutation({
mutationFn: postDarakbang,
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: [QUERY_KEYS.myDarakbangs] });

if (onSuccess) onSuccess();
},
});
}
32 changes: 32 additions & 0 deletions frontend/src/hooks/mutaions/useEnterDarakbang.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';

import { ApiError } from '@_utils/customError/ApiError';
import QUERY_KEYS from '@_constants/queryKeys';
import { postDarakbangEntrance } from '@_apis/posts';

export default function useEnterDarakbang({
onSuccess,
onError,
}: {
onSuccess?: () => void;
onError: (string: string) => void;
}) {
const queryClient = useQueryClient();

return useMutation({
mutationFn: ({ code, nickname }: { code: string; nickname: string }) =>
postDarakbangEntrance({ code, nickname }),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: [QUERY_KEYS.myDarakbangs] });

if (onSuccess) onSuccess();
},

onError: (err) => {
if (err instanceof ApiError) {
onError(err.message);
}
throw err;
},
});
}
12 changes: 12 additions & 0 deletions frontend/src/hooks/queries/useDarakbangInviteCode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import QUERY_KEYS from '@_constants/queryKeys';
import { getDarakbangInviteCode } from '@_apis/gets';
import { useQuery } from '@tanstack/react-query';

export default function useDarakbangInviteCode(darakbangId: number) {
const { data: inviteCode, isLoading } = useQuery({
queryKey: [QUERY_KEYS.darakbangInviteCode, darakbangId],
queryFn: () => getDarakbangInviteCode(darakbangId),
});

return { inviteCode, isLoading };
}
12 changes: 12 additions & 0 deletions frontend/src/hooks/queries/useDarakbangMembers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import QUERY_KEYS from '@_constants/queryKeys';
import { getDarakbangMembers } from '@_apis/gets';
import { useQuery } from '@tanstack/react-query';

export default function useDarakbangMembers(darakbangId: number) {
const { data: members, isLoading } = useQuery({
queryKey: [QUERY_KEYS.darakbangMembers, darakbangId],
queryFn: () => getDarakbangMembers(darakbangId),
});

return { members, isLoading };
}
12 changes: 12 additions & 0 deletions frontend/src/hooks/queries/useDarakbangNameByCode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import QUERY_KEYS from '@_constants/queryKeys';
import { getDarakbangNameByCode } from '@_apis/gets';
import { useQuery } from '@tanstack/react-query';

export default function useDarakbangNameByCode(code: string) {
const { data: darakbangName, isLoading } = useQuery({
queryKey: [QUERY_KEYS.darakbangNameByCode, code],
queryFn: () => getDarakbangNameByCode(code),
});

return { darakbangName, isLoading };
}
12 changes: 12 additions & 0 deletions frontend/src/hooks/queries/useMyDarakbang.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import QUERY_KEYS from '@_constants/queryKeys';
import { getMyDarakbangs } from '@_apis/gets';
import { useQuery } from '@tanstack/react-query';

export default function useMyDarakbangs() {
const { data: myDarakbangs, isLoading } = useQuery({
queryKey: [QUERY_KEYS.myDarakbangs],
queryFn: getMyDarakbangs,
});

return { myDarakbangs, isLoading };
}
12 changes: 12 additions & 0 deletions frontend/src/hooks/queries/useMyDarakbangRole.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import QUERY_KEYS from '@_constants/queryKeys';
import { getMyRoleInDarakbang } from './../../apis/gets';
import { useQuery } from '@tanstack/react-query';

export default function useMyRoleInDarakbang(darakbangId: number) {
const { data: myRoleInDarakbang, isLoading } = useQuery({
queryKey: [QUERY_KEYS.myRoleInDarakbang, darakbangId],
queryFn: () => getMyRoleInDarakbang(darakbangId),
});

return { myRoleInDarakbang, isLoading };
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { DISPLAY_MAX_WIDTH } from '@_constants/styles';
import { css } from '@emotion/react';

// TODO: 바텀 버튼 UI에 대한 기획 논의 필요
export const bottomFixedStyle = css`
position: fixed;
bottom: 26px;
width: ${DISPLAY_MAX_WIDTH};
width: 100%;
padding: 0 16px;
`;
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,4 @@ export const contentStyle = css`
width: 100%;
height: 100vh;
padding: 16px 22px;

font-size: 5rem;
font-weight: 700;
`;
Loading
Loading