Skip to content

Commit

Permalink
[Feat] [GGFE-195] 선물하기 api 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
hyobb109 committed Aug 30, 2023
1 parent 108359b commit 2a250e9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
5 changes: 5 additions & 0 deletions components/Layout/NotiBar/NotiItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export default function NotiItem({ data }: NotiItemProps) {
style: styles.canceldByMan,
content: message,
},
// TODO: 고치기
GIFT: {
style: styles.gift,
content: message,
},
};

const notiWrapperStyle = isChecked ? styles.readWrap : styles.unreadWrap;
Expand Down
2 changes: 1 addition & 1 deletion hooks/modal/store/purchase/useBuyModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const useBuyModal = (purchasedItem: Purchase) => {
const onPurchase = async () => {
try {
await instance.post(
`pingpong/items/purchases/${purchasedItem.itemId}`,
`/pingpong/items/purchases/${purchasedItem.itemId}`,
null
);
alert(`구매 성공!`);
Expand Down
19 changes: 7 additions & 12 deletions hooks/modal/store/purchase/useGiftModal.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// import { useEffect, useState } from 'react';
import { useSetRecoilState } from 'recoil';
import { Gift, GiftRequest } from 'types/itemTypes';
import { instanceInManage } from 'utils/axios';
import { mockInstance } from 'utils/mockAxios';
import { instance } from 'utils/axios';
import { errorState } from 'utils/recoil/error';
import { modalState } from 'utils/recoil/modal';

Expand All @@ -12,22 +10,19 @@ const useGiftModal = (gift: Gift) => {
const data: GiftRequest = {
ownerId: gift.ownerId,
};
// TODO: mockInstance 대신 instance로 변경하기

const onPurchase = async () => {
if (gift.ownerId === '') {
// TODO: alert 대신 toast/snackbar로 변경하기?
alert('선물할 유저를 선택해주세요.');
return;
}
try {
const res = await mockInstance.post(`/items/gift/${gift.itemId}`, data);
const res = await instance.post(
`/pingpong/items/gift/${gift.itemId}`,
data
);
if (res.status === 201) {
// TODO: alert 대신 toast 띄우거나 아무것도 안하기
alert(`${gift.ownerId}님께 선물이 전달되었습니다`);
await instanceInManage.post(`/notifications`, {
intraId: gift.ownerId,
message: `선물이 도착했어요🎁 상점 보관함에서 선물과 발송인을 확인하세요!`,
});
alert(`${gift.ownerId}님께 선물이 전달되었습니다.`);
}
} catch (error) {
setError('HB02');
Expand Down
7 changes: 7 additions & 0 deletions styles/Layout/NotiItem.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
border: 0.5px solid rgba(174, 141, 178, 1);
}
.unreadWrap {
word-break: keep-all;
&.imminent {
color: rgba(255, 255, 255, 1);
background: rgba(166, 100, 176, 1);
Expand All @@ -47,6 +48,12 @@
background: rgba(204, 173, 218, 1);
border: 0.5px solid rgba(237, 116, 167, 1);
}
// TODO: 스타일 수정
&.gift {
color: rgba(255, 255, 255, 1);
background: rgba(235, 152, 187, 1);
border: 0.5px solid rgba(166, 100, 176, 1);
}
}

.date {
Expand Down

0 comments on commit 2a250e9

Please sign in to comment.