diff --git a/src/App.tsx b/src/App.tsx index c071a18..d1f0de4 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,5 @@ -import { BrowserRouter, Route, Routes } from 'react-router-dom'; -import { QueryClient, QueryClientProvider } from 'react-query'; +import { BrowserRouter, Route, Routes } from "react-router-dom"; +import { QueryClient, QueryClientProvider } from "react-query"; import AuthContext from "./states/auth-context"; import Board from "./routes/Board"; @@ -15,25 +15,24 @@ import Schedule from "./routes/Schedule"; import Setting from "./routes/Setting"; import SignupForm from "./components/auth/signup/SignupForm"; import { useContext } from "react"; -import useApiError from './hooks/error/useApiError'; +import useApiError from "./hooks/error/useApiError"; const queryClient = new QueryClient(); function App() { const authCtx = useContext(AuthContext); - + const { handleError } = useApiError(); queryClient.setDefaultOptions({ queries: { onError: (error: any) => handleError(error) }, mutations: { onError: (error: any) => { - console.log('에러 app', error); + console.log("에러 app", error); handleError(error); }, }, }); - return ( @@ -41,7 +40,7 @@ function App() { {authCtx.isLoggedIn ? ( }> - } /> + } /> } /> } /> } /> @@ -50,7 +49,7 @@ function App() { ) : ( <> - } /> + } /> } /> } /> diff --git a/src/components/auth/login/LoginForm/index.tsx b/src/components/auth/login/LoginForm/index.tsx index e5207e2..a8e45d7 100644 --- a/src/components/auth/login/LoginForm/index.tsx +++ b/src/components/auth/login/LoginForm/index.tsx @@ -47,7 +47,7 @@ const LoginForm = () => { try { const response = await authAPI.login(userId, userPassword); authCtx.login(response.access_token); - navigate("/"); + navigate("/home"); const TOKEN_EXPIRE_TIME = 1000 * 60 * 60; //60분 setTimeout(() => { window.alert("로그인 유지 토큰이 만료되어 로그아웃됩니다."); diff --git a/src/components/common/createbutton/index.tsx b/src/components/common/createbutton/index.tsx index 95287de..ffe2a98 100644 --- a/src/components/common/createbutton/index.tsx +++ b/src/components/common/createbutton/index.tsx @@ -3,12 +3,13 @@ import { PencilWhiteIcon } from "../../Icons/BoardIcons"; import { Button } from "./style"; interface CreateButtonProps { - onSubmit: (e: React.SyntheticEvent) => void; + onClick?: (e: React.SyntheticEvent) => void; + onSubmit?: (e: React.SyntheticEvent) => void; } -const CreateButton = ({ onSubmit }: CreateButtonProps) => { +const CreateButton = ({ onClick, onSubmit }: CreateButtonProps) => { return ( - ); diff --git a/src/components/global/Layout/index.tsx b/src/components/global/Layout/index.tsx index 1b6ae75..eaf7950 100644 --- a/src/components/global/Layout/index.tsx +++ b/src/components/global/Layout/index.tsx @@ -3,8 +3,8 @@ import { Outlet } from "react-router-dom"; import styled from "styled-components"; import COLOR from "../../../constants/color"; -import NavBar from '../NavBar'; -import TopBar from '../TopBar'; +import NavBar from "../NavBar"; +import TopBar from "../TopBar"; const Layout = ({ children }: { children?: ReactElement }) => { return ( @@ -23,10 +23,8 @@ const Layout = ({ children }: { children?: ReactElement }) => { }; const Wrapper = styled.div` - width: max-content; min-width: 100vw; height: 100%; - display: flex; position: relative; `; diff --git a/src/components/global/NavBar/index.tsx b/src/components/global/NavBar/index.tsx index d0fcbb1..4192d5d 100644 --- a/src/components/global/NavBar/index.tsx +++ b/src/components/global/NavBar/index.tsx @@ -55,6 +55,7 @@ const NavBar = () => { const [width, setWidth] = useState(true); const location = useLocation().pathname; + const isHomeSelected = location.startsWith("/home"); const navigate = useNavigate(); @@ -68,7 +69,7 @@ const NavBar = () => { {width ? ( <> - navigate("/")}> + navigate("/home")}> setWidth(false)}> @@ -79,9 +80,9 @@ const NavBar = () => { diff --git a/src/components/home/HomeUpdate/index.tsx b/src/components/home/HomeUpdate/index.tsx index d31525d..96cbac9 100644 --- a/src/components/home/HomeUpdate/index.tsx +++ b/src/components/home/HomeUpdate/index.tsx @@ -4,37 +4,53 @@ import { useHome } from "../../../hooks/home/useHome"; import { useHomeUpdate } from "../../../hooks/home/useHomeUpdate"; import { ButtonContainer } from "../../../routes/Home/HomePage/style"; import CreateButton from "../../common/createbutton"; -import { HomeTextarea } from "./style"; +import { CharacterCount, HomeTextarea } from "./style"; import FONT from "../../../constants/fonts"; +import Container from "../../common/container"; function HomeUpdate() { const { home } = useHome(); const navigate = useNavigate(); const [content, setContent] = useState(home?.content); + const [characterCount, setCharacterCount] = useState(content?.length || 0); + const MAX_CHARACTER_COUNT = 10000; const updateMutation = useHomeUpdate(content!!); - const handleUpdateSubmit = (e: React.SyntheticEvent) => { - e.preventDefault(); + const handleUpdateSubmit = () => { updateMutation.mutate(); navigate(-1); }; const handleChange = (e: React.FormEvent) => { - setContent(e.currentTarget.value); + const text = e.currentTarget.value; + setContent(text); + setCharacterCount(text.length); }; return ( -
- + <> + + + + + {characterCount}/{MAX_CHARACTER_COUNT} + - + - + ); } diff --git a/src/components/home/HomeUpdate/style.ts b/src/components/home/HomeUpdate/style.ts index e6bca4a..cf4660b 100644 --- a/src/components/home/HomeUpdate/style.ts +++ b/src/components/home/HomeUpdate/style.ts @@ -2,14 +2,19 @@ import styled from "styled-components"; import COLOR from "../../../constants/color"; const HomeTextarea = styled.textarea` - width: 100%; - height: 29rem; - padding: 1.7rem; + height: 100%; border-radius: 0.5rem; + padding: 0.5rem; outline-color: ${COLOR.GRAY0}; - margin-bottom: 1rem; resize: none; - scrollbar-width: none; + scrollbar-height: none; + overflow: auto; `; -export { HomeTextarea }; +const CharacterCount = styled.div` + display: flex; + justify-content: flex-end; + margin: 0.5rem; +`; + +export { HomeTextarea, CharacterCount }; diff --git a/src/routes/Home/HomePage/index.tsx b/src/routes/Home/HomePage/index.tsx index 90c854f..d9586f8 100644 --- a/src/routes/Home/HomePage/index.tsx +++ b/src/routes/Home/HomePage/index.tsx @@ -1,5 +1,4 @@ import { ButtonContainer, HomeText } from "./style"; - import AuthContext from "../../../states/auth-context"; import Button from "../../../components/common/button"; import Container from "../../../components/common/container"; @@ -33,10 +32,10 @@ const HomePage = () => { return ( <>