Skip to content

Commit

Permalink
♻️ :: 프로필 response변경
Browse files Browse the repository at this point in the history
  • Loading branch information
wjzlskxk committed Jul 11, 2024
1 parent 1d0c467 commit db92245
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/components/home/community/postDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ const PostDetail = () => {
<S.Main>
<S.WriterInfo>
{communityData?.data.profileImage !== null && communityData?.data.profileImage !== undefined ? (
<Image src={communityData.data.profileImage} alt="프로필 이미지" />
<Image src={communityData.data.profileImage} alt="프로필 이미지" width={100} height={100} />
) : (
<Image src={Profile} alt="프로필 이미지" />
)}
<div>
<h1>{communityData?.data.userId}</h1>
<h1>{communityData?.data.userName}</h1>
<span>{convertDate(communityData?.data.modifiedDateTime!!)}</span>
</div>
</S.WriterInfo>
Expand Down
21 changes: 6 additions & 15 deletions src/hooks/auth/login/useLogin.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
"use client";
import dearToast from "@/libs/Swal/Swal";
import axios from "axios";
import axios, { AxiosError } from "axios";
import { useRouter } from "next/navigation";
import React, { useCallback, useEffect, useState } from "react";
import { useRecoilState } from "recoil";
import config from "src/config/config.json";
import {
ACCESS_TOKEN_KEY,
REFRESH_TOKEN_KEY,
} from "src/constants/token/token.constants";
import { ACCESS_TOKEN_KEY, REFRESH_TOKEN_KEY } from "src/constants/token/token.constants";
import token from "src/libs/token/token";
import { ErrorStateAtom } from "src/store/common/common.store";
import { LoginParam, LoginResponse } from "src/types/auth/auth.type";
Expand All @@ -19,36 +16,30 @@ const useLogin = () => {
userId: "",
password: "",
});
const [errorState, setErrorState] =
useRecoilState<Record<string, string>>(ErrorStateAtom);
const [errorState, setErrorState] = useRecoilState<Record<string, string>>(ErrorStateAtom);
const handleLoginChange = useCallback(
(e: React.ChangeEvent<HTMLInputElement>) => {
const { value, name } = e.target;
setLoginData((prev) => ({ ...prev, [name]: value }));
},
[setLoginData]
[setLoginData],
);

const handleConfirmButton = async () => {
try {
await axios
.post<LoginResponse>(`${config.serverUrl}/auth`, {
.post<LoginResponse>(`/auth`, {
email: LoginData.userId,
password: LoginData.password,
})
.then((res) => {
token.setToken(ACCESS_TOKEN_KEY, res.data.data.accessToken);
token.setToken(REFRESH_TOKEN_KEY, res.data.data.refreshToken);

dearToast.sucessToast("로그인 성공");
router.push("/");
});
} catch (e) {
dearToast.errorToast("로그인 실패");
setErrorState({
...errorState,
password: "아이디 및 비밀번호를 확인해주세요.",
});
dearToast.errorToast((e as AxiosError).message);
}
};

Expand Down
1 change: 1 addition & 0 deletions src/types/community/post/post.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface CommunityPostById {
title: string;
content: string;
userId: number;
userName: string;
imagePathList: string[];
createdDateTime: string;
modifiedDateTime: string;
Expand Down

0 comments on commit db92245

Please sign in to comment.