Skip to content

Commit

Permalink
Merge pull request #150 from Team-JustPay/feature/#126
Browse files Browse the repository at this point in the history
Feature/#126
  • Loading branch information
hyunwookchung authored Jan 12, 2023
2 parents 3accc66 + b8994c7 commit 228defc
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 18 deletions.
4 changes: 4 additions & 0 deletions api/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ export const getMySellInfo = async (isSaled: boolean) => {
export const getMyInfo = async () => {
return await userAPI.get(`/my/info?addressSplit=true`);
};

export const getAlarm = async () => {
return await userAPI.get(`my/notifications`);
};
10 changes: 9 additions & 1 deletion apiHooks/user.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useQuery, useMutation } from '@tanstack/react-query';
import { getmyBuy, getmyInfo, putmyInfo, getMySellInfo, getMyInfo } from 'api/user';
import { getmyBuy, getmyInfo, putmyInfo, getMySellInfo, getMyInfo, getAlarm } from 'api/user';
import { MyInfoType } from 'types/recoil/myInfo';

export const useGetmyBuy = (isPurchased: boolean) => {
Expand Down Expand Up @@ -41,3 +41,11 @@ export const useGetMyInfo = () => {
},
});
};

export const useGetAlarm = () => {
return useQuery(['get/my/notifications'], () => getAlarm(), {
onError: (error) => {
console.log(error);
},
});
};
2 changes: 1 addition & 1 deletion components/common/GNB.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function GNB({ currentGNB }: GNBProps) {

return (
<Root>
<button type="button" className="alram" onClick={handleClickGNBOption}>
<button type="button" className="alarm" onClick={handleClickGNBOption}>
{currentGNB === 'alram' ? <AlramColor /> : <Alram />}
</button>
<button type="button" className="buy" onClick={handleClickGNBOption}>
Expand Down
42 changes: 26 additions & 16 deletions pages/my/alram.tsx → pages/my/alarm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,41 @@ import MainLogo from 'public/assets/icons/justpay_symbol_logo.svg';
import BuyIcon from 'public/assets/icons/notification_buy.svg';
import SellIcon from 'public/assets/icons/notification_sell.svg';
import React from 'react';
import { useGetAlarm } from 'apiHooks/user';

export default function alram() {
const data = {
notificationType: '판매 알림',
message: '이런저런 메시지',
create: '2022.12.20 15:40',
};
const { data: myAlarm } = useGetAlarm();

console.log(myAlarm);
const data = [
{
notificationType: '판매 알림',
message: '이런저런 메시지',
create: '2022.12.20 15:40',
},
];

return (
<Root>
<LogoWrapper>
<MainLogo />
</LogoWrapper>
<TradeAlramText>중요한 거래 알림을 확인하세요!</TradeAlramText>
<Notificontent>
<NotificationHeader>
<NotificationText>
{data.notificationType === '구매 알림' ? <BuyIcon /> : <SellIcon />}
{data.notificationType}
</NotificationText>
<NotificationRight>{data.create}</NotificationRight>
</NotificationHeader>
<NotificationMessage>{data.message}</NotificationMessage>
</Notificontent>

<GNB currentGNB={'alram'} />
{myAlarm?.data.data.map((item: { notificationType: string; createdAt: string; message: string }) => (
<Notificontent>
<NotificationHeader>
<NotificationText>
{item.notificationType === '구매 알림' ? <BuyIcon /> : <SellIcon />}
{item.notificationType}
</NotificationText>
<NotificationRight>{item.createdAt}</NotificationRight>
</NotificationHeader>
<NotificationMessage>{item.message}</NotificationMessage>
</Notificontent>
))}

<GNB currentGNB={'alarm'} />
</Root>
);
}
Expand Down

0 comments on commit 228defc

Please sign in to comment.