Skip to content

Commit

Permalink
Merge branch 'main' into feature/admin
Browse files Browse the repository at this point in the history
  • Loading branch information
sunglitter committed Dec 9, 2024
2 parents f062bd2 + d6efd79 commit a2e9d87
Show file tree
Hide file tree
Showing 97 changed files with 6,269 additions and 367 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
.env.development.local
.env.test.local
.env.production.local
/dist

npm-debug.log*
yarn-debug.log*
yarn-error.log*
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"javascriptreact",
"typescript",
"typescriptreact"
]
],
"compile-hero.disable-compile-files-on-did-save-code": true
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5,341 changes: 5,341 additions & 0 deletions dist/assets/index-4YtmX69h.js

Large diffs are not rendered by default.

Binary file added dist/favicon.ico
Binary file not shown.
Binary file added dist/images/apple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/images/arrow-left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/images/bell.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/images/chat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/images/chatlist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/images/chatlist_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/images/check.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/images/comment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/images/location.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/images/location_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/images/login-compl.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/images/login1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/images/login10.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/images/login11.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/images/login2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/images/login3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/images/login4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/images/login5.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/images/login6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/images/login7.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/images/login8.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/images/login9.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/images/myposts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/images/myposts_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/images/mypostscheck.png
Binary file added dist/images/mypostscheck_on.png
Binary file added dist/images/naverlogo.png
Binary file added dist/images/notification.png
Binary file added dist/images/notification_on.png
Binary file added dist/images/orderlist.png
Binary file added dist/images/orderlist_on.png
Binary file added dist/images/origin.png
Binary file added dist/images/qricon.png
Binary file added dist/images/refund.png
Binary file added dist/images/refund_on.png
Binary file added dist/images/search.png
Binary file added dist/images/setting.png
Binary file added dist/images/setting_on.png
Binary file added dist/images/towel.jpeg
Binary file added dist/images/trenchcoat.jpeg
Binary file added dist/images/vacuum.png
Binary file added dist/images/wish.png
Binary file added dist/images/wish_on.png
Binary file added dist/images/wishlist.png
Binary file added dist/images/wishlist_on.png
21 changes: 21 additions & 0 deletions dist/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<!-- 구글 폰트 로드 -->
<!-- <link rel="preconnect" href="https://fonts.googleapis.com" /> -->

<!-- 아이콘 설정 -->
<!-- <link rel="" href="" /> -->

<!-- 뷰포트 설정 -->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<!-- 페이지 타이틀 설정 -->
<title>Good-Buy-Us</title>
<script type="module" crossorigin src="/assets/index-4YtmX69h.js"></script>
</head>
<body>
<div id="root"></div>
</body>
</html>
Expand Down
Binary file added dist/logo192.png
Binary file added dist/logo512.png
25 changes: 25 additions & 0 deletions dist/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions dist/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
Binary file added public/images/apple.png
Binary file added public/images/towel.jpeg
Binary file added public/images/trenchcoat.jpeg
Binary file added public/images/vacuum.png
119 changes: 111 additions & 8 deletions src/api/mypageApi.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,138 @@
import axiosInstance from './axiosInstance';

export type MyPostType = {
availableNumber: number;
category: string;
closeAt: null;
communityPostId: number;
createdAt: string;
description: string;
imageUrls: string[];
nickname: string;
paymentDeadline: null;
period: number;
productUrl: string;
status: string;
title: string;
totalAmount: number;
unitAmount: number;
userId: number;
};

export type GroupPurchaseType = {
communityPostId: number;
title: string;
totalAmount: number;
description: string;
productUrl: string;
category: string;
availableNumber: number;
createdAt: string;
period: number;
closeAt: null;
unitAmount: number;
imageUrls: string[];
status: string;
userId: number;
nickname: string;
paymentDeadline: null;
};

export type OrderType = {
delivery: null | string;
productName: string;
price: number;
orderDate: string;
paymentStatus: string;
payment_key: null | string;
price: number;
productName: string;
quantity: number;
delivery: null | string;
postId: number;
url: string;
};

export const postPasswordVerify = async (body: { currentPassword: string }) => {
const response = await axiosInstance.post(`/mypage/verfiy`, body);
const response = await axiosInstance.post(`/api/mypage/verify`, body);

return response.data;
};

export const postPasswordChange = async (body: { newPassword: string }) => {
const response = await axiosInstance.post(`/mypage/change`, body);
const response = await axiosInstance.post(`/api/mypage/change`, body);

return response.data;
};

