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

Feature/footer 리펙토링 #146 #153

Merged
merged 58 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
4d0f450
fix: store api
rudtj Nov 15, 2024
4350428
Merge branch 'Weekly9' of https://github.com/kakao-tech-campus-2nd-st…
rudtj Nov 15, 2024
240338b
Merge branch 'Master' of https://github.com/kakao-tech-campus-2nd-ste…
jasper200207 Nov 18, 2024
3dcaecf
refactor: change localstorage key
jasper200207 Nov 18, 2024
a75d6d6
refactor: header
jasper200207 Nov 18, 2024
e505c4d
test: localtest
jasper200207 Nov 18, 2024
ec9e46a
refactor: farmlist 수정
rudtj Nov 18, 2024
123e018
refactor: review modal 수정
rudtj Nov 18, 2024
f1b6660
remove: 불필요한 경로 제거
rudtj Nov 18, 2024
519ae82
Merge pull request #141 from kakao-tech-campus-2nd-step3/Feature/Head…
rudtj Nov 18, 2024
76ce76f
refactor: 모달 연결
rudtj Nov 18, 2024
fb5d0b0
refactor: handleCancel 추가
rudtj Nov 18, 2024
6facd13
Merge branch 'Weekly9' of https://github.com/kakao-tech-campus-2nd-st…
rudtj Nov 18, 2024
45dcd03
refactor: listview 추가
rudtj Nov 18, 2024
41e4dfd
refactor: api 수정
rudtj Nov 19, 2024
88d74d5
refactor: wishpage 추가
rudtj Nov 19, 2024
d122df7
remove: 농장 위시리스트 삭제
rudtj Nov 19, 2024
deeab49
refactor: review list 수정
rudtj Nov 19, 2024
7362bf6
refactor: spelling 수정
rudtj Nov 19, 2024
b2465c9
refactor: spelling 수정
rudtj Nov 19, 2024
dcbbc21
refactor
rudtj Nov 19, 2024
b9c51f5
refactor: type 수정
rudtj Nov 19, 2024
91f8656
refactor: minH 추가
rudtj Nov 19, 2024
0527c95
feat: mock review 추가
rudtj Nov 19, 2024
f4196bc
feat: wish page 추가
rudtj Nov 19, 2024
b8a0aa2
refactor: wishlist 수정
rudtj Nov 19, 2024
7f79161
refactor: 경로 수정
rudtj Nov 19, 2024
b229f8b
feat: wishlist page 추가
rudtj Nov 19, 2024
d776878
refactor
rudtj Nov 19, 2024
7278bba
Merge pull request #142 from kakao-tech-campus-2nd-step3/Feature/Orde…
rudtj Nov 19, 2024
8ec5c60
refactor
rudtj Nov 19, 2024
9bbc5d7
feat: scroll saver
jasper200207 Nov 19, 2024
1dccc32
feat: refreshLogin
jasper200207 Nov 19, 2024
bb8527d
design: Product
jasper200207 Nov 19, 2024
b7673fe
fix: kakaologin url
jasper200207 Nov 19, 2024
5e6b587
fix: redirect after login
jasper200207 Nov 19, 2024
9f672f3
fix: header
jasper200207 Nov 19, 2024
b9b7375
fix: file name
jasper200207 Nov 19, 2024
19988bd
feat: product detail
jasper200207 Nov 19, 2024
c689457
refactor: 글자 수정
rudtj Nov 19, 2024
71f3452
refactor: api 추가
rudtj Nov 19, 2024
ba3f938
refactor: api 경로 수정
rudtj Nov 19, 2024
63d2166
feat: schedule link
jasper200207 Nov 19, 2024
ea0ab24
Merge branch 'Weekly9' of https://github.com/kakao-tech-campus-2nd-st…
jasper200207 Nov 19, 2024
2e7defa
Merge pull request #149 from kakao-tech-campus-2nd-step3/Feature/Orde…
rudtj Nov 19, 2024
e198d47
refactor: intro
jasper200207 Nov 19, 2024
8c22d65
refactor: farm list 수정
rudtj Nov 19, 2024
2e059f4
Merge pull request #150 from kakao-tech-campus-2nd-step3/Feature/Orde…
rudtj Nov 19, 2024
d8329a0
fix: wishlist api
jasper200207 Nov 19, 2024
0004e24
fix: farmdetail
jasper200207 Nov 19, 2024
f201f72
fix: storedetail
jasper200207 Nov 19, 2024
af133c4
fix: mypage
jasper200207 Nov 19, 2024
5b9fb29
fix: sellerpage
jasper200207 Nov 19, 2024
be97a81
fix: header
jasper200207 Nov 19, 2024
c840a5f
Merge branch 'Weekly9' of https://github.com/kakao-tech-campus-2nd-st…
jasper200207 Nov 19, 2024
60a5dc8
Merge branch 'Weekly9' of https://github.com/kakao-tech-campus-2nd-st…
jasper200207 Nov 19, 2024
4c1e01c
Merge pull request #148 from kakao-tech-campus-2nd-step3/Feature/카드_리…
rudtj Nov 19, 2024
edff05d
Merge branch 'Weekly9' of https://github.com/kakao-tech-campus-2nd-st…
jasper200207 Nov 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/api/axiosInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const needAuthDefaultApi = axios.create({
baseURL: process.env.REACT_APP_API_URL,
headers: {
"Content-Type": "application/json",
Authorization: JSON.parse(localStorage.getItem("poomasi_user") || "{}")?.token
? `Bearer ${JSON.parse(localStorage.getItem("poomasi_user") || "{}").token}`
Authorization: JSON.parse(localStorage.getItem("poomasi-user") || "{}")?.token
? `Bearer ${JSON.parse(localStorage.getItem("poomasi-user") || "{}").token}`
: undefined,
},
withCredentials: true,
Expand Down
4 changes: 2 additions & 2 deletions src/api/intercepters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ const refrechIntercepter = async (response: AxiosResponse): Promise<AxiosRespons
alert("로그아웃 되었습니다. 다시 로그인해주세요.");
window.location.href = "/";
});
const user = JSON.parse(localStorage.getItem("poomasi_user") || "{}");
const user = JSON.parse(localStorage.getItem("poomasi-user") || "{}");

