Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 가게 세부 페이지 찜버튼 추가 #68

Merged
merged 9 commits into from
Nov 13, 2024

Conversation

l-lyun
Copy link
Contributor

@l-lyun l-lyun commented Nov 5, 2024

#️⃣연관된 이슈

resolves: #37

📝작업 내용

MarketType.ts

export type MarketType = {
  id: number;
  name: string;
  pickupStartAt: number;
  pickupEndAt: number;
  address: string;
  products: ProductType[];
  images: string[];
  hasLike: boolean;
  // TODO: 논의 필요
  marketId?: number;
};

찜 하트 아이콘 컴포넌트 제작 및 가게 상세페이지에 넣었습니다.

스크린샷 (선택)

image

💬리뷰 요구사항(선택)

디자인 적용 좀 해보려고 타입도 바꾸고 이것저것 넣다
백엔드 더미에 태그가 없어 반찬 컴포넌트가 뜨지 않아 다시 다 원복하고 올립니다.

승민이형 다른 코드 부분 최대한 안건드리고 찜 아이콘만 추가했습니다.

Copy link
Contributor

@99mini 99mini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

코드 확인했어요~ api 관련해서 코멘트 확인 부탁드립니다

@@ -117,6 +117,7 @@ const signInWithKakao = async (): Promise<SessionType | null> => {
console.log('카카오 로그인 성공:', response);

return {
//TODO: JWT 토큰으로 대체 필요
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 19 to 37
try {
let res;
if (marketIsLiked) {
console.log('DEL');
res = await apiClient.del<CommonResponseType | null>(
`/market/${marketId}/like`,
);
} else {
console.log('POST');
res = await apiClient.post<CommonResponseType | null>(
`/market/${marketId}/like`,
);
}
handleSubscribe();
return res;
} catch (error) {
console.error('Error subscribe', error);
return null;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

각 서버에 요청을 보내는 코드들은 apis/ 폴더 아래에 파일을 선언해서 추가해주세요. apis/Market.ts에 함수들을 추가해주면 되겠네요. updateMarketLike 와 같은 함수이름으로 하면 좋겟습니다.

+ javascript에서 빈 객체({}) 또한 truly 이기 때문에 해당 코드는 res의 값이 타당하지 않을 수 있을 것 같습니다. 지금의 api문서에서 del은 200코드, post는 201 코드를 반환하니 코드가 타당한지로 판단하는 게 좋을 것 같네요.

스크린샷 2024-11-05 오후 1 36 10

+ 카톡으로 상민이형이랑 나눈 api endpoint관련해서는 확정되면 그렇게 수정하시죠.

Comment on lines +12 to +13
// TODO: 논의 필요
marketId?: number;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id는 아마도 string 일것같아요

Comment on lines 1 to 4
export type CommonResponseType = {
code: number;
message: string;
};
Copy link
Contributor

@99mini 99mini Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response 타입까지 알 필요는 없을 것 같아요. 그래도 강력한 타입을 지원하려면 apiClient에서 선언하는 rest method의 구현에서 사용할 수는 있을 것 같습니다.

// CommonResponseType.ts
export type CommonResponseType<T> = {
  code: number;
  message: string;
  data?: T;
};
// ApiClient.ts
const get = async <T>(url: string): Promise<T | null> => {
  try {
    const res: AxiosResponse<CommonResponseType<T>> = await this.axiosInstance.get(url);

    if (res.data.code === 200 && res.data.data) {
      return res.data.data;
    }

    return null;
  } catch (error) {
    console.error(error);
    return null;
  }
};

@99mini 99mini assigned l-lyun and unassigned 99mini and itslitulinchpin2 Nov 5, 2024
@l-lyun l-lyun merged commit 2aeed1a into main Nov 13, 2024
1 check passed
@l-lyun l-lyun deleted the feature/market-detail-add-subscribe branch November 13, 2024 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(client): 키워드 및 가게 별 찜하기 기능
3 participants