-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Feat: invite team GET api 연결 성공, createRetro 사진 관련 api 요청 수정 완료
- Loading branch information
1 parent
6a161e2
commit 00faf9d
Showing
7 changed files
with
101 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export interface GetInviteTeamRequest { | ||
// teamId: number; | ||
} | ||
|
||
export interface GetInviteTeamResponse { | ||
code: number; | ||
message: string; | ||
data: InviteTeamData; | ||
} | ||
|
||
export interface InviteTeamData { | ||
invitationCode: string; | ||
invitationUrl: string; | ||
expirationTime: string; | ||
qrCodeImage: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { GetInviteTeamRequest, GetInviteTeamResponse } from '../@types/InviteTeam'; | ||
import axiosInstance from '../axiosConfig'; | ||
|
||
const getInviteTeam = async (teamId: GetInviteTeamRequest): Promise<GetInviteTeamResponse> => { | ||
try { | ||
const response = await axiosInstance.get<GetInviteTeamResponse>(`/teams/${teamId}/invitation-url`); | ||
console.log('팀원 초대 호출 성공', response.data); | ||
return response.data; | ||
} catch (error) { | ||
throw new Error('팀원 초대 호출 실패'); | ||
} | ||
}; | ||
|
||
export default getInviteTeam; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import QRCode from 'qrcode.react'; | ||
import { GetInviteTeamResponse, InviteTeamData } from '@/api/@types/InviteTeam'; | ||
import getInviteTeam from '@/api/retrospectivesApi/getInviteTeam'; | ||
|
||
interface InviteTeamComponentProps { | ||
teamId: number; | ||
} | ||
|
||
const InviteTeamComponent: React.FC<InviteTeamComponentProps> = ({ teamId }) => { | ||
const [inviteData, setInviteData] = useState<InviteTeamData | null>(null); | ||
const [error, setError] = useState<string>(''); | ||
|
||
useEffect(() => { | ||
const fetchInviteData = async () => { | ||
try { | ||
const response: GetInviteTeamResponse = await getInviteTeam(teamId); | ||
setInviteData(response.data); | ||
} catch (error) { | ||
console.error(error); | ||
setError('팀원 초대 get 실패'); | ||
} | ||
}; | ||
|
||
fetchInviteData(); | ||
}, [teamId]); // teamId가 변경될 때마다 호출 | ||
|
||
if (error) { | ||
return <div>{error}</div>; | ||
} | ||
|
||
if (!inviteData) { | ||
return <div>로딩중...</div>; | ||
} | ||
|
||
return ( | ||
<div> | ||
<p>초대 코드: {inviteData.invitationCode}</p> | ||
<p> | ||
초대 URL:{' '} | ||
<a href={inviteData.invitationUrl} target="_blank" rel="noopener noreferrer"> | ||
{inviteData.invitationUrl} | ||
</a> | ||
</p> | ||
<p>만료 시간: {inviteData.expirationTime}</p> | ||
<QRCode value={inviteData.qrCodeImage} /> | ||
<p>{inviteData.qrCodeImage}</p> | ||
</div> | ||
); | ||
}; | ||
|
||
export default InviteTeamComponent; |