Skip to content

Commit

Permalink
Merge pull request #42 from LikeLion-12th-SKHU/feat/#26-404-components
Browse files Browse the repository at this point in the history
Feat: 404์ปดํฌ๋„ŒํŠธ ๋ฐ ์—๋Ÿฌ ์ฒ˜๋ฆฌ
  • Loading branch information
GraceKim527 authored Sep 26, 2024
2 parents 7a6f252 + 9ee2a61 commit c8b52a3
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import RecommendHospital from "./pages/tracker/RecommendHospital";
import RequestList from "./pages/friends/RequestList";
import React, { useEffect, useState } from "react";
import MobileWarning from "./components/common/MobileWarning";
import NotFound from "./pages/Errors/NotFound";
import ProtectedRoute from "./components/ProtectedRoute";
import { configureAxios } from "./api/instance";
import { refreshAccessToken } from "./api/loginInstance";
Expand Down Expand Up @@ -127,6 +128,7 @@ function App() {
<Route path="/diary/:id" element={<DiaryDetail />} />
<Route path="/diary/edit/:id" element={<EditDiary />} />
<Route path="/hospital" element={<RecommendHospital />} />
<Route path="*" element={<NotFound />} />
</Route>
</Routes>
</>
Expand Down
20 changes: 18 additions & 2 deletions src/components/friends/RequestMessage.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
// src/components/friends/RequestMessage.jsx
import React, { useEffect, useState } from "react";
import shop from "../../assets/icons/Shop.svg";
import styled from "styled-components";
import styled, { keyframes } from "styled-components";

const fadeOut = keyframes`
0% {
opacity: 1;
}
70% {
opacity: 1;
}
100% {
opacity: 0;
}
`;

const ToastWrap = styled.div`
display: flex;
Expand All @@ -20,6 +35,7 @@ const ToastWrap = styled.div`
bottom: 20%;
left: 50%;
transform: translate(-50%, 20%);
animation: ${fadeOut} 3s forwards;
`;

const ToastImage = styled.img`
Expand All @@ -40,7 +56,7 @@ const RequestMessage = ({ message }) => {
useEffect(() => {
const timer = setTimeout(() => {
setIsVisible(false);
}, 5000);
}, 3000);

return () => clearTimeout(timer);
}, []);
Expand Down
19 changes: 19 additions & 0 deletions src/pages/Errors/NotFound.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from "react";
import { Container, Headline2, Paragraph1, Anchor } from "./style.jsx";
import AngryHoya from "../../assets/icons/AngryHoya.svg";

function NotFound() {
return (
<Container>
<img src={AngryHoya} alt="ํ˜ธ์•ผ ์•„์ด์ฝ˜" />
<Headline2>์ด๋Ÿฐ! ํŽ˜์ด์ง€๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์–ด์š”.</Headline2>
<Paragraph1>
ํŽ˜์ด์ง€์˜ ์ฃผ์†Œ๊ฐ€ ์ž˜๋ชป๋˜์—ˆ๊ฑฐ๋‚˜ ๋ณ€๊ฒฝ๋˜์–ด <br />
์š”์ฒญํ•œ ํŽ˜์ด์ง€๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.
</Paragraph1>
<Anchor to="/">ํ™ˆ์œผ๋กœ ์ด๋™ํ•˜๊ธฐ</Anchor>
</Container>
);
}

export default NotFound;
46 changes: 46 additions & 0 deletions src/pages/Errors/style.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import styled from "styled-components";
import { Link } from "react-router-dom";

export const Container = styled.div`
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 1rem;
max-width: 430px;
min-width: 360px;
height: 100vh;
background: #fff;
`;

export const Headline2 = styled.h2`
color: #525463
text-align: center;
font-family: Pretendard;
font-size: 1.25rem;
font-style: normal;
font-weight: 700;
line-height: 2.25rem;
letter-spacing: -0.01875rem;
`;

export const Paragraph1 = styled.p`
color: #2b2d36;
text-align: center;
font-family: Pretendard;
font-size: 1rem;
font-style: normal;
font-weight: 400;
line-height: 1.5rem;
letter-spacing: -0.00625rem;
`;

export const Anchor = styled(Link)`
color: #756ab6;
text-align: center;
font-family: Pretendard;
font-size: 1rem;
font-weight: 600;
text-decoration: underline;
`;
3 changes: 3 additions & 0 deletions src/pages/chat/Chat.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export default function Chat() {
]);
} catch (err) {
console.error(err);
alert(
"์„œ๋ฒ„ ์˜ค๋ฅ˜๋กœ ์ธํ•ด ํ˜ธ์•ผ์™€ ๋Œ€ํ™”ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ์ž ์‹œ ํ›„ ์‹œ๋„ํ•ด์ฃผ์„ธ์š”."
);
} finally {
setIsLoading(false);
}
Expand Down
13 changes: 12 additions & 1 deletion src/pages/friends/Friends.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function Friends() {
event.preventDefault();
try {
const response = await requestFriend(email);
console.log("Friend request sent:", response);
setMessage("์นœ๊ตฌ ์š”์ฒญ์„ ๋ณด๋ƒˆ์Šต๋‹ˆ๋‹ค.");
} catch (error) {
if (error.response) {
if (error.response.status === 404) {
Expand All @@ -41,6 +41,17 @@ function Friends() {
}
};

// 3์ดˆ ํ›„ ๋ฉ”์‹œ์ง€ ๋ฆฌ์…‹
useEffect(() => {
if (message) {
const timer = setTimeout(() => {
setMessage("");
}, 3000);

return () => clearTimeout(timer);
}
}, [message]);

useEffect(() => {
const getFriends = async () => {
const friendList = await fetchFriends();
Expand Down

0 comments on commit c8b52a3

Please sign in to comment.