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

[FEAT/HM-168]: 초대링크 일정 이름 추가 #66

Merged
merged 1 commit into from
Oct 6, 2024
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
17 changes: 17 additions & 0 deletions src/apis/meeting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,20 @@ export const postMemberMeeting = async ({
const result = await axiosInstance.post(`/room/${roomId}`, meetingReq);
return result;
};

export interface GetMeetingInfoReq {
isGuest: boolean;
meetingId: string;
roomId?: string;
}

export const getMeetingInfo = async ({
isGuest,
meetingId,
roomId,
}: GetMeetingInfoReq) => {
const response = await axiosInstance.get(
`/${isGuest ? `guest-schedule/${meetingId}` : `room/${roomId}/${meetingId}`}`
);
return response.data;
};
14 changes: 6 additions & 8 deletions src/components/login/TeammateLogin.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import { GuestTitle } from '@/styles/components/text';
import { LogoTitleIcon } from 'public/assets/icons';
import { useSearchParams } from 'react-router-dom';
import { useMeetingInfo } from '@/hooks/useMeetingInfo';
import styled from 'styled-components';
import SocialLoginButtons from './SocialLoginButtons';
import LoginForm from './LoginForm';

function TeammateLogin() {
const [searchParams] = useSearchParams();
const meetingId = searchParams.get('meetingId');
const loginType = searchParams.get('loginType');
const { isGuest, meetingId, meetingInfo } = useMeetingInfo();

return (
<Container>
<Header>
<LogoTitleIcon width={140} />
{loginType === 'non-member' ? (
{isGuest ? (
<GuestTitle>
<h2>일정 이름</h2>
<h2>{meetingInfo.name.value}</h2>
<span>
비회원으로 일정을 만든 경우에는
<br />
Expand All @@ -25,13 +23,13 @@ function TeammateLogin() {
</GuestTitle>
) : (
<GuestTitle>
<h2>일정 이름</h2>
<h2>{meetingInfo.name.value}</h2>
<span>간편 로그인 후에 일정을 조율해 보세요.</span>
</GuestTitle>
)}
</Header>
<LoginFormContainer>
{loginType === 'non-member' ? (
{isGuest ? (
<LoginForm meetingId={meetingId!} />
) : (
<SocialLoginButtons />
Expand Down
18 changes: 18 additions & 0 deletions src/hooks/useMeetingInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { getMeetingInfo } from '@/apis/meeting';
import { useQuery } from '@tanstack/react-query';
import { useSearchParams } from 'react-router-dom';

export const useMeetingInfo = () => {
const [searchParams] = useSearchParams();
const meetingId = searchParams.get('meetingId')!;
const roomId = searchParams.get('roomId') || undefined;
const loginType = searchParams.get('loginType');
const isGuest = loginType === 'non-member';

const { data } = useQuery({
queryKey: ['meetingInfo', { roomId, meetingId }],
queryFn: () => getMeetingInfo({ isGuest, roomId, meetingId }),
});

return { meetingInfo: data, meetingId, isGuest };
};