-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
닉네임을 이용한 자식 검색 가능 - 존재하지 않는 닉네임이라면 멘트로 알려줌 자녀 초대 - 검색 결과 존재하는 자녀라면 초대가 가능 - 이후 manage 페이지로 이동하여 초대 확인 가능
- Loading branch information
1 parent
534dc41
commit 3c5e6d4
Showing
10 changed files
with
224 additions
and
10 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
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
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,126 @@ | ||
import { useMutation, useSuspenseQuery } from '@tanstack/react-query'; | ||
import React, { useCallback, useState } from 'react'; | ||
import { containerStyles, contentStyles } from './styles'; | ||
import { | ||
findChildByNickname, | ||
getUserInfo, | ||
requestChild, | ||
} from '../../../apis/userApi'; | ||
import { Mascot } from '../../../components/molecules/Mascot'; | ||
import { infoBoxStyles } from '../Manage/styles'; | ||
import { Icon } from '../../../components/atoms/Icon'; | ||
import { HiChevronLeft } from 'react-icons/hi2'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { Typography } from '../../../components/atoms/Typography'; | ||
import { AvatarWithLabel } from '../../../components/molecules/AvatarWithLabel'; | ||
import { getImgSrc } from '../../../utils/userUtil'; | ||
import { HiMagnifyingGlass } from 'react-icons/hi2'; | ||
import TextField from '../../../components/atoms/TextField'; | ||
import { IChild } from '../../../interfaces/userInterface'; | ||
import { MascotCard } from '../../../components/molecules/MascotCard'; | ||
import { Button } from '../../../components/atoms/Button'; | ||
import { showToast } from '../../../utils/toastUtil'; | ||
|
||
export const RequestFetch = () => { | ||
const userinfoQuery = useSuspenseQuery({ | ||
queryKey: ['userinfo'], | ||
queryFn: async () => await getUserInfo(), | ||
}); | ||
|
||
if (userinfoQuery.error && !userinfoQuery.isFetching) { | ||
throw userinfoQuery.error; | ||
} | ||
|
||
const nav = useNavigate(); | ||
const [nickname, setNickname] = useState<string>(''); | ||
const [child, setChild] = useState<IChild | null>(null); | ||
const onChangeNickname = useCallback( | ||
(e: React.ChangeEvent<HTMLInputElement>) => { | ||
setNickname(() => e.target.value); | ||
}, | ||
[nickname], | ||
); | ||
|
||
const { mutate } = useMutation({ | ||
mutationFn: async (nickname: string) => await requestChild(nickname), | ||
onSuccess: (res) => { | ||
showToast('success', res.data.description); | ||
nav('/manage'); | ||
}, | ||
onError: () => showToast('error', '자식 신청에 실패했습니다'), | ||
}); | ||
|
||
return ( | ||
<div className={containerStyles()}> | ||
<Mascot | ||
nickname={userinfoQuery.data.data.nickname} | ||
ment="자녀 정보가 궁금하시군요!!" | ||
classNameStyles="tablet:hidden" | ||
/> | ||
<div className={contentStyles()}> | ||
<div className={infoBoxStyles()}> | ||
<div className="flex justify-center w-full"> | ||
<Icon | ||
color="dark" | ||
classNameStyles="absolute desktop:left-36 tabletB:left-20 mob:left-8" | ||
> | ||
<HiChevronLeft onClick={() => nav('/manage')} /> | ||
</Icon> | ||
<Typography weight="bold" size="xl" color="dark"> | ||
자녀 초대하기 | ||
</Typography> | ||
</div> | ||
<AvatarWithLabel | ||
imageUrl={getImgSrc(userinfoQuery.data.data.gender, 'PARENT')} | ||
label={userinfoQuery.data.data.nickname} | ||
altText="avatarwithlabel" | ||
size="2xl" | ||
classNameStyles="mt-4" | ||
/> | ||
<div className="relative w-full mt-4"> | ||
<TextField label="닉네임" onChange={onChangeNickname} fullWidth /> | ||
<Icon | ||
color="dark" | ||
size="sm" | ||
classNameStyles="absolute top-4 right-4" | ||
> | ||
<HiMagnifyingGlass | ||
onClick={async () => { | ||
await findChildByNickname(nickname) | ||
.then((res) => setChild(res.data)) | ||
.catch(() => setChild(null)); | ||
}} | ||
/> | ||
</Icon> | ||
</div> | ||
<div | ||
className={`w-full mt-4 ${child ? '' : 'flex justify-center items-center p-8'}`} | ||
> | ||
{child ? ( | ||
<MascotCard | ||
key={child.nickname} | ||
childInfo={child} | ||
withTrash={false} | ||
/> | ||
) : ( | ||
'자녀가 존재하지 않습니다' | ||
)} | ||
</div> | ||
</div> | ||
<div className="w-full desktop:px-36 tabletB:px-20 mob:px-8 bottom-16"> | ||
<Button | ||
fullWidth | ||
onClick={() => { | ||
if (child) mutate(child.nickname); | ||
else showToast('error', '초대할 자녀를 검색해주세요'); | ||
}} | ||
> | ||
<Typography weight="bold" size="sm" color="light"> | ||
초대하기 | ||
</Typography> | ||
</Button> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
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,13 @@ | ||
import React, { Suspense } from 'react'; | ||
import { ErrorBoundary } from 'react-error-boundary'; | ||
import { RequestFetch } from './RequestFetch'; | ||
|
||
export const Request = () => { | ||
return ( | ||
<ErrorBoundary fallback={<>에러</>}> | ||
<Suspense fallback={<>로딩중</>}> | ||
<RequestFetch /> | ||
</Suspense> | ||
</ErrorBoundary> | ||
); | ||
}; |
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,13 @@ | ||
import { tv } from 'tailwind-variants'; | ||
|
||
export const containerStyles = tv({ | ||
base: 'flex items-center justify-center w-full h-auto tablet:flex-col', | ||
}); | ||
|
||
export const contentStyles = tv({ | ||
base: 'flex flex-col items-center justify-between gap-y-4 bg-white desktop:w-[48rem] desktop:h-[48rem] desktop:rounded-lg desktop:py-12 tablet:w-full tablet:h-full tablet:py-8', | ||
}); | ||
|
||
export const infoBoxStyles = tv({ | ||
base: 'relative w-full desktop:px-36 tabletB:px-20 mob:px-8', | ||
}); |
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