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

๐Ÿ”–release:V0.0.2 #80

Merged
merged 7 commits into from
Dec 17, 2024
26 changes: 20 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@stomp/stompjs": "^7.0.0",
"@tanstack/react-query-devtools": "^5.59.0",
"axios": "^1.7.7",
"framer-motion": "^11.12.0",
"framer-motion": "^11.14.4",
"http-proxy-middleware": "^3.0.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand Down
58 changes: 30 additions & 28 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import CatsMap from "./pages/CatsMap";
import EditProfile from "./pages/Profile/EditProfile";
import EditProfile2 from "./pages/Profile/EditProfile2";
import MyProfile from "./pages/Profile/MyProfile";
import SavedPosts from "./pages/Profile/SavedPosts";
import WritePost from "./pages/Post/WritePost";
import "./index.css";
import NotFound from "./pages/NotFound";
Expand All @@ -23,6 +22,7 @@ import Scrap from "./pages/Scrap";
import EditPost from "./pages/Post/EditPost";
import FriendSent from "./pages/FriendSent.jsx";
import FriendReceive from "./pages/FriendReceive.jsx";
import { AnimatePresence } from "framer-motion";
class ErrorBoundary extends React.Component {
constructor(props) {
super(props);
Expand All @@ -34,8 +34,6 @@ class ErrorBoundary extends React.Component {
return { hasError: true };
}



render() {
if (this.state.hasError) {
// ๋Œ€์ฒด UI๋ฅผ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.
Expand All @@ -50,34 +48,38 @@ function App() {
<AuthProvider>
<ErrorBoundary>
<div className="max-w-[768px] min-h-screen mx-auto my-0 bg-yellow shadow-global ">
<Routes>
<Route path="/signup1" element={<SignUp1 />}></Route>
<Route path="/signup2" element={<SignUp2 />}></Route>
<Route path="/" element={<Login />}></Route>
<Route path="/login/findid" element={<FindId />}></Route>
<Route path="/login/findpwd" element={<FindPassword />}></Route>
<Route element={<PrivateRoutes />}>
<Route path="/main" element={<Main />}></Route>
<Route path="/catmap" element={<CatsMap />}></Route>
<Route path="/profile" element={<MyProfile />}></Route>
<Route path="/profile/edit" element={<EditProfile />}></Route>
<Route path="/profile/edit2" element={<EditProfile2 />}></Route>
<Route path="/profile/mycat" element={<Scrap />}></Route>
<Route path="/profile/posts" element={<SavedPosts />}></Route>
<Route path="/post/write" element={<WritePost />}></Route>
<Route path="/post/:id" element={<DetailPost />}></Route>
<Route path="/friend" element={<Friend />}></Route>
<Route path="/friend/profile" element={<FriendProfile />}></Route>
<Route path="/*" element={<NotFound />}></Route>
<Route path="/post/edit/:id" element={<EditPost />} />
<Route path="/friend/send" element={<FriendSent/>}/>
<Route path="/friend/receive" element={<FriendReceive/>}/>
</Route>
</Routes>
<AnimatePresence>
<Routes>
<Route path="/signup1" element={<SignUp1 />}></Route>
<Route path="/signup2" element={<SignUp2 />}></Route>
<Route path="/" element={<Login />}></Route>
<Route path="/login/findid" element={<FindId />}></Route>
<Route path="/login/findpwd" element={<FindPassword />}></Route>
<Route element={<PrivateRoutes />}>
<Route path="/main" element={<Main />}></Route>
<Route path="/catmap" element={<CatsMap />}></Route>
<Route path="/profile" element={<MyProfile />}></Route>
<Route path="/profile/edit" element={<EditProfile />}></Route>
<Route path="/profile/edit2" element={<EditProfile2 />}></Route>
<Route path="/profile/mycat" element={<Scrap />}></Route>
<Route path="/post/write" element={<WritePost />}></Route>
<Route path="/post/:id" element={<DetailPost />}></Route>
<Route path="/friend" element={<Friend />}></Route>
<Route
path="/friend/profile"
element={<FriendProfile />}
></Route>
<Route path="/*" element={<NotFound />}></Route>
<Route path="/post/edit/:id" element={<EditPost />} />
<Route path="/friend/send" element={<FriendSent />} />
<Route path="/friend/receive" element={<FriendReceive />} />
</Route>
</Routes>
</AnimatePresence>
</div>
</ErrorBoundary>
</AuthProvider>
);
}

export default App;
export default App;
16 changes: 16 additions & 0 deletions src/components/common/Wrapper.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { motion } from "framer-motion";
import { pageEffect } from "../../styles/animation";
export default function Wrapper({ children, ...rest }) {
return (
<motion.div
initial="initial"
animate="in"
exit="out"
transition={{ duration: 0.5 }}
variants={pageEffect}
{...rest}
>
{children}
</motion.div>
);
}
3 changes: 0 additions & 3 deletions src/components/nyangmap/KakaoMap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export default function KakoMap() {
await getLocation();
setLoading(false);
} catch (err) {

setError(true);
setLoading(false);
}
Expand All @@ -48,7 +47,6 @@ export default function KakoMap() {
setLoading(true);
await getLocation();
setLoading(false);
// ์œ„์น˜๊ฐ€ null์ธ์ง€ ํ™•์ธ
};

// useFetch ๋Œ€์‹  useEffect ์‚ฌ์šฉ
Expand All @@ -73,7 +71,6 @@ export default function KakoMap() {
}, [location, setPostsCount]);

if (locationError || error) {

return <Error />;
}
if (loading) {
Expand Down
14 changes: 7 additions & 7 deletions src/components/post/DetailPostHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ export default function DetailPostHeader({ postData }) {
const nav = useNavigate();
//๊ฒŒ์‹œ๋ฌผ ํŒ๋‹จ ๋ถˆ๋ฆฌ์–ธ ๊ฐ’
const myPost = async () => {
const response = await api.get(`/api/post/my/${postData?.postId}`);

//๋‚ด ๊ฒŒ์‹œ๋ฌผ์ธ ๊ฒฝ์šฐ
if (response.data.message === "TRUE") {
//๋กœ์ปฌ์Šคํ† ๋ฆฌ์ง€์—์„œ ๋‚ด์•„์ด๋”” ๊ฐ€์ ธ์˜ค๊ธฐ
const myuserId = localStorage.getItem("userId");
if (postData?.userId === myuserId) {
//๋‚ด ๊ฒŒ์‹œ๋ฌผ์ธ ๊ฒฝ์šฐ
setOptions(myOptions);
}
};
Expand Down Expand Up @@ -85,9 +85,9 @@ export default function DetailPostHeader({ postData }) {
alt="profile_img"
src={
postData?.profileUrl && postData.profileUrl !== "null"
? postData.profileUrl // ์œ ํšจํ•œ ํ”„๋กœํ•„ URL
: `${
import.meta.env.VITE_PUBLIC_URL
? postData.profileUrl // ์œ ํšจํ•œ ํ”„๋กœํ•„ URL
: `${
import.meta.env.VITE_PUBLIC_URL
}/assets/images/profile_default.png`
}
className="rounded-full w-10 h-auto bg-white"
Expand Down
28 changes: 28 additions & 0 deletions src/hooks/useLocationPermission.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { useState, useEffect } from "react";

const useLocationPermission = () => {
const [isLocationAllowed, setIsLocationAllowed] = useState(null); // ์œ„์น˜ ๊ถŒํ•œ ์ƒํƒœ (null: ํ™•์ธ ์ค‘, true: ํ—ˆ์šฉ, false: ๊ฑฐ๋ถ€)

// ์œ„์น˜ ๊ถŒํ•œ ์ƒํƒœ ํ™•์ธ
const checkLocationPermission = async () => {
try {
const permission = await navigator.permissions.query({ name: "geolocation" });
if (permission.state === "granted") {
setIsLocationAllowed(true);
} else {
setIsLocationAllowed(false);
}
} catch (error) {

setIsLocationAllowed(false);
}
};

useEffect(() => {
checkLocationPermission();
}, []);

return { isLocationAllowed };
};

export default useLocationPermission;
41 changes: 34 additions & 7 deletions src/pages/CatsMap.jsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,52 @@
import Header from "../components/common/Header";
import NavBar from "../components/common/NavBar";
import Title from "../components/common/Title";
import Wrapper from "../components/common/Wrapper";
import KakoMap from "../components/nyangmap/KakaoMap";
import NyangBox from "../components/nyangmap/NyangBox";
import useLocationPermission from "../hooks/useLocationPermission";
import { useCatMapPosts } from "../store/useCatMapPosts";

export default function CatsMap() {
const { postsCount } = useCatMapPosts();
//์œ„์น˜ ์ •๋ณด ํ—ˆ์šฉ์—ฌ๋ถ€
const { isLocationAllowed } = useLocationPermission();
return (
<div>
<Wrapper>
<Header />
<div className="h-20"></div>
<Title text={"NYANG MAP"} />
<main className="px-6 gap-4 pb-32">
<KakoMap />
<div className="text-slate-400 py-3">
ํ˜„์žฌ ์œ„์น˜ ๊ธฐ์ค€ 200๋ฏธํ„ฐ ๋‚ด์˜ ๊ณ ์–‘์ด๋“ค์ด ๋“ฑ์žฅํ•ด์š”!
</div>
<NyangBox catNumber={postsCount} />
{isLocationAllowed === null && <div>์œ„์น˜ ํ—ˆ์šฉ์—ฌ๋ถ€ ํ™•์ธ์ค‘...</div>}
{/* ์œ„์น˜ ํ—ˆ์šฉ์ด ์ˆ˜๋ฝ๋˜์—ˆ์„ ๋•Œ */}
{isLocationAllowed === true && (
<>
<KakoMap />
<div className="text-slate-400 py-3">
ํ˜„์žฌ ์œ„์น˜ ๊ธฐ์ค€ 200๋ฏธํ„ฐ ๋‚ด์˜ ๊ณ ์–‘์ด๋“ค์ด ๋“ฑ์žฅํ•ด์š”!
</div>
<NyangBox catNumber={postsCount} />
</>
)}
{/* ์œ„์น˜ ํ—ˆ์šฉ์ด ๊ฑฐ๋ถ€๋˜์—ˆ์„ ๋•Œ */}
{isLocationAllowed === false && (
<div className="flex flex-col text-left gap-5">
<a className="font-['Bungee'] text-lg pr-6 text-red-500">
์œ„์น˜ ๊ถŒํ•œ์ด ๊ฑฐ๋ถ€๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์„ค์ •์—์„œ ์œ„์น˜ ๊ถŒํ•œ์„ ํ—ˆ์šฉํ•ด์ฃผ์„ธ์š”.
</a>
<a className="font-['Bungee'] text-2xl pr-6">ios</a>
<a className="font-['Bungee'] text-sm">
์„ค์ •-&gt;์œ„์น˜ ์„œ๋น„์Šค-&gt;์ ‘์†ํ•œ ๋ธŒ๋ผ์šฐ์ € ์„ ํƒ-&gt;์œ„์น˜
์ ‘๊ทผํ—ˆ์šฉ-[&quot;์•ฑ์„ ์‚ฌ์šฉํ•˜๋Š” ๋™์•ˆ&quot;]์„ ํƒ
</a>
<a className="font-['Bungee'] text-2xl pr-6 pt-5">์•ˆ๋“œ๋กœ์ด๋“œ</a>
<a className="font-['Bungee'] text-sm">
์„ค์ •-&gt;์œ„์น˜-&gt;์œ„์น˜์‚ฌ์šฉ-[&quot;์‚ฌ์šฉ&quot;]์„ ํƒ
</a>
</div>
)}
</main>
<NavBar />
</div>
</Wrapper>
);
}
5 changes: 3 additions & 2 deletions src/pages/Friend.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Loading from "../components/common/Loading";
import { useQuery } from "react-query";
import api from "../api/api";
import {useNavigate} from "react-router-dom";
import Wrapper from "../components/common/Wrapper";

export default function Friend() {
//์นœ๊ตฌ๋ชฉ๋ก ๊ฐ€์ ธ์˜ค๊ธฐ
Expand All @@ -22,7 +23,7 @@ export default function Friend() {

const nav=useNavigate();
return (
<>
<Wrapper>
<Header />
<div className="h-20"></div>
<Title text="FRIEND" />
Expand Down Expand Up @@ -58,6 +59,6 @@ export default function Friend() {
</>
)}
<NavBar />
</>
</Wrapper>
);
}
Loading
Loading