localStorage.setItem(
"poomasi_user",
"poomasi-user",
JSON.stringify({
...user,
token: result,
Expand Down
4 changes: 2 additions & 2 deletions src/atoms/userAtom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type UserAtomValue = {
role: string;
};

const userAtom = atom(localStorage.getItem("poomasi_user") ?? "");
const userAtom = atom(localStorage.getItem("poomasi-user") ?? "");

const userAtomWithPersistence = atom(
get => {
Expand All @@ -16,7 +16,7 @@ const userAtomWithPersistence = atom(
},
(_, set, data: UserAtomValue | null) => {
set(userAtom, JSON.stringify(data));
localStorage.setItem("poomasi_user", JSON.stringify(data));
localStorage.setItem("poomasi-user", JSON.stringify(data));
},
);

Expand Down
2 changes: 1 addition & 1 deletion src/components/common/KaKaoLoginButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Image from "@components/common/Image";
type KaKaoLoginButtonProps = ImageProps;

const KaKaoLoginButton = ({ ...props }: KaKaoLoginButtonProps) => {
const link = "https://api.poomasi.shop/oauth2/authentication/kakao";
const link = "http://172.22.42.12:8080/oauth2/authentication/kakao";

return (
<Link href={link} isExternal>
Expand Down
150 changes: 66 additions & 84 deletions src/components/layouts/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,109 +1,91 @@
import { useState } from "react";
import { Link } from "react-router-dom";
import { HeartOutlined, ShoppingCartOutlined } from "@ant-design/icons";
import { Box, Flex, Text, Icon } from "@chakra-ui/react";
import { Link, useLocation } from "react-router-dom";
import { HeartOutlined, ShoppingCartOutlined, LogoutOutlined } from "@ant-design/icons";
import { Flex, Text, Icon } from "@chakra-ui/react";
import poomasi from "@assets/logo/logo.png";
import Avatar from "@components/common/Avatar";
import Image from "@components/common/Image";
import useLogin from "@hooks/useLogin";

const Header = () => {
const [activeMenu, setActiveMenu] = useState<string>("");
const menuLinks = [
{
name: "소개",
link: "/introduction",
},
{
name: "상점",
link: "/store",
},
{
name: "농장",
link: "/schedule",
},
];

const { loginCheck, logout, sellerCheck } = useLogin();
const Header = () => {
const location = useLocation();

const handleMenuClick = (menu: string) => {
setActiveMenu(menu);
};
const { user, loginCheck, logout, sellerCheck } = useLogin();
return (
<Flex pos="relative" direction="column" shadow="lg" bgColor="#FFFFFF">
<Flex justify="flex-end" p="1px 60px" color="#1C4532" fontSize="8px" fontWeight="regular">
{loginCheck()
? [
<Text as={Link} mr="12px" to="/me">
마이페이지
</Text>,
<Text cursor="pointer" onClick={logout}>
로그아웃
</Text>,
]
: [
<Text as={Link} mr="12px" to="/email/register">
회원가입
</Text>,
<Text as={Link} to="/login">
로그인
</Text>,
]}
{sellerCheck() && (
<Text as={Link} ml="12px" to="/seller">
판매자 페이지
</Text>
)}
</Flex>

<Flex align="center" justify="space-between" p="10px 50px">
<Link to="/">
<Image h="30px" objectFit="contain" alt="poomasi" src={poomasi} />
</Link>

<Flex align="center" mx="20px" ml={-70}>
<Link to="/introduction">
<Text
mx="30px"
color={activeMenu === "소개" ? "#1C4532" : "#999999"}
fontSize="20px"
fontWeight="regular"
cursor="pointer"
onClick={() => handleMenuClick("소개")}
>
소개
</Text>
<Flex align="center" justify="space-between" p="5">
<Flex>
<Link to="/">
<Image h="30px" objectFit="contain" alt="poomasi" src={poomasi} />
</Link>
<Link to="/store">
{sellerCheck() && (
<Text
mx="30px"
color={activeMenu === "상점" ? "#1C4532" : "#999999"}
fontSize="20px"
as={Link}
align="center"
ml="3"
p="2"
color="white"
fontSize="12px"
fontWeight="regular"
bg="#1C4532"
borderRadius="xl"
cursor="pointer"
onClick={() => handleMenuClick("상점")}
to="/seller"
>
상점
farmer
</Text>
</Link>
<Link to="/schedule">
)}
{menuLinks.map(menuLink => (
<Text
mx="30px"
color={activeMenu === "농장" ? "#1C4532" : "#999999"}
as={Link}
mx="5"
color={menuLink.link === location.pathname ? "#1C4532" : "#999999"}
fontSize="20px"
fontWeight="regular"
cursor="pointer"
onClick={() => handleMenuClick("농장")}
to={menuLink.link}
>
농장
{menuLink.name}
</Text>
</Link>
))}
</Flex>

{/* <Input
w="400px"
h="40px"
ml={10}
px="20px"
border="2px solid #1C4532"
borderColor="#1C4532"
borderRadius="12px"
_placeholder={{ color: "#B3B3B3" }}
placeholder="검색어를 입력해주세요."
/> */}

<Flex ml={250}>
<Box mx="10px" color="#1C4532" cursor="pointer">
<Icon as={HeartOutlined} fontSize="25px" />
</Box>
<Box mx="10px" color="#1C4532" cursor="pointer">
<Icon as={ShoppingCartOutlined} fontSize="25px" />
</Box>
<Flex align="center" gap="5">
{loginCheck() ? (
[
<Link to="/me/wish">
<Icon as={HeartOutlined} color="#1C4532" fontSize="25px" />
</Link>,
<Link to="/cart">
<Icon as={ShoppingCartOutlined} color="#1C4532" fontSize="25px" />
</Link>,
<Flex as={Link} gap="1" to="/me">
<Avatar size="sm" src={user.profile} />
<Text color="#1C4532" fontSize="20px" fontWeight="regular" cursor="pointer">
{user.name}님
</Text>
</Flex>,
<Icon as={LogoutOutlined} color="#1C4532" fontSize="25px" cursor="pointer" onClick={() => logout()} />,
]
) : (
<Text as={Link} color="#1C4532" fontSize="20px" fontWeight="regular" cursor="pointer" to="/login">
로그인
</Text>
)}
</Flex>
</Flex>
</Flex>
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const useLogin = () => {

const sellerCheck = () => user?.role === "ROLE_FARMER";

return { login, logout, loginCheck, sellerCheck };
return { user, login, logout, loginCheck, sellerCheck };
};

export default useLogin;
Loading