export const postLocationChange = async (body: { newAddress: string }) => {
const response = await axiosInstance.post(`/mypage/changeneighbor`, body);
export const putLocationChange = async (body: { newAddress: string }) => {
const response = await axiosInstance.put(`/api/mypage/changeneighbor`, body);

return response.data;
};

export const getOrderList = async () => {
const response = await axiosInstance.get(`/mypage/orders`);
const response = await axiosInstance.get(`/api/mypage/orders`);

if (response.status !== 204) {
return response.data;
} else {
return [];
}
};

export const getRefundList = async () => {
const response = await axiosInstance.get(`/api/mypage/refund_orders`);

return response.data;
};

export const getUser = async () => {
const response = await axiosInstance.get(`/api/mypage`);

return response.data;
};

export const getCommunity = async () => {
const response = await axiosInstance.get(`/api/mypage/community`);

return response.data;
};

export const getMyPostList = async () => {
const response = await axiosInstance.get(`/api/mypage/post`);

return response.data;
};

export const deleteMyPost = async (id: string) => {
const response = await axiosInstance.delete(`/api/mypage/post/${id}`);

return response.data;
};

export const postProductCancel = async (body: {
paymentKey: string;
cancelReason: string;
}) => {
const response = await axiosInstance.post(
`/api/v1/main-payments/cancel`,
body
);

return response.data;
};

export const putEditProfile = async (file: File) => {
const formData = new FormData();

formData.append('profile', file);
const response = await axiosInstance.put(
`/api/mypage/editprofile`,
formData,
{
headers: {
'Content-Type': 'multipart/form-data',
},
}
);

return response.data;
};
78 changes: 33 additions & 45 deletions src/components/common/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
import React, { useEffect, useState } from 'react';
import React, { useState } from 'react';
import { Link } from 'react-router-dom';
import styled from 'styled-components';
// import cart from '../../assets/icons/icon.png';
import cart from '../../assets/icons/icon.png';
import logo from '../../assets/icons/goodbuyus-logo.svg';
import menu from '../../assets/icons/menu.svg';
import { useAuth } from '../../context/AuthContext';

const Header = () => {
const [isLoggedIn, setIsLoggedIn] = useState(false);
const [isAdmin, setIsAdmin] = useState(false);
const [isUser, setIsUser] = useState(false);
const { isLoggedIn, isAdmin, logout } = useAuth();
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);

useEffect(() => {
const token = localStorage.getItem('token');
const userRole = localStorage.getItem('role');

setIsLoggedIn(!!token);
setIsAdmin(userRole === 'ROLE_ADMIN');
setIsUser(userRole === 'ROLE_USER');
}, []);

const toggleMobileMenu = () => {
setIsMobileMenuOpen(!isMobileMenuOpen);
};

const handleCommunityClick = (
e: React.MouseEvent<HTMLAnchorElement, MouseEvent>
) => {
if (!isUser && !isAdmin) {
if (!isLoggedIn || !isAdmin) {
e.preventDefault();
alert('로그인 후 이용할 수 있는 페이지입니다.');
setIsMobileMenuOpen(!isMobileMenuOpen);
Expand Down Expand Up @@ -71,12 +62,14 @@ const Header = () => {
</StyledLink>
</NavItem>
<NavItem>
<StyledLink
to={isAdmin ? '#' : '/mypage/setting'}
onClick={toggleMobileMenu}
>
{isAdmin ? 'Admin Page' : 'My Page'}
</StyledLink>
{isLoggedIn && (
<StyledLink
to={isAdmin ? '#' : '/mypage/setting'}
onClick={toggleMobileMenu}
>
{isAdmin ? 'Admin Page' : 'My Page'}
</StyledLink>
)}
{isAdmin && (
<SubMenu>
<SubMenuItem>
Expand All @@ -98,22 +91,16 @@ const Header = () => {
</Login>
) : (
<>
<LogOut
onClick={() => {
localStorage.removeItem('role');
localStorage.removeItem('token');
setIsLoggedIn(false);
}}
>
<LogOut onClick={logout}>
<a>LogOut</a>
</LogOut>
{/* <LogOut>
<LogOut>
<CartIcon>
<StyledLink to="/cart" onClick={toggleMobileMenu}>
<img src={cart} alt="장바구니 아이콘" />
</StyledLink>
</CartIcon>
</LogOut> */}
</LogOut>
</>
)}{' '}
</NavList>
Expand Down Expand Up @@ -300,7 +287,7 @@ const Login = styled.li`
text-decoration: none;
display: block;
text-align: center;
margin-top: 4px;
margin-top: 5px;
font-weight: bold;
}
Expand Down Expand Up @@ -329,11 +316,11 @@ const LogOut = styled.li`
padding: 0px 10px;
a {
font-size: 15px;
color: white;
text-decoration: none;
display: block;
text-align: center;
margin-top: 1px;
font-weight: bold;
}
Expand Down Expand Up @@ -370,16 +357,17 @@ const StyledLink = styled(Link)`
}
`;

// const CartIcon = styled.div`
// img {
// width: 20px;
// height: 20px;
// }

// @media (min-width: 576px) and (max-width: 767px) {
// img {
// width: 25px;
// height: 25px;
// }
// }
// `;
const CartIcon = styled.div`
img {
margin-top: -4px;
width: 22px;
height: 22px;
}
@media (min-width: 576px) and (max-width: 767px) {
img {
width: 25px;
height: 25px;
}
}
`;
25 changes: 10 additions & 15 deletions src/components/pages/HomePage/CategoryProduct.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useMemo, useState } from 'react';
import React, { useMemo, useState } from 'react';
import styled from 'styled-components';
import StarRating from '../../common/StarRating';
import DEFAULT_IMG from '../../../assets/icons/default-featured-image.png.jpg';
Expand Down Expand Up @@ -42,24 +42,19 @@ const CategoryProduct: React.FC<CategoryProductsProps> = ({
setSelectedCategory(category);
setIsExpanded(false);
};

const filtered = products.filter((product: Product) =>
product.category.toLowerCase().includes(selectedCategory.toLowerCase())
const filtered = useMemo(
() =>
products?.filter((product) =>
product.category.toLowerCase().includes(selectedCategory.toLowerCase())
) || [],
[selectedCategory, products]
);

const getRandomProducts = (products: Product[]): Product[] => {
const shuffled = [...products].sort(() => 0.5 - Math.random()); // Shuffle the array
const displayedProducts = useMemo(() => {
const shuffled = [...filtered].sort(() => 0.5 - Math.random());
return shuffled.slice(0, 8);
};

const displayedProducts = useMemo(
() => getRandomProducts(filtered),
[filtered]
);
}, [filtered]);

useEffect(() => {
//fetch상품
}, [selectedCategory]);
return (
<Recommend>
<CategoryWrapper>
Expand Down
Loading

0 comments on commit a2e9d87

Please sign in to comment.