INtiful / SootheWithMe

같이 달램
https://soothe-with-me.vercel.app/
0 stars 0 forks source link

feat: 로그인 회원가입 api 연결 #88

Closed hakyoung12 closed 1 week ago

hakyoung12 commented 1 week ago

✏️ 작업 내용

📷 스크린샷

서버에러메시지 추가

스크린샷 2024-09-23 오후 4 49 19 스크린샷 2024-09-23 오후 4 49 36

✍️ 사용법

쿠키 사용법

// getCookie 예시
const token = await getCookie('key')
// setCookie
setCookie('key', 'value')
// deleteCookie
deleteCookie('key');

UserContext

  const { user, setUser, isLoading, errorMsg } = useUser();

user: 유저정보

타입: { id: string; email: string; name: string; companyName: string; image: string; createdAt: string; updatedAt: string; } | null 초기값은 null이며, 유저 데이터가 로드되면 해당 유저의 정보를 포함합니다.

setUser: 유저 데이터를 업데이트

타입: (userData: Partial<UserContextType['user']>) => void 추후 유저데이터 변경 시 아래의 코드를 추가하여 클라이언트에 저장된 유저데이터를 변경할 수 있습니다.

setUser(data);

isLoading: 데이터가 로드 중인지 여부

타입: boolean API 호출이 진행 중일 때 true, 완료되면 false로 설정됩니다.

errorMsg: API 호출 중 발생한 오류 메시지

타입: string | null 오류가 없을 경우 null, 오류가 발생하면 해당 오류 메시지를 포함합니다.

🎸 기타