-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 설정 팝업 관련 UI 구현 및 API 연동 (#135)
* feat: 설정 팝업 UI 관련 작업 * feat: 계정 설정 팝업 API 연동 및 회원 탈퇴 API 연동 (카카오 로그인 시에만 회원 탈퇴 가능) * style: lint 실행
- Loading branch information
Showing
24 changed files
with
781 additions
and
77 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
apps/admin/src/components/AccountDeleteForm/AccountDeleteForm.styles.ts
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,60 @@ | ||
import { mq_lg } from '@boolti/ui'; | ||
import styled from '@emotion/styled'; | ||
|
||
const AccountDeleteForm = styled.form` | ||
padding: 24px 0; | ||
${mq_lg} { | ||
padding: 0; | ||
} | ||
`; | ||
|
||
const AccountDeleteFormDescription = styled.p` | ||
${({ theme }) => theme.typo.b3}; | ||
color: ${({ theme }) => theme.palette.grey.g90}; | ||
margin-bottom: 12px; | ||
line-height: 24px; | ||
`; | ||
|
||
const AccountDeleteFormTextArea = styled.textarea` | ||
width: 100%; | ||
padding: 12px; | ||
border: 1px solid ${({ theme }) => theme.palette.grey.g20}; | ||
border-radius: 4px; | ||
background-color: ${({ theme }) => theme.palette.grey.w}; | ||
color: ${({ theme }) => theme.palette.grey.g90}; | ||
${({ theme }) => theme.typo.b3}; | ||
&:placeholder-shown { | ||
border: 1px solid ${({ theme }) => theme.palette.grey.g20}; | ||
color: ${({ theme }) => theme.palette.grey.g30}; | ||
} | ||
&:focus { | ||
border: 1px solid ${({ theme }) => theme.palette.grey.g90}; | ||
} | ||
&:disabled { | ||
background: ${({ theme }) => theme.palette.grey.g10}; | ||
border: 1px solid ${({ theme }) => theme.palette.grey.g20}; | ||
color: ${({ theme }) => theme.palette.grey.g40}; | ||
} | ||
&::placeholder { | ||
color: ${({ theme }) => theme.palette.grey.g30}; | ||
} | ||
`; | ||
|
||
const AccountDeleteFormButtonWrapper = styled.div` | ||
display: flex; | ||
justify-content: flex-end; | ||
gap: 8px; | ||
margin-top: 32px; | ||
`; | ||
|
||
export default { | ||
AccountDeleteForm, | ||
AccountDeleteFormDescription, | ||
AccountDeleteFormTextArea, | ||
AccountDeleteFormButtonWrapper, | ||
}; |
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,86 @@ | ||
import { Button } from '@boolti/ui'; | ||
import Styled from './AccountDeleteForm.styles'; | ||
import { useForm } from 'react-hook-form'; | ||
import { useDeleteMe, useLogout } from '@boolti/api'; | ||
import { useAuthAtom } from '~/atoms/useAuthAtom'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { PATH } from '~/constants/routes'; | ||
|
||
export interface AccountDeleteFormInputs { | ||
reason: string; | ||
} | ||
|
||
interface AccountDeleteFormProps { | ||
oauthType?: 'KAKAO' | 'APPLE'; | ||
onClose: () => void; | ||
} | ||
|
||
const AccountDeleteForm = ({ oauthType, onClose }: AccountDeleteFormProps) => { | ||
const navigate = useNavigate(); | ||
|
||
const deleteMeMutation = useDeleteMe(); | ||
const { removeToken } = useAuthAtom(); | ||
const logoutMutation = useLogout({ | ||
onSuccess: () => { | ||
removeToken(); | ||
}, | ||
}); | ||
const { | ||
register, | ||
handleSubmit, | ||
reset, | ||
formState: { isValid }, | ||
} = useForm<AccountDeleteFormInputs>(); | ||
|
||
const submitHandler = async (data: AccountDeleteFormInputs) => { | ||
let appleIdAuthorizationCode: string | undefined = undefined; | ||
|
||
// TODO: 애플 로그인 시 탈퇴 로직 작성 | ||
if (oauthType === 'APPLE') { | ||
const appleAuthData = await window.AppleID?.auth.signIn(); | ||
|
||
appleIdAuthorizationCode = appleAuthData?.authorization.code; | ||
} | ||
|
||
await deleteMeMutation.mutateAsync({ | ||
reason: data.reason, | ||
appleIdAuthorizationCode, | ||
}); | ||
await logoutMutation.mutateAsync(); | ||
|
||
onClose(); | ||
navigate(PATH.INDEX); | ||
}; | ||
|
||
return ( | ||
<Styled.AccountDeleteForm onSubmit={handleSubmit(submitHandler)}> | ||
<Styled.AccountDeleteFormDescription> | ||
삭제 이유를 알려 주세요. 주신 의견 참고하여 더 나은 서비스를 제공하는 불티가 되겠습니다. | ||
</Styled.AccountDeleteFormDescription> | ||
<Styled.AccountDeleteFormTextArea | ||
placeholder="예) 계정 삭제 후 재 가입할게요" | ||
rows={3} | ||
autoFocus | ||
{...register('reason', { required: true })} | ||
/> | ||
<Styled.AccountDeleteFormButtonWrapper> | ||
<Button | ||
type="button" | ||
colorTheme="line" | ||
size="medium" | ||
onClick={() => { | ||
onClose(); | ||
reset(); | ||
}} | ||
> | ||
취소하기 | ||
</Button> | ||
<Button type="submit" colorTheme="primary" size="medium" disabled={!isValid}> | ||
삭제하기 | ||
</Button> | ||
</Styled.AccountDeleteFormButtonWrapper> | ||
</Styled.AccountDeleteForm> | ||
); | ||
}; | ||
|
||
export default AccountDeleteForm; |
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
Oops, something went wrong.