Skip to content

Commit

Permalink
⚡ 잠시 비밀번호가 없는 경우 고려 (#73-4)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaewoong2 committed Oct 30, 2022
1 parent f29e35d commit 0a570af
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/components/hoc/withPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ import React, { ComponentType, useEffect, useState } from 'react'
import useGetUser from '@/hooks/useGetUser'
import { useNavigate } from 'react-router-dom'
import { ModalProvider, useModal } from '@jaewoong2/modal'
import withAuth from './withAuth'

type MessageProps = {
setStatusCancled: () => void
setStatusLoading: () => void
flag: boolean
}

const Message = ({ setStatusCancled, setStatusLoading }: MessageProps) => {
const Message = ({ setStatusCancled, setStatusLoading, flag }: MessageProps) => {
useEffect(() => {
setStatusLoading()
return () => {
setStatusCancled()
if (flag) {
setStatusCancled()
}
}
}, [])

Expand All @@ -33,6 +35,7 @@ const withPassword = (Component: ComponentType) => {
<Message
setStatusCancled={() => setStatus('cancled')}
setStatusLoading={() => setStatus('loading')}
flag={Boolean(user?.userPhone)}
/>
),
modalWidth: '350px',
Expand All @@ -47,8 +50,10 @@ const withPassword = (Component: ComponentType) => {

/* 권한 분기 */
useEffect(() => {
if (!user?.userPhone) {
if (Boolean(user?.userPhone) === false) {
show()
} else {
hide()
}
}, [user])

Expand All @@ -69,7 +74,7 @@ const withPassword = (Component: ComponentType) => {
)
}

return withAuth(HOC)
return HOC
}

export default withPassword

0 comments on commit 0a570af

Please sign in to comment.