-
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.
- Loading branch information
Showing
21 changed files
with
181 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React, { createContext, useContext, useState, ReactNode } from 'react' | ||
|
||
interface AuthContextType { | ||
isLoggedIn: boolean | ||
login: (email: string, token: string) => void | ||
} | ||
|
||
// 초기값 undefined | ||
const AuthContext = createContext<AuthContextType | undefined>(undefined) | ||
|
||
// 커스텀 훅 인증 없을 때 오류 알림 | ||
export const useAuth = () => { | ||
const context = useContext(AuthContext) | ||
if (!context) { | ||
throw new Error('useAuth must be used within an AuthProvider') | ||
} | ||
return context | ||
} | ||
|
||
export const AuthProvider = ({ children }: { children: ReactNode }) => { | ||
const [isLoggedIn, setIsLoggedIn] = useState<boolean>(false) | ||
|
||
const login = (email: string, token: string) => { | ||
localStorage.setItem('user_email', email) | ||
document.cookie = `accessToken=${token}; path=/` | ||
setIsLoggedIn(true) | ||
} | ||
|
||
return ( | ||
<AuthContext.Provider value={{ isLoggedIn, login }}> | ||
{children} | ||
</AuthContext.Provider> | ||
) | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
26 changes: 26 additions & 0 deletions
26
weatherfit_refactoring/src/Components/Atoms/Text/TextStore.tsx
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,26 @@ | ||
export enum TextStyle { | ||
GMARKET_TEXT = 'GMARKET_TEXT', | ||
NANUM_TEXT = 'NANUM_TEXT', | ||
CAFE_TEXT = 'CAFA_TEXT', | ||
} | ||
|
||
interface Props { | ||
textStyle: TextStyle | ||
style?: string | ||
children?: React.ReactNode | ||
} | ||
|
||
export default function TextStore({ textStyle, style, children }: Props) { | ||
const selectText = (): React.ReactNode => { | ||
switch (textStyle) { | ||
case TextStyle.GMARKET_TEXT: | ||
return <p className={`${style} font-gmarketsans`}>{children}</p> | ||
case TextStyle.NANUM_TEXT: | ||
return <p className={`${style} font-NanumSquareRound`}>{children}</p> | ||
case TextStyle.CAFE_TEXT: | ||
return <p className={`${style} font-Cafe24SsurroundAir`}>{children}</p> | ||
} | ||
} | ||
|
||
return <>{selectText()}</> | ||
} |
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
47 changes: 47 additions & 0 deletions
47
weatherfit_refactoring/src/Components/Molecules/MainHeader.tsx
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,47 @@ | ||
'use client' | ||
|
||
import IconStore, { IconStyle } from '../Atoms/Icon/IconStore' | ||
import ButtonStore, { ButtonStyle } from '../Atoms/Button/ButtonStore' | ||
import BoxStore, { BoxStyle } from '../Atoms/Box/BoxStore' | ||
import { MouseEventHandler } from 'react' | ||
import { useRouter } from 'next/navigation' | ||
import Link from 'next/link' | ||
|
||
interface Props { | ||
title: string | ||
btnText?: string | ||
iconStyleCase?: IconStyle | ||
buttonStyleCase?: ButtonStyle | ||
onClickFunction?: MouseEventHandler<HTMLButtonElement> | undefined | ||
onClickFunction2?: () => void | ||
} | ||
|
||
export default function MainHeader({ | ||
title, | ||
btnText, | ||
iconStyleCase, | ||
buttonStyleCase, | ||
onClickFunction, | ||
onClickFunction2, | ||
}: Props) { | ||
const router = useRouter() | ||
|
||
const onClickToMain = | ||
title === '옷늘날씨' ? () => router.push('/') : undefined // 또는 다른 함수 | ||
|
||
return ( | ||
<div className="relative flex items-center justify-between h-[50px] my-1 pb-1"> | ||
<BoxStore | ||
boxStyle={BoxStyle.BOX_BLUE} | ||
style={`absolute left-1/2 transform -translate-x-1/2 px-2 h-[30px] font-neurimboGothic text-[22px] pb-[7px] shadow-[7px_7px_1px] flex items-center ${title === '옷늘날씨' ? 'cursor-pointer' : ''}`} | ||
onClickFunction={onClickToMain}> | ||
{title} | ||
</BoxStore> | ||
<Link | ||
href={`/login`} | ||
className="absolute right-[19px] font-gmarketsans text-black"> | ||
로그인 | ||
</Link> | ||
</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
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
Oops, something went wrong.