-
Notifications
You must be signed in to change notification settings - Fork 0
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: 친구 페이지 친구 삭제, 내 초대코드 조회, 친구 추가 API 연동 #28
Changes from 9 commits
46901a6
3772493
0cc095b
8c406fe
18b3904
e0930eb
2e0488c
50c2bd2
f684513
dcb64e5
7ea8153
7876f5f
b9f9fb7
15203f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
|
||
const CheckIcon: React.FC<React.SVGProps<SVGSVGElement>> = (props) => ( | ||
<svg width="12" height="8" viewBox="0 0 12 8" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}> | ||
<path d="M1.3938 3.16216L5.02294 6.7913L10.6062 1.20801" stroke={props.stroke ? 'current' : '#F1F2F4'} strokeWidth="1.67" strokeLinecap="round"/> | ||
</svg> | ||
); | ||
export default CheckIcon; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
|
||
const WarningIcon: React.FC<React.SVGProps<SVGSVGElement>> = (props) => ( | ||
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}> | ||
<path fill={props.fill ? "current" : '#FB2414'} fillRule="evenodd" clipRule="evenodd" d="M12 6C12 9.31348 9.3137 12 6 12C2.6863 12 0 9.31348 0 6C0 2.68652 2.6863 0 6 0C9.3137 0 12 2.68652 12 6ZM6 2.6168C6.27671 2.6168 6.50101 2.84121 6.50101 3.11777V6.30527C6.50101 6.58184 6.27671 6.80625 6 6.80625C5.72329 6.80625 5.49899 6.58184 5.49899 6.30527V3.11777C5.49899 2.84121 5.72329 2.6168 6 2.6168ZM6 8.88223C6.27667 8.88223 6.50098 8.65781 6.50098 8.38125C6.50098 8.10469 6.27667 7.88027 6 7.88027C5.72329 7.88027 5.49899 8.10469 5.49899 8.38125C5.49899 8.65781 5.72329 8.88223 6 8.88223Z" /> | ||
</svg> | ||
); | ||
|
||
export default WarningIcon; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { CheckIcon } from '@/assets/icons'; | ||
import React from 'react'; | ||
|
||
const CheckBox: React.FC<{ active: boolean; onClick: () => void }> = ({ | ||
active = false, | ||
onClick, | ||
}) => { | ||
const commonStyle = | ||
'flex justify-center items-center w-[20px] h-[20px] rounded-full'; | ||
return active ? ( | ||
<button onClick={onClick} className={`${commonStyle} bg-primary2`}> | ||
<CheckIcon /> | ||
</button> | ||
) : ( | ||
<button onClick={onClick} className={`${commonStyle} border border-gray5`}> | ||
<CheckIcon stroke="#9299AA" /> | ||
</button> | ||
); | ||
}; | ||
|
||
export default CheckBox; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
import { SettingIcon } from '@/assets/icons'; | ||
|
||
const FriendshipHeaderSettingButton: React.FC<{ onClick: () => void }> = ({ | ||
onClick, | ||
}) => { | ||
return ( | ||
<button onClick={onClick}> | ||
<SettingIcon /> | ||
</button> | ||
); | ||
}; | ||
|
||
export default FriendshipHeaderSettingButton; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react'; | ||
import { WarningIcon } from '@/assets/icons'; | ||
|
||
const WarningLine: React.FC<{ text: string }> = ({ text }) => { | ||
return ( | ||
<div className="flex items-center"> | ||
<WarningIcon /> | ||
<p className="ml-[4px] body2-regular text-point4">{text}</p> | ||
</div> | ||
); | ||
}; | ||
|
||
export default WarningLine; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,81 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { LabelRoundBox, WarningLine } from '@/components/molecules'; | ||
import React, { useState } from 'react'; | ||
|
||
import { BulletNoticeBox } from '../organisms'; | ||
import { LabelRoundBox } from '../molecules'; | ||
import { BulletNoticeBox } from '@/components/organisms'; | ||
import { MiniButton } from '@/components/atoms'; | ||
|
||
const MY_INVITATION_CODE = 'AB12CD3EF'; | ||
import { queryKeys } from '@/hooks/queries/queryKeys'; | ||
import { useAddFriendship } from '@/hooks/queries/friendship'; | ||
import { useBaseQuery } from '@/hooks/queries/useBaseQuery'; | ||
import useToast from '@/hooks/useToast'; | ||
|
||
const AddFriendTemplate: React.FC = () => { | ||
const [myCode, setMyCode] = useState<string>(''); | ||
const [friendInviteCode, setFriendInviteCode] = useState<string>(''); | ||
const [warningVisible, setWarningVisible] = useState<boolean>(false); | ||
const { showToast } = useToast(); | ||
const addFriendship = useAddFriendship({ | ||
onSuccess: () => { | ||
showToast('친구 추가가 완료되었습니다.', 'success'); | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 수정 완료 했습니다 😌 |
||
}); | ||
|
||
const onCopy: () => void = () => { | ||
navigator.clipboard | ||
.writeText(myCode) | ||
.then(() => null) | ||
.writeText(myInviteCode?.data?.inviteCode ?? '') | ||
.then(() => { | ||
showToast('초대 코드가 복사되었습니다.', 'success'); | ||
}) | ||
.catch(() => null); | ||
}; | ||
|
||
useEffect(() => { | ||
setMyCode(MY_INVITATION_CODE); | ||
}, []); | ||
const onAddFriend = () => { | ||
if (friendInviteCode.length < 9) { | ||
setWarningVisible(true); | ||
} else { | ||
addFriendship.mutate({ inviteCode: friendInviteCode }); | ||
} | ||
}; | ||
|
||
const { data: myInviteCode } = useBaseQuery<{ inviteCode: string }>( | ||
queryKeys.MY_INVITE_CODE(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 피드백 감사합니다😊 수정해서 반영해두었습니다 👍🏻 |
||
'/users/me/invite-code', | ||
); | ||
|
||
return ( | ||
<div className="pt-[72px] px-[20px]"> | ||
<LabelRoundBox | ||
label="내 초대 코드" | ||
content={ | ||
<> | ||
<div className="flex"> | ||
<span className="flex-1 outline-none mr-[10px] border-none p-[10px] bg-gray1 rounded-[6px] text-gray8 body1-medium"> | ||
{myCode} | ||
{myInviteCode?.data?.inviteCode} | ||
</span> | ||
<MiniButton label="복사" onClick={onCopy} variant="active" /> | ||
</> | ||
</div> | ||
} | ||
/> | ||
<LabelRoundBox | ||
label="상대 초대 코드 입력" | ||
content={ | ||
<> | ||
<input | ||
placeholder="상대 초대 코드를 입력해주세요." | ||
className="flex-1 outline-none mr-[10px] border-none p-[10px] bg-gray1 rounded-[6px] text-gray8 body1-medium" | ||
/> | ||
<MiniButton label="추가" onClick={onCopy} variant="clickable" /> | ||
<div className="flex mb-[8px]"> | ||
<input | ||
placeholder="상대 초대 코드를 입력해주세요." | ||
className={`flex-1 mr-[10px] p-[10px] bg-gray1 rounded-[6px] text-gray8 body1-medium ${warningVisible ? 'border border-point4' : 'border-none'}`} | ||
value={friendInviteCode} | ||
onChange={(e) => { | ||
setFriendInviteCode(e.target.value); | ||
}} | ||
maxLength={10} | ||
/> | ||
<MiniButton | ||
label="추가" | ||
onClick={onAddFriend} | ||
variant="clickable" | ||
/> | ||
</div> | ||
{warningVisible ? ( | ||
<WarningLine text="9-10자리 초대 코드를 입력해주세요." /> | ||
) : null} | ||
</> | ||
} | ||
/> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이런 형태도 가능할 것 같네요..!🙇♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
분기 파편화 이슈가 생길까봐 고민 했었는데 공유 주신 코드가 훨씬 간결해보이네요 👍🏻☺️ 감사해요!🙇♀️
반영해두었습니다