Skip to content

Commit

Permalink
fix: ESLint 규칙에 맞춰서 수정
Browse files Browse the repository at this point in the history
추가적으로 로그인 페이지 SplashTop 위치도 수정
  • Loading branch information
nebulaBdj committed Oct 26, 2024
1 parent c23ccda commit f830294
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 33 deletions.
15 changes: 8 additions & 7 deletions src/app/auth/callback/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ export default function LoginCheck() {
const state = searchParams.get('state')

const sendUserHomeOrStart = (userState: string) => {
if (userState == 'GUEST') router.push('/start')
if (userState == 'MEMBER') router.push('/home')
if (userState === 'GUEST') router.push('/start')
if (userState === 'MEMBER') router.push('/home')
}

const getUserData = async (socialType: string, sendDataArr: SendData[]) => {
let url: string = `https://cnergy.p-e.kr/v1/oauth/login/${socialType}?`
for (let i = 0; i < sendDataArr.length; i++) {
if (i == 0) {
for (let i = 0; i < sendDataArr.length; i += 1) {
if (i === 0) {
url += `${sendDataArr[i].name}=${sendDataArr[i].value}`
continue
}

url += `&${sendDataArr[i].name}=${sendDataArr[i].value}`
if (i !== 0) {
url += `&${sendDataArr[i].name}=${sendDataArr[i].value}`
}
}

try {
Expand All @@ -39,7 +40,7 @@ export default function LoginCheck() {

const data = await res.json()

console.log('reponse Data', data)
// console.log('reponse Data', data)

// 토근 설정
localStorage.setItem('accessToken', data.data.accessToken)
Expand Down
29 changes: 11 additions & 18 deletions src/app/components/Oauth/OauthBtn.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
import { useRouter } from 'next/navigation'
import { OauthBtnProps } from './type'

export default function OauthBtn(data: OauthBtnProps) {
export default function OauthBtn({ auth_uri, type, text }: OauthBtnProps) {
const router = useRouter()

const handleSocialLogin = async () => {
router.push(`${data.auth_uri}`)
router.push(`${auth_uri}`)
}

let btnStyle: string = ''

if (type === 'kakao') btnStyle = 'bg-[#FFE819]'
if (type === 'naver') btnStyle = 'bg-[#03C75A]'
if (type === 'google') btnStyle = 'bg-white border'

return (
<button
onClick={() => handleSocialLogin()}
type="button"
className={`
${data.style}
${
data.type === 'kakao'
? 'bg-[#FFE819]'
: data.type === 'naver'
? 'bg-[#03C75A]'
: data.type === 'google'
? 'bg-white border'
: ''
}
${btnStyle}
w-[342px] h-[56px] flex justify-center items-center rounded-12 text-black font-semibold mb-10
`}
>
<img
src={`/images/${data.type}-icon.png`}
alt={`${data.type}`}
className="mr-8"
/>
{data.text}로 시작하기
<img src={`/images/${type}-icon.png`} alt={`${type}`} className="mr-8" />
{text}로 시작하기
</button>
)
}
3 changes: 1 addition & 2 deletions src/app/components/Oauth/SocialTypeData.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { OauthBtnData } from './type'

export const social_types: OauthBtnData[] = [
export const socialTypes: OauthBtnData[] = [
{
id: 1,
type: 'kakao',
Expand All @@ -18,6 +18,5 @@ export const social_types: OauthBtnData[] = [
type: 'google',
text: '구글',
auth_uri: 'https://cnergy.p-e.kr/v1/oauth/google',
style: 'border',
},
]
1 change: 0 additions & 1 deletion src/app/components/Oauth/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export interface OauthBtnData {
type: string
text: string
auth_uri: string
style?: string
}

export type OauthBtnProps = Omit<OauthBtnData, 'id'>
9 changes: 4 additions & 5 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { motion } from 'framer-motion'
import SplashLogo from '@/components/Icons/SplashLogo'
import SplashTop from '@/components/Icons/SplashTop'
import SplashBottom from '@/components/Icons/SplashBottom'
import { social_types } from './components/Oauth/SocialTypeData'
import { socialTypes } from './components/Oauth/SocialTypeData'
import OauthBtn from './components/Oauth/OauthBtn'

export default function Home() {
Expand Down Expand Up @@ -47,7 +47,7 @@ export default function Home() {

<motion.div
initial={{ x: 0, y: -200, opacity: 1 }}
animate={{ x: 0, y: 0, opacity: 1 }}
animate={{ x: 0, y: -17, opacity: 1 }}
transition={{ duration: 0.5 }}
>
<SplashTop
Expand Down Expand Up @@ -84,15 +84,14 @@ export default function Home() {
animate={{ y: 0, opacity: 1 }}
transition={{ duration: 0.5 }}
>
{social_types &&
social_types.map((socialData) => {
{socialTypes &&
socialTypes.map((socialData) => {
return (
<OauthBtn
key={socialData.id}
type={socialData.type}
text={socialData.text}
auth_uri={socialData.auth_uri}
style={socialData.style && socialData.style}
/>
)
})}
Expand Down

0 comments on commit f830294

Please sign in to comment.